Skip to content

Instantly share code, notes, and snippets.

View sheymann's full-sized avatar

Sébastien Heymann sheymann

View GitHub Profile
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' ] }
@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');
@jbilcke
jbilcke / create_video.py
Last active July 25, 2023 07:14
How to create a video using Gephi + Scripting plugin + ffmpeg
execfile("/your/path/to/videomaker.py")
videomaker(
ts_min=1352261778000, # "from" timestamp..
ts_max=1352262378000, # .."to" timestamp
frames=20, # number of images in the video. eg 200 frames for a video at 20 frames per seconds = 10 seconds of video
output_prefix="/path/to/output/dir/frame_", # path where to write the png. images will be prefixed with "frame_"
output_format=".png" # you probably want to leave png here
)
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@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
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@sente
sente / formatXML.js
Last active April 4, 2024 12:20
javascript to format/pretty-print XML
The MIT License (MIT)
Copyright (c) 2016 Stuart Powers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: