Skip to content

Instantly share code, notes, and snippets.

View adamhunter's full-sized avatar

Adam Hunter adamhunter

View GitHub Profile
sudo ./configure --disable-debug --enable-libfaad --enable-libfaac --enable-gpl --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libgsm --disable-debug --enable-shared --enable-nonfree --enable-libxvid --enable-libdc1394 --prefix=/usr
@adamhunter
adamhunter / gist:136009
Created June 25, 2009 17:43
velocity ratings
<!-- <li class="rate">
#set($ratingAggs = $cms.getRatingAggregates(["$content.id"]))##
#set($ratingAggObj = $ratingAggs.get($content.id))##
#set($averageRating = $ratingAggObj.average)##
$cms.template("Rating module")
</li> -->
(function($) {
// errors is an array of errors
// render :json => {:errors => @item.errors.full_messages}
function FormErrors(errors) {
var self = this,
error_count = errors.length;
this.html = function() {
var html = '';
html += '<div class="errorExplanation" id="errorExplanation">';
def hamming_distance(a, b)
dist = 0
val = a ^ b
while !val.zero?
dist += 1
val &= val - 1
end
dist
end
1) Add the function below into your .bash_profile, .bash_login, or other shell profile file.
2) Then you can hit nt (for new tab) anywhere
and a new tab will open up in same directory.
All credit for the idea and applescript goes to @jnunemaker - I just tidied it up.
If you can improve it further, let him know -- nunemaker@gmail.com.
class Fixnum
def d(sides)
sum = 0
self.times { sum += rand(sides)+1 }
sum
end
end

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

init = Rails::Initializer.run do |config|
#...
end
# look for all existing loaded plugin's public/ directories
plugin_assets = init.loaded_plugins.map { |plugin| File.join(plugin.directory, 'public') }.reject { |dir| not (File.directory?(dir) and File.exist?(dir)) }
init.configuration.middleware.use MyApp::Rack::StaticOverlay, :roots => plugin_assets
install mysql gem for snow leopard
first install the x84_64 version of mysql
then run:
sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install mysql -- -with-mysql-config=/usr/local/mysql/bin/mysql_config
# stick this in your rakefile and smoke it
# this will let you notify yourself after any rake task completes
# you need to install growlnotify from the growl package extras folder
# usage: rake run:task growl
def notify(msg, title = 'Rake Notify')
system "growlnotify -m \"#{msg}\" -t \"#{title}\""
end
desc "Growl after rake task"