Skip to content

Instantly share code, notes, and snippets.

View sheymann's full-sized avatar

Sébastien Heymann sheymann

View GitHub Profile
angular.module('myServices')
.factory('visibilityBroadcaster', function($rootScope, $document, _) {
var document = $document[0],
features,
detectedFeature;
features = {
standard: {
eventName: 'visibilitychange',
@gka
gka / worldcup-network.gexf
Last active August 29, 2015 14:02
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
<?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" />
@conradlee
conradlee / mmap_edgelist_parser.py
Created November 4, 2011 11:31
Edgelist parser using python and numpy's mmap
import numpy
import subprocess
weighted_edge_dtype = [("n1", numpy.uint32),("n2", numpy.uint32),("weight", numpy.float64)]
def convert_edgelist_to_mmap(in_filename):
# First determine number of edges because we will need to
# pre-allocate memmap object and that action requires a size
# Use unix's wc (WordCount) to count lines because it is
sigi = sigma.instances[1];
var prefix = /.{7}/;
sigi.iterNodes(function (node) {
node.label = node.attr.kind + ": " + node.attr.name.replace(prefix, '');
});
WebFontConfig = {
google: { families: [ 'Lato::latin' ] }
@jexp
jexp / panama_papers_azerbaijan.adoc
Last active May 23, 2017 18:08
ICIJ Panama Papers Graph Model Exploration

The #PanamaPapers - Example Dataset President of Azerbaijan

Let’s look at the family of the Azerbaijan’s President Ilham Aliyev who was already the topic of a GraphGist by Linkurious in the past. We see his wife, two daughters and son depicted.

Source

@jexp
jexp / RunNeo4jImport.bat
Last active May 24, 2017 08:41
launch neo4j-shell in Neo4j-Desktop (exe on Windows, dmg on OSX)
"C:\Program Files\Neo4j Community\jre\bin\java" -cp "C:\Program Files\Neo4j Community\bin\neo4j-desktop-3.0.2.jar" \
org.neo4j.tooling.ImportTool %*
@dschnare
dschnare / cachetext.correct.js
Last active January 18, 2020 03:12
HTML5 Canvas Tricks: Text Caching and Registration Point
// Create our stage canvas.
var stage = document.createElement('canvas');
stage.style.border = '1px solid #000';
document.body.appendChild(stage);
// Create offscreen buffer for our text rendering.
// This way all we have to do is draw our buffer to
// the main canvas rather than drawing text each frame.
var textBuffer = document.createElement('canvas');
@rvanbruggen
rvanbruggen / foodimport.cql
Last active May 1, 2021 08:37
Food network import instructions
// create nodes
// create BaseNodes
import-cypher -d ; -i ./IMPORT/INPUT/1-basenodes.csv -o ./IMPORT/OUTPUT/nodeoutput.csv create (n:#{type} {id:{id},name:{name}}) return n
// create indexes
create index on :INGREDIENT_CATEGORY(name);
create index on :INGREDIENT(name);
create index on :INGREDIENT(id);
create index on :COMPOUND(name);
create index on :COMPOUND(id);
@abyx
abyx / angular-error-handling.js
Last active February 4, 2022 19:19
AngularJS HTTP Error Handling Mechanism
var HEADER_NAME = 'MyApp-Handle-Errors-Generically';
var specificallyHandleInProgress = false;
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) {
return {
// --- The user's API for claiming responsiblity for requests ---
specificallyHandled: function(specificallyHandledBlock) {
specificallyHandleInProgress = true;
try {
return specificallyHandledBlock();
@jannecederberg
jannecederberg / formspree.html
Last active November 4, 2022 12:26 — forked from manfromanotherland/formspree.html
JS: Ajax send forms using the most excellent Formspree » http://formspree.io #snippet
<form id="contact-form" action="//formspree.io/your@email.com" method="post">
<input type="text" name="Name" placeholder="Name" required>
<input type="email" name="Email" placeholder="Email" required>
<textarea name="Message" cols="30" rows="6" placeholder="Message" required></textarea>
<!-- CONFIG -->
<input class="is-hidden" type="text" name="_gotcha">
<input type="hidden" name="_subject" value="Subject">
<input type="hidden" name="_cc" value="email@cc.com">
<!-- /CONFIG -->
<input class="submit" type="submit" value="Send">