Skip to content

Instantly share code, notes, and snippets.

@fblundun
fblundun / double_reverse_base64.py
Created October 30, 2015 09:31
List strings which may appear when a target string is doubly base 64-encoded
#!/usr/bin/python
import base64
import sys
input = sys.argv[1]
def get_combinations(s):
return [base64.urlsafe_b64encode('a'*i + s)[2*i:-4] for i in range(3)]
for x in [get_combinations(intermediate) for intermediate in get_combinations(sys.argv[1])]:
for y in x:
@fblundun
fblundun / manual_geolocation.js
Created November 20, 2015 09:10
Manually sending geolocation events
if (!geolocationContextAdded && navigatorAlias.geolocation && navigatorAlias.geolocation.getCurrentPosition) {
navigator.geolocation.getCurrentPosition(function (position) {
var coords = position.coords;
var geolocationContext = {
schema: 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0',
data: {
latitude: coords.latitude,
longitude: coords.longitude,
latitudeLongitudeAccuracy: coords.accuracy,
altitude: coords.altitude,
@fblundun
fblundun / getRootDomain.js
Created January 7, 2016 12:07
How to get the root domain on which cookies can be written
function getRootDomain() {
var split = window.location.hostname.split('.');
var position = split.length - 1;
while (position >= 0) {
var currentDomain = split.slice(position, split.length).join('.');
document.cookie = 'unique=unique;domain=' + currentDomain + ';';
if (document.cookie.indexOf('unique') > -1) {
return currentDomain;
}
position -= 1;
implicit class RichDfType(df: DfType) {
def f(pairs: List[(String, AType)]): DfType = pairs match {
case head :: tail => df.withColumn(head._1, head._2).f(tail)
case Nil => df
}
}
@fblundun
fblundun / get-open-shards.sh
Last active January 14, 2016 09:53
Easy way to view open shards of a Kinesis stream
#!/bin/sh
aws kinesis describe-stream --stream-name $1 |
jq '.StreamDescription.Shards | map(select(.SequenceNumberRange.EndingSequenceNumber == null))'
@fblundun
fblundun / improved_single_reverse_base64.py
Last active January 18, 2016 10:23
List strings which may appear when a target string is base 64-encoded
#!/usr/bin/python
import base64
import sys
input = sys.argv[1]
drop = [0, 2, 3]
def get_combinations(s):
return [(base64.urlsafe_b64encode('a'*i + s)[drop[i]:]).replace('=', '') for i in range(3)]
@fblundun
fblundun / collect_contexts.bash
Last active January 18, 2016 17:10
Rewriting data pipelines in bash
#!/bin/bash
set -e
path=$1;
schema=$2;
# String manipulation to extract "s3://first_part_of_path/"
path_prefix=$(echo $1 | sed 's_\(^s3://[^/]*/\).*$_\1_g');
@fblundun
fblundun / link-validator.py
Created January 25, 2016 08:55
GitHub wiki link validator
@fblundun
fblundun / convert_changelog.py
Last active March 15, 2016 16:40
Converting the snowplow/snowplow CHANGELOG to release notes
#!/usr/bin/env python
import fileinput
import sys
import re
domain = None
ignored_lines = 0
for line in fileinput.input():
if line == "\n":
break
@fblundun
fblundun / forecast.js
Last active May 31, 2016 08:18
Detect Snowplow
var page = require('webpage').create();
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: you must provide some URL to check');
phantom.exit();
}
page.open(system.args[1], function(status) {
var usesSnowplow;
var information;
if(status === "success") {