Skip to content

Instantly share code, notes, and snippets.

View bactisme's full-sized avatar

Baptiste M. bactisme

View GitHub Profile
@bactisme
bactisme / ua-classifed.go
Created December 22, 2016 15:47
Classify the result of UA-Parser
package main
/** This is a rewrite of the PHP ua-classifier in golang
* https://github.com/phlib/ua-classifier/blob/master/src/Classifier.php
*/
import (
"strings"
"github.com/ua-parser/uap-go/uaparser"
)
@bactisme
bactisme / Track RSS views via a pixel in the content
Last active December 8, 2016 14:20
Track RSS views via a pixel in the content
# --- RSS TRACKING
location ~ /ga_proxy_track\.gif {
set $mainDomain 'frandroid.com';
set $cid $cookie__ga_cid;
if ($cid = '') {
#set $cid "$request_id"; # only nginx 1.2.7
set $cid "$pid-$date_local";
}
add_header Set-Cookie "_ga_cid=$cid; path=/; domain=.$mainDomain";
set $uip "$remote_addr"; #x_forwarded_for
@bactisme
bactisme / quickperfcurl.sh
Last active April 21, 2020 12:15
quickperfcurl
#!/bin/bash
URL=$1
ITERATION=100
T1NAME=time_connect
T2NAME=time_starttransfer
T3NAME=time_total
T1=0
@bactisme
bactisme / BustRecapcha.php
Last active July 18, 2016 14:49
Extract a ReCapcha challenge to be presented to a external user
<?php
/*
PHP template to ask a recapcha challenge, present it to a user.
*/
<?php
class BustRecapcha {
<?php
// CONFIG
$servers = array(
array('Local', '127.0.0.1', 6379),
);
// END CONFIG
$server = 0;
if (isset($_GET['s']) && intval($_GET['s']) < count($servers)) {
$server = intval($_GET['s']);
@bactisme
bactisme / CJDeepLink.php
Created June 10, 2016 14:53
Commission Junction DeepLink Wrapper
@bactisme
bactisme / ZanoxDeepLink.php
Created June 10, 2016 14:48
Zanox DeepLink Toolbox Wrapper
@bactisme
bactisme / sendMessage.php
Created May 19, 2016 14:41
Send a web notification with OneSignal
function sendMessage($title, $url){
$content = array(
"en" => $title,
"fr" => $title
);
$fields = array(
'app_id' => ONESIGNAL_APP_ID,
'included_segments' => array('All'),
'url' => $url,
set tabstop=4
set shiftwidth=4
set expandtab
syntax on
set number
#set background=dark
#colorscheme solarized
@bactisme
bactisme / check_images_sizes
Created April 26, 2016 13:59
Take a file containing a liste of URL, print average, sum and max file size
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from lxml import html
import sys
def sum_avg_max(images):
total = sum(s for url, s in images)