Skip to content

Instantly share code, notes, and snippets.

View blake41's full-sized avatar

Blake Johnson blake41

  • http://blakejohnson.brandyourself.com/
View GitHub Profile
@blake41
blake41 / webserver.rb
Created October 3, 2012 20:19
ruby webserver that loses data
require 'socket'
require 'debugger'
load 'parser.rb'
puts 'starting up server'
server = TCPServer.new("0.0.0.0",8080)
puts "Parent process is #{Process.pid}"
$PROGRAM_NAME = "Parent Server"
loop do
@blake41
blake41 / list.c
Created October 23, 2012 18:17
header file
#include "list.h"
#include "dbg.h"
List *List_create()
{
return calloc(1, sizeof(List));
}
void List_destroy(List *list)
{
@blake41
blake41 / bstring.c
Created October 25, 2012 16:22
bstring sample
#include "bstrlib.h"
#include <stdio.h>
#include <stdint.h>
int main(int argc, char const *argv[])
{
char *string = "blake johnson";
bstring my_bstring = (bstring)string;
int length = blength(my_bstring);
char *new_string = bdata(my_bstring);
@blake41
blake41 / gist:5808171
Created June 18, 2013 18:54
Part II of playlister
The goal of the second part of this lab is to create a command line interface got for the playlister application. (The third part of the excercise will be evolving the CLI to be a web interface)
Write a ruby script that parses the data within the data directory
and uses the classes defined above to instantiate Song, Artist, and Genres
for each file. These instances should be correctly associated to each other
so that artist.genre will return a Genre object, etc.
The data directory is filled with a bunch of songs in this format
Artist Name - Song Name [genre_name].mp3
So for example A$AP Rocky - Peso [dance].mp3
<form action='/pirate' method="POST">
<input ... name="pirate[name]" />
<input ... name="pirate[weight]" />
<input ... name="pirate[height]" />
<input ... name="pirate[ships][0][name]" />
<input ... name="pirate[ships][0][type]" />
<input ... name="pirate[ships][0][booty]" />
</form>
## Build the Flatiron School
# Goal - To reinforce controllers, models, and forms and the interaction between them.
Per usual we're going to create restful routes for the following objects.
School, Course, Student, Teacher
Schools have courses
courses have students

Build the Flatiron School

Goal - To reinforce controllers, models, and forms and the interaction between them.

Per usual we're going to create restful routes for the following objects.

School, Course, Student, Teacher

Schools have courses courses have students

@blake41
blake41 / gist:6074307
Created July 24, 2013 20:37
plist file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
<key>Label</key>
<string>readinglisttoinstapaper</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
#!/bin/bash --login
# usage: _rvmruby <ruby version> [ruby arguments]
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
ruby_version=$1; shift
rvm $ruby_version
exec ruby "$@"
@blake41
blake41 / gist:6084609
Created July 25, 2013 23:06
homework
def add_one(new_result)
new_result + 1
end
def arithmetic(number,another_number)
result = number+another_number
add_one(result)
end
arithmetic(5,6)