Skip to content

Instantly share code, notes, and snippets.

@rociiu
rociiu / gist:1089756
Created July 18, 2011 14:55 — forked from croaky/gist:1089598
Transfer data from production to staging on Heroku
heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote production
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@rociiu
rociiu / gist:1015706
Created June 8, 2011 23:20 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@rociiu
rociiu / gist:1001905
Created June 1, 2011 06:56 — forked from stammy/gist:961862
rails 3 error_messages_for deprecation replacement
<% if @user.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this record from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
@rociiu
rociiu / mapreduce.js
Created May 17, 2011 07:26 — forked from adomado/mapreduce.js
Simple MapReduce with Javascript
var Job = {
data : [
"We are glad to see you here. This site is dedicated to",
"poetry and to the people who make poetry possible",
"poets and their readers. FamousPoetsAndPoems.com is",
"a free poetry site. On our site you can find a large",
"collection of poems and quotes from over 631 poets",
"Read and Enjoy Poetry",
"I, too, sing America",
@rociiu
rociiu / james_very_simple_example.rb
Created May 15, 2011 01:39 — forked from floere/james_very_simple_example.rb
Simple example dialogue for James.
require 'rubygems'
require 'james'
# This is a very simple James example for MacRuby.
#
# James is a voice controlled butler:
# http://github.com/floere/james
#
# Run using:
# 1. gem install james
@rociiu
rociiu / nodeconf_2011.md
Created May 7, 2011 00:48 — forked from guybrush/nodeconf_2011.md
a list of slides from nodeconf 2011
@rociiu
rociiu / FTAccessibleActionSheet.m
Created May 4, 2011 01:32 — forked from alloy/FTAccessibleActionSheet.m
A UIActionSheet subclass that customizes the accessibility labels of the options in the sheet.
// Copyright (c) 2011 Eloy Durán <[email protected]>
// Available under the MIT license: http://www.opensource.org/licenses/mit-license.php
#import <objc/message.h>
@interface FTAccessibleActionSheet : UIActionSheet
- (void)copyAccessibilityMetadataFrom:(NSString *)title toControl:(UIView *)control;
@end
@implementation FTAccessibleActionSheet
function set_window_and_tab_title
{
local title="$1"
if [[ -z "$title" ]]; then
title="root"
fi
local tmpdir=~/Library/Caches/${FUNCNAME}_temp
local cmdfile="$tmpdir/$title"