Skip to content

Instantly share code, notes, and snippets.

Marc-Olivier Arsenault marcolivierarsenault

Block or report user

Report or block marcolivierarsenault

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View extract.py
import json
from botocore.vendored import requests
url = 'https://voyagesarabais.com/recherche-sud/getpricedetails?search%5Bgateway%5D=YUL&search%5BdateDep%5D=2019-12-15&search%5Bduration%5D=7day%2C8day&search%5BdestDep%5D=o&search%5BnoHotel%5D=p7&search%5Broom1%5D=a%3A4%3A%7Bi%3A0%3Bs%3A2%3A%2240%22%3Bi%3A1%3Bs%3A2%3A%2240%22%3Bi%3A2%3Bs%3A1%3A%223%22%3Bi%3A3%3Bs%3A1%3A%221%22%3B%7D&search%5Broom2%5D=&search%5Broom3%5D=&search%5Broom4%5D=&search%5Broom5%5D=&search%5Broom6%5D=&search%5Bflex%5D=N&search%5Bflexhigh%5D=3&search%5Bflexlow%5D=3&search%5Broomcallgroup%5D=%5B%7B%22_priority%22%3A9%2C%22nb_rooms%22%3A1%2C%22nb_adults%22%3A2%2C%22non_adults%22%3A%5B%223%22%2C%221%22%5D%7D%5D&search%5Bpricemax%5D=9000&search%5Bpricemin%5D=1&search%5Ballinclusive%5D=Y&search%5Bbeach%5D=&search%5Bcasino%5D=&search%5Bfamily%5D=&search%5Bgolf%5D=&search%5Bkitchenette%5D=&search%5Boceanview%5D=&search%5Bminiclub%5D=&search%5Bspa%5D=&search%5Bwedding%5D=&search%5Badultonly%5D=&search%5Bnoextrasingle%5D=&search%5Bvilla%5D=&s
View regex.py
from utils.scala_functions import find_matching_patterns
from pyspark.sql import functions as F
regexes = regex.agg(F.collect_list(F.col("pattern"))).collect()[0][0]
regexes = sc.broadcast(regexes)
articles = articles \
.withColumn("patterns", find_matching_patterns(F.col("text"), regexes.value)
.withColumn("patterns", F.when(F.col("patterns").isNull(), F.array(F.lit(None))).otherwise(F.col("patterns"))) \
.withColumn("pattern", F.explode(F.col("patterns")))
View UDF.scala
def findMatchingPatterns(regexes: ArrayList[String]): UserDefinedFunction = {
udf((value: String) => {
for {
text <- Option(value)
matches = regexes.asScala.filter(r => Pattern.matches(r, text))
if matches.nonEmpty
} yield matches
}, ArrayType(StringType))
}
View rlike.py
wiki.join(regex, expr("text rlike pattern") how='left_outer')
View lossless_triplet_loss.py
def lossless_triplet_loss(y_true, y_pred, N = 3, beta=N, epsilon=1e-8):
"""
Implementation of the triplet loss function
Arguments:
y_true -- true labels, required when you define a loss in Keras, you don't need it in this function.
y_pred -- python list containing three objects:
anchor -- the encodings for the anchor data
positive -- the encodings for the positive data (similar to anchor)
negative -- the encodings for the negative data (different from anchor)
View defaultSiamese.py
def triplet_loss(y_true, y_pred, alpha = 0.4):
"""
Implementation of the triplet loss function
Arguments:
y_true -- true labels, required when you define a loss in Keras, you don't need it in this function.
y_pred -- python list containing three objects:
anchor -- the encodings for the anchor data
positive -- the encodings for the positive data (similar to anchor)
negative -- the encodings for the negative data (different from anchor)
@marcolivierarsenault
marcolivierarsenault / Alt Coin Scraper
Created Jan 15, 2018
lamda function to get all the lambda function and store them in a database
View Alt Coin Scraper
import json
import decimal
import urllib.request
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('AltCoinHistory')
def lambda_handler(event, context):
View .tmux.conf
# change the prefix from 'C-b' to 'C-a'
# (remap capslock to CTRL for easy access)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
@marcolivierarsenault
marcolivierarsenault / .vimrc
Created Mar 20, 2017
My own vimrc config file
View .vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Marc-Olivier Arsenault
" marcolivier.arsenault@gmail.com
"
" Version:
" 1.0 - 20/03/2017
"
" Blog_post:
" Highly inspired from Awesome vim file
@marcolivierarsenault
marcolivierarsenault / Spy.py
Last active Jan 4, 2017
Protocol sniffer between two serial port. Dump the output to a file and in the consol
View Spy.py
'''
Protocol sniffer between two serial port. Dump the output to a file and in the consol
@Author Marc-Olivier Arsenault
@Date Jan 3rd 2017
'''
import serial
import sys
port1 = "/dev/ttyS1"
port2 = "/dev/ttyS3"
You can’t perform that action at this time.