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 / 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
@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 / 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 / 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 / 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 / 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 / commands.md
Created January 7, 2012 13:44
Mac OS Stuff

Apache

  • Start: sudo httpd
  • Stop: sudo killall httpd
@nirix
nirix / ses.rb
Created January 24, 2012 22:41
Hack for sending Emails using Amazon SES without having to depend on Mail.
require 'httparty'
require 'hmac-sha2'
require 'base64'
require 'cgi'
module Amazon
module SES
OPTIONS = {
:access_key => '...',
:secret_key => '...'
@nirix
nirix / TODO.md
Last active March 2, 2023 16:56
Stuff to do after Arch Linux install
  1. Install Xfce
    1. Install gvfs (for trash)
    2. Add exec startxfce4 to ~/.xinitrc
    3. Set it up like our old friend, GNOME 2
    4. Install networkmanager and network-manager-applet
    5. Install the Bluebird theme
    6. Install the elementary icons
    7. Get the Arch logo and use it as the Applications menu icon
  2. Install Chromium
  3. Clone dotfiles repo and "install"
@nirix
nirix / bm.rb
Created April 25, 2012 22:53
ERB vs Erubis
require 'erb'
require 'erubis'
require 'benchmark'
@hey = "Herro prease"
@lols = [
'12', '34', '56', '78', '90',
'ab', 'cd', 'ef', 'gh', 'ij',
'kl', 'mn', 'op', 'qr', 'st',
'uv', 'wx', 'yz',