Skip to content

Instantly share code, notes, and snippets.

@christiangenco
christiangenco / videos.js
Created March 28, 2012 11:24 — forked from csabapalfi/videos.js
Download and Organize Coursera videos
$("h3.list_header").each(function(sectionIndex){
var sectionName = $(this).text().replace(/Chapter .+ - /,"").replace(/\:/,'-').replace(/^(V|I|X)+\. /,'');
$(this).parent().next().find("a.lecture-link").each(function(videoIndex){
var $lectureLink = $(this);
var videoName = $.trim($lectureLink.text());
var downloadLink = $lectureLink.attr('href').replace('view','download.mp4');
var cookieHeader = ' --header \"Cookie:'+ document.cookie + '\" ';
var directory = (sectionIndex+1) + '. ' + sectionName + '/';
var filename = directory + (videoIndex+1) + '. ' + videoName + '.mp4';
@christiangenco
christiangenco / gist:2240229
Created March 29, 2012 17:20
GoogleCL Calendar add shortcut: `gcal Party Today`
function gcal {google calendar add "`echo $@`"}
@christiangenco
christiangenco / csv_to_json.rb
Created May 24, 2012 17:41
Translate .csv files to .json objects using the first line of the csv file as a list of keys
# csv_to_json.rb
# a simple utility to translate csv files to json objects
# using the first line of the csv file as a list of keys
# The keys in the first line of the csv file are downcased and
# underscored (ex: "First Name" => "first_name")
# Example usage:
# csv_to_json.rb my_csv_file.csv
# => outputs JSON interpretation of my_csv_file.csv to STDOUT
// gist_id: 5dd142a99f1c82cbfc94
// hook_url: https://hook.io/christiangenco/twilio
// url: http://sms.gen.co/?body="hi"
module['exports'] = function(hook) {
var client = require('twilio')(hook.env['TWILIO_SID'], hook.env['TWILIO_AUTH']);
client.sendMessage({
// to: hook.params.to || '+18177977334',
to: '+18177977334',
from: '+18176685965',
# ruby herokuspeed.rb > herokuspeed.html && open herokuspeed.html
require 'pry'
require 'descriptive_statistics'
require 'erb'
# require 'open3'
def time_exec(cmd)
start = Time.now
`#{cmd}`
@christiangenco
christiangenco / weight.rb
Created May 1, 2013 22:54
A simple script to log my weight in a csv stored in dropbox.
#!/usr/bin/env ruby
require 'time'
filename = '/Users/cgenco/Dropbox/log/weight.csv'
File.open(filename, "a") {} # create the file if it doesn't exist
weight = ARGV.first
unless weight
puts "From: " + filename
@christiangenco
christiangenco / serial_vibrating_belt.ino
Created August 23, 2013 20:20
Arduino and ruby code for The Vibrating Belt. More information can be found at: http://christian.gen.co/2013/04/08/the-vibrating-belt.html
#simplest ruby program to read from arduino serial,
#using the SerialPort gem
#(http://rubygems.org/gems/serialport)
# from http://playground.arduino.cc/interfacing/ruby
require 'serialport'
require 'pry'
# https://github.com/igrigorik/em-websocket
# require 'em-websocket'
require 'pry'
class Integer
def factors() (1...self).select { |n| (self % n).zero? } end
end
class Array
def score(n)
total = n
minus = n.factors.inject(0) {|sum, f|
server {
listen 80;
server_name www.dbinbox.com;
rewrite ^/(.*) http://dbinbox.com/$1 permanent;
}
@christiangenco
christiangenco / coffify
Last active December 28, 2015 11:39
Convert .js files to .coffee files in batch.
#!/usr/bin/env ruby
# Usage:
# $ coffify app/*/*
# Depends on http://js2coffee.org/
# npm install js2coffee
ARGV.each{|filepath|
# skip this file if it's not a .js file