Skip to content

Instantly share code, notes, and snippets.

View deciob's full-sized avatar

Decio Battaglia deciob

  • Featurespace
  • Cambridge, UK
View GitHub Profile
class boxChart
# conventions:
# throughout the code c stands for configuration
# the svg left-right margins are calculated doubbling the box margin value
# typical svg structure:
#
# <div id="box_chart_vis">
# <svg class="parent" width="140" height="500">
@deciob
deciob / spinejs_setup.sh
Created April 29, 2012 10:50
Setting up spinejs in Linux Mint 12 (and possibly ubuntu)
# Setting up spinejs in Linux Mint 12
# Node Version Manager (see: https://github.com/creationix/nvm)
sudo apt-get install curl build-essential libssl-dev #dependencies
git clone git://github.com/creationix/nvm.git ~/src/nvm
. ~/src/nvm/nvm.sh #should add this to your ~/.bashrc
# Node.js
nvm install v0.6.15
nvm use v0.6.15
@deciob
deciob / relocate_tiles.py
Created April 3, 2012 08:37
Move map tiles from "OpenLayers" system to TMS system
import os
import shutil
class FilesystemDiver(object):
"""crawls the filesystem and extracts
filepath and filenames information"""
def __init__(self, path):
self.path = path
@deciob
deciob / scaler.coffee
Created April 3, 2012 08:33
Linear scaling script
class Scaler
scale: (range, domain) =>
@rmax = domain[1]
@rmin = domain[0]
return (val) =>
position_in = @getPositionInDomain(val)
position_out = @getPositionInRange(range, position_in)
Math.ceil(position_out)
@deciob
deciob / observer.coffee
Created March 12, 2012 09:35
Simple event-observer class inspired from the example on: http://api.jquery.com/jQuery.Callbacks/ (needs JQuery 1.7)
class Observer
actions: {}
init: (id) ->
action = id && @actions[ id ]
callbacks = $.Callbacks()
if not action
action =
notify: callbacks.fireWith,
@deciob
deciob / spinejs_on_mint.sh
Created November 5, 2011 12:29
Setting up spinejs on linux mint 11
sudo apt-get install g++ curl libssl-dev
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-v0.4.12.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
curl http://npmjs.org/install.sh | sh
@deciob
deciob / wb_jsonp.js
Created October 2, 2011 11:39
JQuery jsonp call
$.ajax({
url: "http://api.worldbank.org/countries/AUT/indicators/BAR.POP.6064?per_page=10&date=2000:2011&format=jsonP&prefix=Getdata",
dataType: 'jsonp',
jsonp: false,
jsonpCallback: "Getdata",
success: function(data){
/* do something awesome! */
}
});