Skip to content

Instantly share code, notes, and snippets.

View unimatrixZxero's full-sized avatar
🌱
💎

Sam Figueroa unimatrixZxero

🌱
💎
View GitHub Profile
@unimatrixZxero
unimatrixZxero / gist:150346
Created July 20, 2009 13:49 — forked from cypher/gist:150248
script to verify that only syntactically valid ruby code is commited #git
#!/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")
#
@unimatrixZxero
unimatrixZxero / watermark_dir.rb
Created August 15, 2009 00:36
Script to watermark and resize images with imageMagick
#!/opt/local/bin/ruby
# _ __ _ _____
# __ ______ (_)___ ___ ____ _/ /______(_) _/__ / _ _____ _________
# / / / / __ \/ / __ \__ \/ __ \/ __/ ___/ / |/_/ / / | |/_/ _ \/ ___/ __ \
# / /_/ / / / / / / / / / / /_/ / /_/ / / /> < / /___> </ __/ / / /_/ /
# \__,_/_/ /_/_/_/ /_/ /_/\__,_/\__/_/ /_/_/|_| /____/_/|_|\___/_/ \____/
#
# Watermark folder script
# 2009-08-15 01:52 am
#
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@paulirish
paulirish / gist:576335
Created September 12, 2010 19:05
Things to do when IE9 Beta comes out

Things to do when IE9 Beta comes out

Note significant features added since IE9 PP4

  • Implemented but not announced: box-shadow, hsla
  • Expecting: 2d transforms, css animation, css transitions, flexible box model
  • Maybe: gradients, columns, reflections, svg filters, uncrippling @font-face, 3d transforms
  • Maybe version auto-update functionality

Test Modernizr against it

  • Does it still throw an error checking elem.msTransform?
@kaiwren
kaiwren / net_http_debug.rb
Created September 22, 2010 12:48
Enable debug for all Ruby HTTP requests
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)
# easy example
def multiplier n
lambda { |m| n*m }
end
# advanced examples
class Proc
def * other
lambda { |*args| self.call(*other.call(*args)) } # other is variable form enclosing scope
end
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
require "rubygems"
require "wirble"
require "pp"
require 'irb/completion'
require 'hirb'; extend Hirb::Console
Wirble.init
Wirble.colorize
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
#old style
a={}
a[:test] = {}
a[:test][:second_test] = 'Hello hash!'
# new style
# emulates working with directories
b = {}
b/:test = {}
b/:test/:second_test = 'Hello hash!'
@unimatrixZxero
unimatrixZxero / deploy.rb
Created May 31, 2011 13:45
Play a song when you deploy with capistrano
namespace :deploy do
before 'deploy' do
# run deploy song if available and mpg321 is installed
system('[ -e deploy.mp3 ] && type mpg321 &>/dev/null && mpg321 deploy.mp3 &')
end unless ENV['MUSIC_OFF']
end