Skip to content

Instantly share code, notes, and snippets.

@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 <eloy@fngtps.com>
// 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
//Run this code in a simulator for the iPhone and it will crash DO NOT RUN ON DEVICE, gets fscked
- (void) setAlarmOfDoom:(NSDate *)newAlarm {
{
UIApplication* app = [UIApplication sharedApplication];
// Create a new notification.
for(int i = 0; i < 10 ; i++) {
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
if (alarm)
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"
(function(w, d) {
// Empty path to CSS file
// to determine later on.
var path;
// Create empty: <link rel="stylesheet" id="adaptive_css" />
var css = d.createElement('link');
css.rel = 'stylesheet';
css.id = 'adaptive_css';
table scores:
user_id | value | score_date
1 90 2010-03-04
1 80 2009-03-04
2 90 2009-04-05
2 70 2009-05-06
3 100 2010-04-06
Find most recent scores: