Skip to content

Instantly share code, notes, and snippets.

@mconnell
mconnell / .profile
Created January 29, 2011 23:48
My Sublime Text 2 settings.
alias sublime='open -a "Sublime Text 2"'
@mconnell
mconnell / gist:786172
Created January 19, 2011 13:34
Restart Apache on Mac OS X
sudo /usr/sbin/apachectl restart
# found this the other day while looking for something entirely different..
# http://webcache.googleusercontent.com/search?q=cache:s4vKoo5lpwoJ:blog.viamentis.com/articles/category/ruby/page/2/+chat+AI+ruby&cd=10&hl=en&ct=clnk&client=safari
require 'net/http'
def eliza(str)
response = Net::HTTP.post_form(URI.parse("http://www-ai.ijs.si/eliza-cgi-bin/eliza_script"),{'Entry1'=>str})
return response.body.split("</strong>\n").last.split("\n").first
end
@mconnell
mconnell / gist:748299
Created December 20, 2010 11:53
List installed packages on ubuntu
dpkg --get-selections > installed-software
/* Ismael Celis 2010
Simplified WebSocket events dispatcher (no channels, no users)
var socket = new FancyWebSocket();
// bind to server events
socket.bind('some_event', function(data){
alert(data.name + ' says: ' + data.message)
});
Word / Phrase acroym iphone autocomplete
Working from home wfh egg
# divide an array with one pint too many
class Array
def /(divider)
divider = divider.to_i
collection_size = size / divider
array = []
each_with_index do |element, index|
index % collection_size == 0 && divider != array.size ? array << [element] : array.last.push(element)
end
array.size == 1 ? array.flatten! : array
<link rel="apple-touch-icon" media="screen and (resolution: 163dpi)" href="57px.png" />
<link rel="apple-touch-icon" media="screen and (resolution: 132dpi)" href="72px.png" />
<link rel="apple-touch-icon" media="screen and (resolution: 326dpi)" href="114px.png" />
# Create a fresh git repo
git :init
git :add => "."
git :commit => "-m 'Initial commit.'"
# Create the javascripts dir
run 'mkdir public/javascripts'
# Create the javascripts dir
run 'mkdir public/javascripts'
# pull down jquery, jquery-ui and the appropriate rails driver
run 'curl -L http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js > public/javascripts/jquery.js'
run 'curl -L http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js > public/javascripts/jquery-ui.js'
run 'curl -L http://github.com/rails/jquery-ujs/raw/master/src/rails.js > public/javascripts/rails.js'