Skip to content

Instantly share code, notes, and snippets.

View chrismanderson's full-sized avatar

Chris Anderson chrismanderson

View GitHub Profile
@chrismanderson
chrismanderson / bools
Created April 4, 2012 18:34
boolean tests
# in model
validates :admin, :inclusion => { :in => [true, false] }
# the test
it "rejects invalid admin state" do
non_admin_user = User.new(@attr.merge(:admin => "is administrator"))
non_admin_user.should_not be_valid
end
//
// MasterViewController.m
// ShoeEngine
//
// Created by Chris Anderson on 4/19/12.
// Copyright (c) 2012 The Winston Group. All rights reserved.
//
#import "MasterViewController.h"
@chrismanderson
chrismanderson / gist:2838249
Created May 30, 2012 18:48
clarified gist

To set the root user password. From terminal.

 /usr/local/Cellar/mysql/5.5.20/bin/mysqladmin -u root password 'enter_a_password'

Then do

 mysql --user=root --password=enter_a_password

In the mysql command prompt:

<!DOCTYPE html>
<html>
<head>
<title>ThinAuth</title>
<link href="/assets/application-7270767b2a9e9fff880aa5de378ca791.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application-990a4cf0df42934fcc4c14aaf88b7ced.js" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="1W3NM3IJuIgxScltwWBmilWuuCQhcKMFV3jULKoPUNA=" name="csrf-token" />
</head>
@chrismanderson
chrismanderson / gist:3090735
Created July 11, 2012 14:31
Titleize.coffee
String::titleize = ->
titleized = this.split(" ")
UNCAPITALIZED = ['a', 'an']
titleized = (
for word, index in titleized
if word in UNCAPITALIZED && index != 0
word
else
word[0].toUpperCase() + word.slice(1) if word
__ ___ ___ __
,-' '-.-' '-. .-' '-.-' '-,
_______,-' '-.____ '-. .-' ____.-' '-,_______
| '-. \/ .-' |
/ `-._ |_____||_____| _.-' \
/ | \ /| | | |\ / | \
/ _|__'|_|____| |____|_|'__|_ \
/| | | | | |\
|___________| |___________|
______ | | | | ______
describe "Application 'Tests'" do
before do
@app = UIApplication.sharedApplication
end
it "has one window" do
@app.windows.size.should == 1
end
describe "button controller" do
I'm using RestKit 0.10.2.
I have the following JSON data:
{
"title":"2012 General Election: Romney vs. Obama",
"last_updated":"2012-01-02T17:08:44Z",
"estimates":[
{ "choice":"Romney", "value":44.5 },
{ "choice":"Obama", "value":46.6 }
],
@chrismanderson
chrismanderson / test0_output
Created January 15, 2013 15:14
CSCI 3907 Test0 Output
uby-1.9.3 ~/Downloads/ws (master *%)
→ make test0
./server 8084 0 &
httperf --port=8084 --server=localhost --num-conns=1
binding receive socket: Address already in use
httperf --client=0/1 --server=localhost --port=8084 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 0
Total: connections 1 requests 0 replies 0 test-duration 0.000 s