Skip to content

Instantly share code, notes, and snippets.

View mconnell's full-sized avatar

Mark Connell mconnell

View GitHub Profile
@mconnell
mconnell / gist:1122314
Created August 3, 2011 10:06
Installing PG on OSX 10.6
Install PG from binary + rubygem
PATH=$PATH:/Library/PostgreSQL/9.0/bin gem install pg
function Weather(locationName){
var locationURL = "http://www.google.com/ig/api?weather="+locationName;
var forcast = {};
$.get(locationURL, function(data){
var current = $(data).find('current_conditions');
['condition', 'temp_f', 'temp_c', 'humidity', 'wind_condition'].forEach(function(attribute){
forcast[attribute] = $(current).find(attribute).attr('data');
});
});
@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" />