Skip to content

Instantly share code, notes, and snippets.

@defunkt
defunkt / test-spec-mini.rb
Created November 16, 2008 10:34
test/spec/mini 3
##
# test/spec/mini 3
# http://gist.github.com/25455
# chris@ozmm.org
# file:lib/test/spec/mini.rb
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@shayne
shayne / gvoice.rb
Created December 15, 2009 06:21
A quick interface to the Google Voice using an undocumented API
require 'rest_client'
class GVoice < Struct.new :e, :p
def initialize(*args, &block)
super; instance_eval &block if block_given?
end
def send_sms(number, text)
post 'sms/send', :phoneNumber => number, :text => text, :_rnr_se => get[/'_rnr_se': '([^']+)'/, 1]
end

iOS Fonts

This is a list on all of the available fonts on iPhone. The following list was produced with the following code running on iOS 4.2:

for (NSString *family in [UIFont familyNames]) {
	for (NSString *font in [UIFont fontNamesForFamilyName:family]) {
		NSLog(@"%@ - %@", family, font);
	}
}
//
// GradientTableViewCell.m
//
// Created by Mark Sands on 5/4/10.
// Copyright 2010 Apple Inc. All rights reserved.
//
//
#import "GradientTableViewCell.h"
@nruth
nruth / cookie_steps.rb
Created July 21, 2010 17:16
Testing login "remember me" feature with Capybara (rack::test or selenium) - deleting the session cookie (only)
.bar
.fill{:style => "width: #{(percent_full*100).round}%"}
SIGN UP
curl -H "Content-Type:application/json" -H "Accept:application/json" \
-d "{\"user\":{\"password_confirmation\":\"12345678\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \
http://your_server.com/users
SIGN IN
curl -H "Content-Type:application/json" -H "Accept:application/json" \
-d "{\"user\":{\"remember_me\":\"0\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \
http://your_server.com/users/sign_in
#!/custom/ree/bin/ruby
# USAGE:
#
# echo "|/path/to/core_helper.rb %p %s %u %g" > /proc/sys/kernel/core_pattern
#
require 'etc'
require 'net/smtp'
// ************** oggsteamer.h
#define NUM_BUFFERS 4
#define BUFFER_SIZE 65536
#define BUFFER_MSECS 10
typedef struct {
char *data;
int data_length;
int seek_offset;