Skip to content

Instantly share code, notes, and snippets.

@sferik
sferik / install-ruby-2.0.0.sh
Created November 5, 2012 02:28
Instructions to install on Ruby 2.0.0 on Mac OS X with homebrew
#!/usr/bin/env sh
brew update
brew install rbenv
brew install ruby-build
brew install openssl
CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install 2.0.0-preview1
@shawnbot
shawnbot / d3-compat.js
Created November 29, 2012 02:00
d3 "mouseenter" and "mouseleave" event support
(function() {
// get a reference to the d3.selection prototype,
// and keep a reference to the old d3.selection.on
var d3_selectionPrototype = d3.selection.prototype,
d3_on = d3_selectionPrototype.on;
// our shims are organized by event:
// "desired-event": ["shimmed-event", wrapperFunction]
var shims = {
@aficionado
aficionado / JSON PML schemas.md
Last active September 4, 2018 23:49
JSON PML schemas

JSON PML: schemas for models

  • model-schema.json A generic ML model, containing fields shared by most models despite of their concrete type. It uses:
    • sample-schema.json The schema for dataset sampling specifications
    • field-collection-schema.json Auxiliary schema describing a collection of field (or "properties") descriptors
    • generic-field-schema.json Properties shared by all fields, regardless of their type.
    • field-schema.json The union schema of all field descriptor types, with their specific properties.
  • tree-model-schema.json A specialization of the model schema to decision tree models. It uses:
  • node-schema The schema for the nodes in a decision tree
@erochest
erochest / start-rserve.sh
Created February 17, 2013 23:12
A simple shell script to start Rserve.
#!/bin/sh
R -e 'library(Rserve)' -e 'Rserve(args="--vanilla")'
@mbostock
mbostock / .block
Last active August 30, 2025 17:55
Gray Earth
license: gpl-3.0
@wch
wch / examples.r
Created March 6, 2013 20:31
Examples for O'Reilly Webinar on Data Visualization with R and ggplot2
Getting started
===============
# Make sure you have ggplot2 installed
install.packages("ggplot2")
library(ggplot2)
Basic examples
==============
@rufuspollock
rufuspollock / csv2sqlite.py
Last active April 14, 2016 14:22
UPDATED VERSION NOW AT https://github.com/rgrp/csv2sqlite [Script to load CSV to SQLite]
#!/usr/bin/env python
# A simple Python script to convert csv files to sqlite (with type guessing)
#
# @author: Rufus Pollock
# Placed in the Public Domain
import csv
import sqlite3
def convert(filepath_or_fileobj, dbpath, table='data'):
if isinstance(filepath_or_fileobj, basestring):
Step One
Fetch URL based on column:
'http://www.datasciencetoolkit.org/maps/api/geocode/json?sensor=false&address=' + escape(value, 'url')'
Step Two
Parse Json for longitude:
value.parseJson()["results"][0]["geometry"]["location"]["lng"]
@aaronpk
aaronpk / Makefile
Last active December 20, 2015 10:39
me:
ifeq ($(USER), root)
@echo "\c"
else
@echo "make \c"
endif
a:
ifeq ($(USER), root)
@echo "\c"
@caged
caged / d3-server.js
Last active October 17, 2023 04:05
Directly render and serve d3 visualizations from a nodejs server.
// Start `node d3-server.js`
// Then visit http://localhost:1337/
//
var d3 = require('d3'),
http = require('http')
http.createServer(function (req, res) {
// Chrome automatically sends a requests for favicons
// Looks like https://code.google.com/p/chromium/issues/detail?id=39402 isn't
// fixed or this is a regression.