Skip to content

Instantly share code, notes, and snippets.

Avatar

Ibrahim Muhammad whistler

View GitHub Profile
@whistler
whistler / canvas_image.js
Created Oct 17, 2014
Add Image to Canvas
View canvas_image.js
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 Aug 29, 2015
Access Angular service from console
View console.js
service = angular.element('*[ng-app]').injector().get('serviceName')
@whistler
whistler / client.coffee
Last active Dec 20, 2015
How to use socket.io-client to keep retrying for server or connect to a different server
View client.coffee
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 Jun 30, 2013
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.
View ubuntu_nodejs.sh
# 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 Feb 2, 2013
Install Rails on Mac
View gist:4699578
# 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 Sep 17, 2012
Unicode is Ruby file
View unicode.rb
# encoding: UTF-8
# Add the about comment in the ruby file
@whistler
whistler / no_overflow.css
Created Aug 17, 2012
Make sure child div stays inside parent div
View no_overflow.css
.parent
{
position: relative;
}
@whistler
whistler / jenkins_rails_ubuntu.sh
Created Jul 26, 2012
Set up Jenkins and Rails on Ubuntu server
View jenkins_rails_ubuntu.sh
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 Jun 11, 2012
Dont send timestamps of Rails records to browser
View no_timestamps_in_json.rb
class ActiveRecord::Base
def as_json(options={})
super(:except => [:created_at, :updated_at])
end
end
@whistler
whistler / run_tests.sh
Created Jun 6, 2012
Pull Rails application and test repeatedly
View run_tests.sh
#!/bin/bash
while [ true ]; do
git pull origin master
bundle install
rake db:migrate
rake rake:test:prepare
rake spec
done
You can’t perform that action at this time.