This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script installs nodejs, coffeescript and git on an Ubuntu machine. | |
# Configures git to use with Github and clones a repository with a node | |
# project and installs its dependencies. | |
# 30 Jun 2013 | |
# Ibrahim Muhammad | |
# http://ibrahimmuhammad.com | |
# install node prereqs | |
sudo apt-get install python-software-properties python g++ make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = require 'socket.io-client' | |
socket = null | |
host = "http://localhost:12345" | |
connect_client = () -> | |
console.log('connecting') | |
socket = client.connect(host, {'force new connection': true}) | |
socket.on('connect', ()-> | |
console.log('connected') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service = angular.element('*[ng-app]').injector().get('serviceName') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function () | |
{ | |
var canvas = document.getElementById("overlay_canvas"); | |
var ctx = canvas.getContext("2d"); | |
var image = new Image(); | |
image.src = "http://placekitten.com/4536/3024"; | |
image.onload = function () { | |
ctx.drawImage(image, 0, 0); | |
image_ctx = image.getContext("2d"); | |
debugger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copied from http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/ | |
git clone <git repository A url> # clone source repository | |
cd <git repository A directory> | |
git remote rm origin # to make sure it doesn't affect the original repository | |
git filter-branch --subdirectory-filter <directory 1> -- --all # remove all files other than the ones needed | |
mkdir <directory 1> # move them into another directory where they will be stored in the destination repository (if needed) | |
mv * <directory 1> | |
git add . | |
git commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
for i in range(10): | |
print '\r', # print is Ok, and comma is needed. | |
time.sleep(0.3) | |
print i, | |
sys.stdout.flush() # flush is needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from csv import DictWriter | |
from glob import glob | |
from ofxparse import OfxParser | |
DATE_FORMAT = "%m/%d/%Y" | |
def write_csv(statement, out_file): | |
print "Writing: " + out_file | |
fields = ['date', 'payee', 'debit', 'credit', 'balance'] | |
with open(out_file, 'w') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AnimalView = Backbone.View.extend({ | |
.. | |
save: function() { | |
var that = this; | |
if(!this.isSaved) { | |
that.model.save() | |
} else { | |
that.alreadySaved(); | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import httplib2 | |
import flask | |
from oauth2client import client | |
from apiclient.discovery import build | |
http_auth = None | |
view_id = '00000000' # Add view id here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetch(url, callback) { | |
console.log('Getting ' + url); | |
var delay = (Math.round(Math.random() * 1E4) % 4000) + 1000 | |
var response = 'Content for ' + url; | |
setTimeout(function() { | |
callback(response) | |
}, delay); | |
} | |
function promiseFetch(url) { |