Skip to content

Instantly share code, notes, and snippets.

@farnoy
farnoy / gist:727343
Created December 3, 2010 18:39
tests
GitHub::Repo.get('mojombo/jekyll').fetch(:self, :watchers)
GitHub::Repo.get('schacon/kidgloves').fetch(:watchers).watchers.each
GitHub::Repo.get('parndt/hub').parent.fetch(:self, :watchers).watchers
GitHub::User.get('kneath').fetch(:followers, :followings)
GitHub::User.get('defunkt').fetch(:followers, :followings)
GitHub::User.get('schacon').fetch(:followers, :followings)
@farnoy
farnoy / class.hpp
Created December 9, 2010 11:48
Dynamic function calling with C++
class Class
{
public:
int a (int a, short b)
{
return a + b;
}
int (Class::*PointerToA())(int, short)
{
@farnoy
farnoy / treeview.rb
Created January 9, 2011 20:42
TreeView in console for Grit
#!/usr/bin/env ruby
# Takes two parameters, location of repo and branch name
# First defaults to directory where you're running from
# Second defaults to 'master'
# To override, use
# -p path/to/repo
# -b branch_name
if ARGV.include? '--path' or ARGV.include? '-p'
@farnoy
farnoy / gist:1102736
Created July 24, 2011 15:41
Shared resources in C++0x
#include <iostream>
#include <string>
#include <memory>
struct Printer {
virtual void Print() = 0;
};
struct StandardCoutPrinter : Printer {
std::weak_ptr<std::string> content;
goog.require('goog.testing.jsunit');
goog.require('example');
goog.require('goog.dom');
goog.require('goog.dom.NodeType');
var testHtmlEscaping = function() {
example.sayHello('<b>greeting</b>');
var greetingEl = goog.dom.getElement('greeting');
assertEquals('The <h1 id="greeting"> element should only have one child node',
cat sat_words | \
sed -e 's:^\(\w*\) .*:"\1":' \
-e 's:^\(\w*-\w*\) .*:"\1":' \
-e 's:^\(\w*-\w*-\w*\) .*:"\1":' \
-e 's:^\(\w*-\w*-\w*-\w*\) .*:"\1":' \
| sed -e ':a;N;$!ba;s:\n:,:g' \
-e 's:^:-[:' \
-e 's:-[:]:'
# changes
@farnoy
farnoy / gist:1800782
Created February 11, 2012 15:25
Test output for SO question
[48 32 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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choServer(ws *websocket.Conn) {
@farnoy
farnoy / gist:1838021
Created February 15, 2012 18:32
gosab deps
kuba:gosab$ tree
.
|-- src
| `-- gosab
| |-- api
| | |-- sab_api.go
| | `-- sab_api_test.go
| |-- backend
| | |-- connector
| | | `-- connector.go
$:.unshift './'
require 'calculator'
describe Calculator do
describe :constructor do
it 'should take many arguments' do
args = [1, 2, 3, 4]
Calculator.new(*args).values.should eq(args)
end
end