Skip to content

Instantly share code, notes, and snippets.

View tejo's full-sized avatar

Matteo Parmi tejo

View GitHub Profile
@tejo
tejo / gist:58932
Created February 5, 2009 19:16 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@tejo
tejo / gist:58933
Created February 5, 2009 19:16 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
$.getJSON("http://github.com/api/v1/json/tejo?callback=?", function(data){
$('#loader').remove();
$.each(data.user.repositories, function(i,repo){
$('#ghbadge').append('<li><a title="'+repo.description+'" href="'+repo.url+'" target="blank">'+repo.name+'</a></li>');
});
//$('#ghbadge > li').slideDown();
});
$.getJSON("http://github.com/api/v1/json/tejo?callback=?", function(data){
$('#loader').remove();
$.each(data.user.repositories, function(i,repo){
$('#ghbadge').append('<li><a title="'+repo.description+'" href="'+repo.url+'" target="blank">'+repo.name+'</a></li>');
});
});
$.getJSON("http://github.com/api/v1/json/tejo?callback=?", function(data){
$('#loader').remove();
$.each(data.user.repositories, function(i,repo){
$('#ghbadge').append('<li><a title="'+repo.description+'" href="'+repo.url+'" target="blank">'+repo.name+'</a></li>');
});
});
sudo bash -c "ARCHFLAGS='-arch i386' gem install mysql -- \
--with-mysql-config=/usr/local/mysql/bin/mysql_config"
//http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.31-osx10.5-x86.dmg/from/pick
#!/bin/bash
# Unattended REE/Passenger installation with nginx
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
VERSION="1.2"
# Quick wrapper for undocumented and unsupported MyMileMarker.com API
require 'rubygems'
gem 'httparty', '>= 0.3.1'
require 'httparty'
module MyMileMarker
class Client
include HTTParty
# Monkey-patch for Passenger to use the EventMachine reactor.
# This allows the use of EM timers, EM.system/popen, and other async libraries (amqp, em-http-request, etc) inside a Rails process.
# This requires EM.watch which was added to EM's git repo recently. Build an EM gem first:
# git clone git://github.com/eventmachine/eventmachine
# cd eventmachine
# gem build eventmachine.gemspec
# sudo gem install eventmachine-0.12.9.gem
# Please do not use this in production =)
begin
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } }
config.cache_store = :mem_cache_store, %w(localhost:11211), { :namespace => 'OI', :timeout => 60 }
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
config.cache_store = nil
$stderr.puts "memcached not running, caching to memory"
end