Skip to content

Instantly share code, notes, and snippets.

View nirix's full-sized avatar
🚜
Terraforming cloud environments for large scale projects

Jack Polgar nirix

🚜
Terraforming cloud environments for large scale projects
View GitHub Profile
@nirix
nirix / outback.css
Created January 7, 2012 05:17
Espresso Themes
/*
@theme Outback
@override-placeholders html, xml, sourcecode.js
*/
:document-base {
color: #fff;
background-color: #2b2b2c;
insertion-point-color: #fff;
selection-background-color: #000;
@nirix
nirix / gist:1471370
Created December 13, 2011 09:24
time_ago
def time_ago(timestamp, from_timestamp = nil)
return if timestamp.nil?
from_timestamp = Time.now.to_i if from_timestamp.nil?
difference = from_timestamp - timestamp
periods = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade']
lengths = [60, 60, 24, 7, 4.35, 12, 10]
i = 0
@nirix
nirix / gist:1471326
Created December 13, 2011 09:10
Rails time_ago_in_words without localisation
def time_ago_in_words(from_time, include_seconds = false)
distance_of_time_in_words(from_time, Time.now, include_seconds)
end
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
distance_in_minutes = (((to_time - from_time).abs)/60).round
distance_in_seconds = ((to_time - from_time).abs).round
@nirix
nirix / partial.rb
Created December 11, 2011 07:45
Partials in Sinatra
#
# Sinatra Partials
# Copyright (C) 2011 Jack Polgar
#
# @copyright Jack Polgar 2011
# @license New BSD License
# @example:
# render_partial 'articles/article', :article => article
#
helpers do
@nirix
nirix / update.sh
Created September 7, 2011 13:00
Update VladGh-Nginx with Passenger
#!/bin/bash
#
###################################################################
# Script to update Nginx to the latest version. #
# June 3rd 2011 Vlad Ghinea. #
###################################################################
#
# Needs to be called with the version number as argument and also
# with "sudo env PATH=$PATH" in front to preserve the paths.
#
@nirix
nirix / routes.rb
Created July 21, 2011 17:44
Routing subdomains in Ramaze
Domains = {
/domain\.com/ => '/',
/forum\.domain\.com/ => '/forum/index'
}
Ramaze::Route['sub domains'] = lambda do |uri, action|
Domains.each do |regex, sub_uri|
if action['env']['HTTP_HOST'] =~ regex
return sub_uri
end