Skip to content

Instantly share code, notes, and snippets.


Nadeem Bitar shinzui

  • Los Angeles / San Francisco
  • Twitter @shinzui
View GitHub Profile
View gist:11202
name: "bitly",
takes: {"url to shorten": noun_arb_text},
preview: "Replaces the selected URL with a URL.",
description: "Replaces the selected URL with a URL.",
icon: "",
execute: function( urlToShorten ) {
var baseUrl = "";
var params = {url: urlToShorten.text};
jQuery.get(baseUrl, params, function(shortenedUrl) {
View github-code-search.js
// Based on Ubiquity Search:
name: "code",
takes: {"function": noun_arb_text},
icon: "",
homepage: "",
author: {name: "Tiago Bastos", email: ""},
license: "MPL,GPL",
description: "Search on Github Code Search",
View gist:37010
#!/usr/bin/env ruby
# fetch hosts from amazon EC2 meta-data
# Based on
%w(logger optparse rubygems right_aws resolv pp).each { |l| require l }
LOGGER ="/var/log/fetch_hosts.log")
View sinatra-apps.txt
Let's make a list of Sinatra-based apps!
- "Sinatra based"
- "minimalist blogging engine"
- "The easy and fun Continuous Integration server"
- "git-powered wiki"
- "Seinfeld-inspired productivity calendar to track your public github commits."
- "Marley, the blog engine without <textareas>."
- "Serve up your Markdown files with this tiny Sinatra app!"
View gist:45058
# 1) Point * in your DNS setup to your server.
# 2) Setup an Apache vhost to catch the star pointer:
# <VirtualHost *:80>
# ServerName *
# </VirtualHost>
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
View gist:51102
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
View download_youtube_video.rb
def parse_youtube(url)
youtube = ""
# url =~ /(?:http\:\/\/.*\/(?:watch\?v=|v\/))?(.*)$/
url =~ /watch\?v=(.*)/
video_id = $1
video_id = video_id.split("&")[0]
flv_url = nil
open("#{youtube}watch\?v=#{video_id}") do |f|
f.each_line do |line|
if line =~ /watch_fullscreen\?(.*?)video_id=([\w-]+)&(.*?)&t=([\w-]+)&/
View server_restarter
#!/usr/bin/env ruby
# usage: script/server_restarter
# Rails autoloading, while nice in theory, frequently doesn't work. Since Rails 2.3+
# is so fast when completely reloading the server, I wrote this script to listen to the
# given directories, and kill/restart the server when any file is changed.
# It's quick, simple, and it reliably reloads your application when changes are made.
View sinatra_metal.rb
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
View db_rollback_to_common.rake
# Usage:
# rake db:rollback_to_common branch=production
# git checkout -m production
# rake db:migrate
namespace :db do
desc 'Rolls back database to common migration state between current branch and another'
task :rollback_to_common do do