Skip to content

Instantly share code, notes, and snippets.

View sheymann's full-sized avatar

Sébastien Heymann sheymann

View GitHub Profile
@sheymann
sheymann / export_plot.R
Created April 16, 2012 16:01
R tip: Export a ggplot plot in PDF, EPS and PNG files
View export_plot.R
ExportPlot <- function(gplot, filename, width=2, height=1.5) {
# Export plot in PDF and EPS.
# Notice that A4: width=11.69, height=8.27
ggsave(paste(filename, '.pdf', sep=""), gplot, width = width, height = height)
postscript(file = paste(filename, '.eps', sep=""), width = width, height = height)
print(gplot)
dev.off()
png(file = paste(filename, '_.png', sep=""), width = width * 100, height = height * 100)
print(gplot)
dev.off()
@sheymann
sheymann / sigma.fruchterman.js
Created February 28, 2013 15:37
Fruchterman-Reingold layout plugin for Sigma.js with automatic cooling and stopping condition.
View sigma.fruchterman.js
/**
* Linkurious 2012, all rights reserved.
* Sébastien Heymann <seb@linkurio.us>,
* Romain Yon <romain@linkurio.us>
*
* Please use http://jsbeautifier.org/ and indent with 2 spaces.
*
* Lib docs:
* http://twitter.github.com/bootstrap/
* http://docs.jquery.com/
View node_debian_init.sh
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
View avgdegree.groovy
#!/usr/bin/env groovy
import org.gephi.data.attributes.api.AttributeController
import org.gephi.graph.api.GraphController
import org.gephi.io.importer.api.EdgeDefault
import org.gephi.io.importer.api.ImportController
import org.gephi.io.processor.plugin.DefaultProcessor
import org.gephi.project.api.ProjectController
import org.gephi.statistics.plugin.Degree
import org.openide.util.Lookup
View linkurious.js
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' ] }
@sheymann
sheymann / internal_links.py
Created October 18, 2012 13:24
Internal Link Detection on Bipartite Graph
View internal_links.py
@sheymann
sheymann / entries.md
Created June 7, 2012 15:51 — forked from samuelclay/entries.md
Top entries in Knight News Challenge 2012
View entries.md
@sheymann
sheymann / skew.py
Created May 16, 2012 08:10
Mean, Standard deviation and Skewness functions
View skew.py
import sys
import math
myvalues = [-3, -2, -1, -1, 0, 1, 2, 3, 7]
def moy(l):
sommeval = reduce(lambda somme, val: somme+val, l, 0)
return (float(sommeval)/len(l))
@sheymann
sheymann / debug.R
Created April 16, 2012 16:04
R tip: enable DEBUG mode
View debug.R
options(error=utils::recover)
@sheymann
sheymann / gist:2400082
Created April 16, 2012 17:22
R ggplot2 tip: Change legend options
View gist:2400082
g <- g + opts(legend.position = c(0.5,0.86),
legend.title = theme_blank(),
legend.text = theme_text(size=11),
legend.key.size = unit(1, "lines"),
legend.key = theme_blank())