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
# printf "\033[0m0 All attributes off\033[0m\n"
# printf "\033[1m1 Bold\033[0m\n"
# printf "\033[4m4 Underline\033[0m\n"
# printf "\033[5m5 Blink\033[0m\n"
# printf "\033[7m7 Invert\033[0m\n"
# printf "\033[8m8 Hide\033[0m8 = Hide\n"
# printf "\033[30m30 Black\033[0m30 = Black\n"
# printf "\033[31m31 Red\033[0m\n"
# printf "\033[32m32 Green\033[0m\n"
# printf "\033[33m33 Yellow\033[0m\n"
# printf "\033[0m0 All attributes off\033[0m\n"
# printf "\033[1m1 Bold\033[0m\n"
# printf "\033[4m4 Underline\033[0m\n"
# printf "\033[5m5 Blink\033[0m\n"
# printf "\033[7m7 Invert\033[0m\n"
# printf "\033[8m8 Hide\033[0m8 = Hide\n"
# printf "\033[30m30 Black\033[0m30 = Black\n"
# printf "\033[31m31 Red\033[0m\n"
# printf "\033[32m32 Green\033[0m\n"
# printf "\033[33m33 Yellow\033[0m\n"
# Cache Headers
# Middleware for configuring HTTP cache policy headers in Rack based web applications.
# Apply cache headers to HTTP responses corresponding to requests that match defined
# URI patterns.
#
# Example usage:
#
# use Rack::CacheHeaders
#
# Rack::CacheHeaders.configure do |cache|
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
@shinzui
shinzui / dewip.sh
Created August 12, 2009 21:43 — forked from timriley/dewip.sh
alias dewip="sed -E -i '' -e '/^[[:blank:]]*@wip$/d;s/,[[:blank:]]*@wip//g;s/@wip,[[:blank:]]*//g' features/**/*.feature"
class Object
def send_through(object, *args)
object.dispatcher_for(self).call(self, *args)
end
end
module Dispatcher
class DispatcherNotFound < StandardError; end
def self.extended(klass)
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
@shinzui
shinzui / gist:186248
Created September 13, 2009 17:25 — forked from mtodd/gist:180398
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
https?
EOH
Quotes also give you more freedom/creativity with the terminal ID:
@shinzui
shinzui / gist:189913
Created September 20, 2009 20:27
Dopplr City Color
require "digest/md5"
def dopplr_city_color(city)
Digest::MD5.hexdigest(city).slice(0..5)
end
@shinzui
shinzui / gist:214739
Created October 21, 2009 00:22
Rack route decoupling example using the rack sparklines middleware
# Example from Rick Olson's Sparklines middleware
# http://github.com/technoweenie/rack-sparklines/blob/master/lib/rack-sparklines.rb
module Rack
class Sparklines
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
if env['PATH_INFO'][@options[:prefix]] == @options[:prefix]