Skip to content

Instantly share code, notes, and snippets.

View m3talsmith's full-sized avatar

Michael Christenson II m3talsmith

View GitHub Profile
@m3talsmith
m3talsmith / scope-binding-closure.js
Last active August 29, 2015 14:06
Showing the principle of javascript scope binding
var bob = (function (name) {
var char = {
name: name,
say: function (message) { this.logger(this.name + " says: " + message); },
logger: function (message) { console.log(message); }
};
return char;
})("Bob");
var CommentController = {
current_users: [],
create: function(req, res) {
this.current_users.push('yada');
}
}
module.exports = CommentController;
@m3talsmith
m3talsmith / install-docker.txt
Created March 25, 2014 02:30
How to install docker on 13.10
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get --yes install linux-image-extra-`uname -r`
sudo apt-get --yes install lxc-docker wget python-software-properties python g++ make cgroup-lite software-properties-common
sudo wget -O /etc/init/docker.conf https://raw.github.com/dotcloud/docker/master/contrib/init/upstart/docker.conf
sudo service docker restart
@m3talsmith
m3talsmith / callback.c
Last active January 2, 2016 08:39
Testing callbacks in c
#include <stdio.h>
void say(char *string[]) {
printf("%s\n", *string);
}
int add(int a, int b, void (*callback)(char *string[])) {
int sum = a + b;
char* mesg;
asprintf(&mesg, "%d + %d = %d", a, b, sum);
@m3talsmith
m3talsmith / cbhellorest_greetings_controller.erl
Last active December 23, 2015 19:19
Trying to get restful responses from chicago boss
-module(cbhellorest_greetings_controller, [Req]).
-compile(export_all).
hello('GET', []) ->
{json, [{message, "hey"}]};
hello('POST', []) ->
NewGreeting = greeting:new(id, Req:post_params("message")),
{ok, SavedGreeting} = NewGreeting.save(),
{json, [{message, SavedGreeting:attributes}]}.
@m3talsmith
m3talsmith / gapitoken-test.js
Last active December 19, 2015 07:19
gapitoken: token undefined issue
var util = require('util');
var GAPI = require('gapitoken');
var gapi = new GAPI({
iss: '1074036960964-p8827i23hcprb8dr959uh2a6irk1jgfe@developer.gserviceaccount.com',
scope: 'https://storage.googleapis.com',
keyFile: './config/google-key.pem'
}, function(error){
console.log(error);
console.log(gapi);
@m3talsmith
m3talsmith / assets_spec.rb
Created June 24, 2013 16:48
An example of an attachment upload paperclip test.
require 'spec_helper'
describe Manage::Collections::AssetsController do
use_vcr_cassette
let!(:collection) {FactoryGirl.create :collection}
let!(:employee) {FactoryGirl.create :employee}
it 'creates an asset' do
collection.header.should_not be
@m3talsmith
m3talsmith / single-line-replacement.rb
Created June 18, 2013 20:55
A simple single line replacement example
puts 'Counting up to 100'
100.times do |i|
print "\rcurrent number: #{i + 1}"
sleep 0.1
end
puts ''
puts 'Done'
@m3talsmith
m3talsmith / challenge.rb
Created May 17, 2013 15:02
Beer Friday Challenges #1: Beer level 1 (you drink one beer before solving this) The dynamic conditional. Solve in any language, but you must solve with code - no mental substitutions. Drink, fork, and solve, people!
((15, 'less_than', 30) == true)
@m3talsmith
m3talsmith / calendar_item.rb
Created May 7, 2013 05:20
fancy calendar fun
class CalendarItem < Section
include Mongoid::Document
field :url
def calendar
Icalendar.parse(open(self.url).read).first
end
end