Skip to content

Instantly share code, notes, and snippets.

View chrismanderson's full-sized avatar

Chris Anderson chrismanderson

View GitHub Profile
int GetInt(void)
{
// try to get an int from user
while (true)
{
// get line of text, returning INT_MAX on failure
string line = GetString();
if (line == NULL)
{
return INT_MAX;
@chrismanderson
chrismanderson / foo.jsonp
Last active August 29, 2015 14:09 — forked from tmcw/foo.jsonp
d3.jsonp.foo('Hello, World!');

Input JSON:

{
   "fleet":{
      "MVVSYUagG6":{
         "shift-end":"9:00",
         "shift-start":"0:00",
         "start-location":"depot"
      },

"LC0Ux5hmUR":{

/Applications/Xcode.app/Contents/MacOS/Xcode </dev/null &>/dev/null &
@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>