Skip to content

Instantly share code, notes, and snippets.

View shinzui's full-sized avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • X @shinzui
View GitHub Profile
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132
CmdUtils.CreateCommand(
{
name: "code",
takes: {"function": noun_arb_text},
icon: "http://github.com/fluidicon.png",
homepage: "http://tiago.zusee.com",
author: {name: "Tiago Bastos", email: "comechao@gmail.com"},
license: "MPL,GPL",
description: "Search on Github Code Search",
@shinzui
shinzui / gist:37010
Created December 17, 2008 09:54 — forked from jsierles/gist:31100
#!/usr/bin/env ruby
#
# fetch hosts from amazon EC2 meta-data
#
# Based on http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns
#
%w(logger optparse rubygems right_aws resolv pp).each { |l| require l }
LOGGER = Logger.new("/var/log/fetch_hosts.log")
Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
@shinzui
shinzui / gist:51102
Created January 23, 2009 17:29 — forked from peterc/gist:33337
# SUPER DARING APP TEMPLATE 1.0
# 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"
def parse_youtube(url)
youtube = "http://www.youtube.com/"
# url =~ /(?:http\:\/\/.*youtube.com\/(?: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-]+)&/
#!/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.
#
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end
#
# 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
FileUtils.cd(RAILS_ROOT) do
# rails application template for generating customized rails apps
#
# == requires ==
#
# * rails 2.3+, rspec, cucumber, culerity (langalex-culerity gem), machinist
#
# == a newly generated app using this template comes with ==
#
# * working user registration/login via authlogic, cucumber features to verify that it works
# * rspec/cucumber/culerity for testing