Skip to content

Instantly share code, notes, and snippets.

View plot.awk
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device.
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
israelst / getAllColors.js
Last active Mar 19, 2019
Get all colors used in a webpage.
View getAllColors.js
const els = document.querySelectorAll('*');
const isColorProperty = property => property.toLowerCase().indexOf('color') > -1;
colors = new Set();
for(el of els)
for(property in getComputedStyle(el))
View overlay.css
position: relative;
.overlay > *{
position: relative;
z-index: 1;
israelst /
Last active Feb 3, 2019
Helper functions to data structures hacking
def chunk_indexes(size, chunk_size):
start = (size % chunk_size) or chunk_size
upper_boundary = list(range(start, size + 1, chunk_size))
lower_boundary = [0] + upper_boundary[:-1]
return zip(lower_boundary, upper_boundary)
israelst /
Created May 25, 2016
GNIP Historical PowerTrack parse
# coding: utf-8
import json
fd = open('all.json')
lines = fd.readlines()
tweets = map(json.loads, lines)
ptBR_tweets = filter(lambda l: l['language']=='pt', tweets)
israelst /
Created Oct 1, 2015
Return a list of unique keys from a list of dicts.
def keys_from_dicts(dicts):
all_keys = sum(map(dict.keys, dicts), [])
return list(set(all_keys))
israelst /
Last active Aug 29, 2015
This is a example to show a reduced version of gitflow. We are considering two remotes at local repository, the origin (fork) and the upstream (central):
(master) $ # starting a new task
(master) $ git pull --ff-only upstream master
(master) $ git checkout -b feature/new-task
(feature/new-task) $ # some coding
(feature/new-task) $ git add -p
(feature/new-task) $ git commit -m "The answer of all questions of the universe"
(feature/new-task) $ git push origin feature/new-task
(feature/new-task) $ # Do a pull request from feature/new-task to master and wait for coworker acceptance
(feature/new-task) $ git checkout master
(master) $ git pull --ff-only upstream master
israelst / preprocess.js
Last active Aug 29, 2015
Function that turns Facebook insights into a flat structure.
View preprocess.js
function preprocess(post){
var flatPost =, insight){
post[] = insight.values[0].value;
return post;
}, {});
flatPost.likes = post.likes.summary.total_count;
flatPost.comments = post.comments.summary.total_count;
flatPost.shares = (post.shares || {'count': 0}).count;
israelst / insights.html
Last active Aug 29, 2015
Show facebook post data with d3.parcoords
View insights.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<title>Curto Café Facebook Page</title>
<script src="preprocess.js" charset="utf-8"></script>
<script src="" charset="utf-8"></script>
<script src="" charset="utf-8"></script>
<link href="" rel="stylesheet" />
israelst /
Last active Dec 25, 2015
From csv to json in one twitt
import csv, json
f = open('sample.csv', 'r')
reader = csv.DictReader(f, fieldnames=("col1","col2"))
print json.dumps(list(reader))
You can’t perform that action at this time.