Skip to content

Instantly share code, notes, and snippets.

View whistler's full-sized avatar

Ibrahim Muhammad whistler

View GitHub Profile
@whistler
whistler / import.sh
Created March 16, 2015 17:31
Copy files to another repository while saving git history
# 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
@whistler
whistler / canvas_image.js
Created October 17, 2014 16:33
Add Image to Canvas
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;
@whistler
whistler / console.js
Last active August 29, 2015 13:57
Access Angular service from console
service = angular.element('*[ng-app]').injector().get('serviceName')
@whistler
whistler / client.coffee
Last active December 20, 2015 02:49
How to use socket.io-client to keep retrying for server or connect to a different server
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')
@whistler
whistler / ubuntu_nodejs.sh
Created June 30, 2013 09:59
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.
# 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
@whistler
whistler / gist:4699578
Created February 2, 2013 22:39
Install Rails on Mac
# Pre-requisite: X-Code Command Line Tools: http://connect.apple.com
# install homebrew
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
# git
brew install git
#rbenv
@whistler
whistler / unicode.rb
Created September 17, 2012 01:22
Unicode is Ruby file
# encoding: UTF-8
# Add the about comment in the ruby file
@whistler
whistler / no_overflow.css
Created August 17, 2012 20:09
Make sure child div stays inside parent div
.parent
{
position: relative;
}
@whistler
whistler / jenkins_rails_ubuntu.sh
Created July 26, 2012 02:33
Set up Jenkins and Rails on Ubuntu server
sudo aptitude install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install libmysqlclient-dev ruby-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install libreadline-dev
### Install Java ###
sudo apt-get install openjdk-6-jre-headless
@whistler
whistler / no_timestamps_in_json.rb
Created June 11, 2012 15:10
Dont send timestamps of Rails records to browser
class ActiveRecord::Base
def as_json(options={})
super(:except => [:created_at, :updated_at])
end
end