Skip to content

Instantly share code, notes, and snippets.

View radiodario's full-sized avatar

Darío Villanueva radiodario

  • London
View GitHub Profile
@radiodario
radiodario / compileme.js
Last active December 24, 2015 23:39
Compiling on the fly for rich_
var fs = require('fs');
var code = '#include <stdio.h>\n int main (void){printf("testing");char x; x = getchar();printf("READ: %c",x);return 0;}';
var child = require('child_process');
fs.writeFile('tmp.c',code,function(){
console.log('Code written to disk');
var args = ['-o', process.cwd() + '/run', process.cwd() + '/tmp.c'];
console.log(args.join(' '));
@radiodario
radiodario / trimSouthEast.js
Last active December 24, 2015 14:09 — forked from mildfuzz/trimSouthEast.js
Helping fuzzy at #node.js work with imagemagick
var spawn = require('child_process').spawn;
var fs = require('fs');
var os = require('os');
exports.trimSouthEast = function(file, i){
/*
* Trims the bottom and right edges
*/
var origFile = process.cwd() + '/' + file;
// On index.js
//Configure Body Parser
app.configure(function() {
app.use(express.cookieParser())
app.use(express.session({
key: "QAWdefrAQ",
secret: 'asfyvhq987ertvyweiurytsdfgadekjr4yhtfsdfgt9jfwe3ht987234yh'
}))
app.use(express.bodyParser())
var express = require('express');
var mongoose = require('mongoose');
var app = module.exports = express.createServer();
var QueryModel = require('../lib/models/query');
// the base route is
// /db/queries
@radiodario
radiodario / Title.coffee
Created June 10, 2013 11:21
Rouge View
###
# Title module
Contains all the stuff related to the title,
from autogenerating it to storing a different
one
###
define [
'app'
# modules
@radiodario
radiodario / symmetric.js
Last active December 16, 2015 20:49
Define the symmetric of an integer as the integer obtained by inverting the order of its digits, eg 4321 is the symmetric of 1234. What are the numbers for which the square is equal to the symmetric of the square of the symmetric?
function symmetric(number) {
return parseInt((''+number).split('').reverse().join(''));
}
var i = 0;
while (true) {
if ((""+symmetric(i)).length === (""+i).length) {
if (symmetric(i*i) === (symmetric(Math.pow(symmetric(i), 2))))
console.log(i)

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

# the collection
Cages.Cages = Backbone.Collection.extend(
model: Cages.Cage
url: app.dataServer + 'cages.json?date=2013-04-07&fetch_relationships=true'
)
# shows a list of cages
Cages.Views.CagesList = Backbone.View.extend(
# Truly the most ridiculous thing I could think of.
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("XML", "png", "devtools", "RCurl")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Some helper functions, lineFinder and makeTable
source_gist("818983")
source_gist("818986")
@radiodario
radiodario / gist:5258708
Created March 27, 2013 22:30
make www on your cordova project a symlink to your dist folder on your grunt project.
ln -s $CORDOVAPROJECT/www $GRUNTPROJECT/dist