Skip to content

Instantly share code, notes, and snippets.

View cancerberoSgx's full-sized avatar

Sebastián Gurin cancerberoSgx

  • home
  • Montevideo, Uruguay
View GitHub Profile
@shancarter
shancarter / README.md
Last active June 7, 2019 11:42
Using d3 to generate SVGs in node.js

In order to generate some svg with d3 in node.js, you need a dom. This is a bare bones example of using jsdom for said dom.

@Xaekai
Xaekai / ipc.example.js
Created July 11, 2016 18:12
Example of Interprocess communication in Node.js through a UNIX domain socket
/*
**
** Example of Interprocess communication in Node.js through a UNIX domain socket
**
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
**
*/
@fusepilot
fusepilot / css-attributes.pegjs
Last active May 23, 2019 02:56
Peg.js Simple CSS Attribute Parsing
/*
* CSS like attribute parsing.
*
* Parses strings like `comp[name=myComp] > layer[name=myLayer light=true selected]` to objects.
*/
{
function mergeProps(array){
var merged = {};
@jrenggli
jrenggli / backup-all-docker-images.sh
Created December 8, 2015 17:56
Backup/Save all Docker Images to a compressed file
docker images | tail -n +2 | grep -v "none" | awk '{printf("%s:%s\n", $1, $2)}' | while read IMAGE; do
echo $IMAGE
filename="${IMAGE//\//-}"
filename="${filename//:/-}.docker-image.gz"
docker save ${IMAGE} | pigz --stdout --best > $filename
done
@nikcorg
nikcorg / promisified-hyperquest.js
Last active May 10, 2018 05:44
Promisified Hyperquest -- A quick exercise wrapping Hyperquest in a Promise for an easy thenable API.
var concat = require("concat-stream");
var hyperquest = require("hyperquest");
var Promise = require("bluebird");
var stream = require("stream");
// Wait for the request to finish or fail
function promisify(req) {
return new Promise(function (resolve, reject) {
req.on("error", reject).pipe(concat({ encoding: "string" }, resolve));
var _ = require('underscore');
var Backbone = require('backbone');
var cheerio = require('cheerio');
var request = require('request');
Backbone.ajax = function(options) {
options.json = true;
return request(options, function(error, result) {
if (error) {
define([
'Backbone'
], function(
Backbone
){
// I've evalled the entire file at this point, using cmd + A, cmd + Enter
Backbone // cmd + Enter returns me `undefined`, although in the application, it would be the Backbone library object
})
@icfantv
icfantv / FontResource.java
Last active April 20, 2018 13:03
font resource
public interface FontResource extends ClientBundle
{
FontResource INSTANCE = GWT.create(FontResource.class);
@Source("font1.otf")
DataResource font1();
@Source("font2.otf")
DataResource font2();
@amatiasq
amatiasq / Handlebars- Backbone.js
Created February 5, 2013 00:06
This allow Handlebars to look up Backbone Model's attributes: {{ user.address.street }} If user is a Backbone Model this will become user.get("address").street And if user.get("adress") is also a Backbone Model this will be produced: user.get("address").get("street")
Handlebars.JavaScriptCompiler.prototype.nameLookup = function(parent, name, type) {
var result = '(' + parent + ' instanceof Backbone.Model ? ' + parent + '.get("' + name + '") : ' + parent;
if (/^[0-9]+$/.test(name)) {
return result + "[" + name + "])";
} else if (Handlebars.JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
return result + "." + name + ')';
} else {
return result + "['" + name + "'])";
}
};
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream