Skip to content

Instantly share code, notes, and snippets.

View whistler's full-sized avatar

Ibrahim Muhammad whistler

View GitHub Profile
@whistler
whistler / google_analytics.py
Created August 16, 2016 21:26
Fetch Page View Data from Google Analytics
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
@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_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
@whistler
whistler / run_tests.sh
Created June 6, 2012 13:47
Pull Rails application and test repeatedly
#!/bin/bash
while [ true ]; do
git pull origin master
bundle install
rake db:migrate
rake rake:test:prepare
rake spec
done
@whistler
whistler / rubyplusplus 12-17-2011
Created May 1, 2012 14:51
Set up Ubuntu for Rails and Github
############ For Vitual Machines #######
sudo locale-gen en_CA.UTF-8
sudo apt-get install ruby git build-essential
############ Run Updates ############
sudo apt-get update
sudo apt-get -y upgrade
############ Reboot ############
@whistler
whistler / scrollToDiv.js
Created April 12, 2012 17:56
Scroll div into view
document.getElementById('youridhere').scrollIntoView();
@whistler
whistler / file_read_line_by_line.rb
Created February 28, 2012 22:46
Read file line by line in ruby
IO.foreach("filename.ext") { |line| p line}