.htaccess redirect if # exist in URI

i've been looking for this solution and i couldnt find anything.

i've been looking for this solution and i couldnt find anything.

the idea is redirect depend on URI string but the problem is htaccess can't catch #.

IF # exist in URI redirect to LINK_A

ELSE redirect to LINK_B

here my little code and its not working for me

RewriteEngine on
RewriteRule ^((?!#).)*$ http://google.fr [L,R=301,NE]
RewriteRule # http://redirect.fr [L,R=301,NE]


Apache Spark Tutorial - Apache Spark Full Course - Learn Apache Spark

Apache Spark Tutorial - Apache Spark Full Course - Learn Apache Spark

This video will help you understand and learn Apache Spark in detail. This Spark tutorial is ideal for both beginners as well as professionals who want to master Apache Spark concepts.

This video will help you understand and learn Apache Spark in detail. This Spark tutorial is ideal for both beginners as well as professionals who want to master Apache Spark concepts. Below are the topics covered in this Spark tutorial for beginners:

2:44 Introduction to Apache Spark

3:49 What is Spark?

5:34 Spark Eco-System

7:44 Why RDD?

16:44 RDD Operations

18:59 Yahoo Use-Case

21:09 Apache Spark Architecture

24:24 RDD

26:59 Spark Architecture

31:09 Demo

39:54 Spark RDD

41:09 Spark Applications

41:59 Need For RDDs

43:34 What are RDDs?

44:24 Sources of RDDs

45:04 Features of RDDs

46:39 Creation of RDDs

50:19 Operations Performed On RDDs

50:49 Narrow Transformations

51:04 Wide Transformations

51:29 Actions

51:44 RDDs Using Spark Pokemon Use-Case

1:05:19 Spark DataFrame

1:06:54 What is a DataFrame?

1:08:24 Why Do We Need Dataframes?

1:09:54 Features of DataFrames

1:11:09 Sources Of DataFrames

1:11:34 Creation Of DataFrame

1:24:44 Spark SQL

1:25:14 Why Spark SQL?

1:27:09 Spark SQL Advantages Over Hive

1:31:54 Spark SQL Success Story

1:33:24 Spark SQL Features

1:37:15 Spark SQL Architecture

1:39:40 Spark SQL Libraries

1:42:15 Querying Using Spark SQL

1:45:50 Adding Schema To RDDs

1:55:05 Hive Tables

1:57:50 Use Case: Stock Market Analysis with Spark SQL

2:16:50 Spark Streaming

2:18:10 What is Streaming?

2:25:46 Spark Streaming Overview

2:27:56 Spark Streaming workflow

2:31:21 Streaming Fundamentals

2:33:36 DStream

2:38:56 Input DStreams

2:40:11 Transformations on DStreams

2:43:06 DStreams Window

2:47:11 Caching/Persistence

2:48:11 Accumulators

2:49:06 Broadcast Variables

2:49:56 Checkpoints

2:51:11 Use-Case Twitter Sentiment Analysis

3:00:26 Spark MLlib

3:00:31 MLlib Techniques

3:01:46 Demo

3:11:51 Use Case: Earthquake Detection Using Spark

3:24:01 Visualizing Result

3:25:11 Spark GraphX

3:26:01 Basics of Graph

3:27:56 Types of Graph

3:38:56 GraphX

3:40:42 Property Graph

3:48:37 Creating & Transforming Property Graph

3:56:17 Graph Builder

4:02:22 Vertex RDD

4:07:07 Edge RDD

4:11:37 Graph Operators

4:24:37 GraphX Demo

4:34:24 Graph Algorithms

4:34:40 PageRank

4:38:29 Connected Components

4:40:39 Triangle Counting

4:44:09 Spark GraphX Demo

4;57:54 MapReduce vs Spark

5:13:03 Kafka with Spark Streaming

5:23:38 Messaging System

5:21:15 Kafka Components

2:23:45 Kafka Cluster

5:24:15 Demo

5:48:56 Kafka Spark Streaming Demo

6:17:16 PySpark Tutorial

6:21:26 PySpark Installation

6:47:06 Spark Interview Questions

Ursa Labs and Apache Arrow in 2019

Ursa Labs and Apache Arrow in 2019

In this talk I will discuss the current status of the project and Ursa Labs, a new not-for-profit development group I founded to focus on Arrow development. I will give a preview of our Arrow development roadmap for 2019 and how it may impact the Python data science ecosystem

For the last 3 years, the Apache Arrow project has been developing a language-independent open standard in-memory format for tabular data and a library ecosystem that builds on top of the format.

In this talk I will discuss the current status of the project and Ursa Labs, a new not-for-profit development group I founded to focus on Arrow development. I will give a preview of our Arrow development roadmap for 2019 and how it may impact the Python data science ecosystem

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Apache

Apache Kafka Series - Learn Apache Kafka for Beginners v2

How To Install the Apache Web Server on CentOS 7

Apache Spark 2 with Scala - Hands On with Big Data!

Taming Big Data with Apache Spark and Python - Hands On!

An Introduction to Regex in Python

An Introduction to Regex in Python

An Introduction to Regex in Python

What is Regex?

Regex stands for Regular Expression and essentially is an *easy *way to define a pattern of characters. Regex is mostly used in pattern identification, text mining or input validation.

Regex puts a lot of people off, because it looks like gibberish on first look; as for the people who know how to use it, they can’t seem to stop! It’s a very powerful tool that is worth learning about if you don’t already know.

Introduction to Regex

The first thing you need to know about regex, is that you can match a specific character or words.

Let’s assume, that we want to know whether a specific string, contains the letter ‘a’ or word ‘lot’. If that is the case, we can use the following python code:

import re
str = "Learning regex can be a lot of fun"
lst = re.findall('a', str)
lst2 = re.findall('lot', str)
print(lst)
print(lst2)

which will return, a list with 3 matches and a list of 1:

['a', 'a', 'a']
['lot']

Keeping our set up the same, imagine that you want to search for the following 3 letters in any order a, b or c. You can use a list, by using square brackets:

lst = re.findall('[abc]', str)
lst2 = re.findall('[a-c]', str)
print(lst)
print(lst2)

returning:

['a', 'c', 'a', 'b', 'a']
['a', 'c', 'a', 'b', 'a']

Photo by Dayne Topkin on Unsplash

The Regex Cheat Sheet

Every time I am about to write a complicate regular expression, my first port of contact is the following list, by Dr Chuck Severance:

Python Regular Expression Quick Guide

^        Matches the beginning of a line
$        Matches the end of the line
.        Matches any character
\s       Matches whitespace
\S       Matches any non-whitespace character
*        Repeats a character zero or more times
*?       Repeats a character zero or more times 
         (non-greedy)
+        Repeats a character one or more times
+?       Repeats a character one or more times 
         (non-greedy)
[aeiou]  Matches a single character in the listed set
[^XYZ]   Matches a single character not in the listed set
[a-z0-9] The set of characters can include a range
(        Indicates where string extraction is to start
)        Indicates where string extraction is to end

Using the above cheat sheet as a guide, you can pretty much come up with any syntax. Let’s take a closer look in some more complicate search patterns.

Stepping it Up

Imagine that you are building some sort of validation on an input field where the user can input any number followed by the letter d, m or y.

Your regex algorithm would look something like this:

^[0-9]+[dmy]$

Decomposing the above: ^ signifies the beginning of the match followed by a 0–9 number. However the + sign means it needs to be at least one 0–9 number though there can be more. Then the string needs to be followed by d, m or y, which have to be at the end because of $.

Testing the above in python:

import re
str = '1d'
str2 = '200y'
str3 = 'y200'
lst = re.findall('^[0-9]+[dmy]$', str)
lst2 = re.findall('^[0-9]+[dmy]$', str2)
lst3 = re.findall('^[0-9]+[dmy]$', str3)
print(lst)
print(lst2)
print(lst3)

Returning:

['1d']
['200y']
[]

Photo by Arget on Unsplash

Escaping Special Characters

When it comes to regular expressions, certain characters are special. For instance, dot, star and dollar sign are all used for matching purposes. So what happens if you want to match those characters?

In that case, we can use the back slash.

import re
str = 'Sentences have dots. How do we escape them?'
lst = re.findall('.', str)
lst1 = re.findall('\.', str)
print(lst)
print(lst1)

The above example is using dot, and backslash dot. As you would expect, it returns two results. The first one matches all characters, while the second one, only the dot.

['S', 'e', 'n', 't', 'e', 'n', 'c', 'e', 's', ' ', 'h', 'a', 'v', 'e', ' ', 'd', 'o', 't', 's', '.', ' ', 'H', 'o', 'w', ' ', 'd', 'o', ' ', 'w', 'e', ' ', 'e', 's', 'c', 'a', 'p', 'e', ' ', 't', 'h', 'e', 'm', '?']
['.']

Matching exact number of characters

Imagine that you want to match a date. You know that what the format will be, DD/MM/YYYY. Sometimes there will be 2Ds or 2Ms, sometimes just one, but always 4Ys.

import re
str = 'The date is 22/10/2018'
str1 = 'The date is 3/1/2019'
lst = re.findall('[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}', str)
lst = re.findall('[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}', str1)
print(lst)
print(lst1)

Which gives the following results:

['22/10/2018']
['3/1/2019']

Extracting the matched pattern

There are certain times, that knowing the fact that you’re matching a pattern is not enough. You want to have the ability to extract information from the match.

For instance, imagine that you are scanning a large data set looking for email addresses. If you use what we learnt about, you could search for a pattern of:

  • Could start with a letter, number, dot or underscore
  • Then followed by at least another letter, or number
  • Which could be followed by a dot or an underscore
  • Then there’s a @
  • Then follow the same logic again as before the @
  • Finally look for a dot followed by at least a letter
^[a-zA-Z0-9\.\_]*[a-zA-Z0-9]+[\.\_]*\@[a-zA-Z0-9\.\_]*[a-zA-Z0-9]+[\.\_]*\.[a-zA-z]+

From the above match, you only want to extract the domain name ie everything after the @. All you have to do is add brackets around what you’re after:

import re
str = '[email protected]'
lst = re.findall('^[a-zA-Z0-9\.\_]*[a-zA-Z0-9]+[\.\_]*\@([a-zA-Z0-9\.\_]*[a-zA-Z0-9]+[\.\_]*\.[a-zA-z]+)', str)
print(lst)

Returning:

['gmail.com']

In Summary

In summary, you can use regex to match strings of data and it can be used in a number of different ways. Python includes a regex package called re, which will allow you to use this. Should you find yourself on a Unix machine however, you can use regular expression along with grep, awk or sed. On Windows should you want to access all these commands, you can use tools like Cygwin.

Thanks for reading ❤

If you liked this post, share it with all of your programming buddies!