Skip to content

Instantly share code, notes, and snippets.

🐢

Gregor Aisch gka

🐢
Block or report user

Report or block gka

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
@gka
gka / publish-chart.php
Last active Aug 29, 2015
Script for publishing Datawrapper charts via command-line
View publish-chart.php
<?php
/*
* This scripts triggers the chart publication process.
* Usage: php publish-chart.php [CHART_ID]
*/
define('ROOT_PATH', '../'); // relative path to your Datawrapper root
define('NO_SLIM', 1);
define('NO_SESSION', 1);
View README.md

Created by Christopher Manning

Summary

Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.

The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.

Controls

@gka
gka / worldcup-network.gexf
Last active Aug 29, 2015
Network of 2014 World Cup teams, their players and the clubs they are playing in. Derived from the FIFA.com player database. Used to make this graphic: http://www.nytimes.com/interactive/2014/06/20/sports/worldcup/how-world-cup-players-are-connected.html?ref=worldcup
View worldcup-network.gexf
<?xml version="1.0" encoding="utf-8"?><gexf version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="undirected" mode="static">
<attributes class="node" mode="static">
<attribute id="0" title="country_rank" type="integer" />
<attribute id="1" title="confederation" type="string" />
<attribute id="2" title="team_count" type="integer" />
<attribute id="3" title="country" type="string" />
<attribute id="4" title="premier" type="boolean" />
<attribute id="5" title="type" type="string" />
<attribute id="6" title="rank" type="integer" />
@gka
gka / gist:59918662ff4c15f9c4bf
Created Aug 26, 2014
Batch rename a bunch of files
View gist:59918662ff4c15f9c4bf
for i in *.php ; do mv "$i" "`basename $i .php`.json" ; done
View git-go.js
#!/usr/bin/env node
var cmds = [];
if (process.argv.length < 3) {
console.log('You need to provide a commit message!');
process.exit(-1);
}
cmds.push('git add -A');
cmds.push('git add -u');
View multiple-screenshots.js
var page = require('webpage').create();
page.viewportSize = { width: 1402*2, height: 800*2 };
page.zoomFactor = 2;
page.open('http://localhost:1337/?forceRetina=1', function() {
var s = 420, z = 2;
page.clipRect = {
top: z * (630-s/2),
left: z * (1402 - s)/2,
width: z * s,
height: z * s
@gka
gka / rm_old.sh
Created Sep 17, 2015
Remove everything but five newest files/directories
View rm_old.sh
(ls -t|head -n 5;ls)|sort|uniq -u|xargs rm -Rf
@gka
gka / WikipediaPlainTables
Created Aug 3, 2011
Ever tried to copy&paste a table from Wikipedia to your favourite spreadsheet software? You just want the pure data and not all those hyperlinks and embedded images? This script removes unnecessary stuff from the tables. Simply run in firebug console and
View WikipediaPlainTables
// remove all images
$('table img').remove();
// remove all reference links
$('table .reference').remove()
// convert all links to plain text
$('table a').each(function(index, el) { $(el).replaceWith($(el).html()) });
@gka
gka / csv2tsv
Created Sep 16, 2011
Converting a comma-separated and quoted file into a tab-separated and unquoted file
View csv2tsv
#!/usr/bin/env python2.7
"""
No more trouble with comma-separated and quoted CSV files.
"""
import csv, sys
if len(sys.argv) != 3: print 'Usage:\ncsv2tsv fromfile.csv tofile.tsv'
file_in = sys.argv[1]
file_out = sys.argv[2]
@gka
gka / gisutils.py
Created Oct 6, 2011
Some GIS utils for Python, like area computation for geo-polygons
View gisutils.py
"""
implementation taken from
http://forum.worldwindcentral.com/showthread.php?t=20724
algorithm expects a list of [lng,lat] pairs in degrees
"""
def haversine(x):
from math import cos
return ( 1.0 - cos(x) ) / 2.0
You can’t perform that action at this time.