- 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- <li class="rate"> | |
#set($ratingAggs = $cms.getRatingAggregates(["$content.id"]))## | |
#set($ratingAggObj = $ratingAggs.get($content.id))## | |
#set($averageRating = $ratingAggObj.average)## | |
$cms.template("Rating module") | |
</li> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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">'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hamming_distance(a, b) | |
dist = 0 | |
val = a ^ b | |
while !val.zero? | |
dist += 1 | |
val &= val - 1 | |
end | |
dist | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -- [email protected]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fixnum | |
def d(sides) | |
sum = 0 | |
self.times { sum += rand(sides)+1 } | |
sum | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
OlderNewer