Skip to content

Instantly share code, notes, and snippets.

View tomjakubowski's full-sized avatar

Tom Jakubowski tomjakubowski

View GitHub Profile
struct SomethingOpts {
inverse: bool
}
trait SomethingArg {
fn arg(&self) -> int;
fn opts(&self) -> SomethingOpts;
}
impl SomethingArg for int {
extern crate serialize;
use serialize::json;
use serialize::json::ToJson;
pub struct Connection;
pub struct Table;
pub struct Func;
pub trait Runnable: ToJson {
[14] pry(main)> FooBarBaz
NameError: uninitialized constant FooBarBaz
#![crate_type="lib"]
trait Times {
fn times(&self, f: |uint| -> ());
}
impl Times for uint {
fn times(&self, f: |uint| -> ()) {
for i in range(0, *self) {
f(i);
macro_rules! json_obj(
({ $($key:expr : $value:expr),* }) => ({
use serialize::json::ToJson;
let mut _temp = ::collections::treemap::TreeMap::new();
$(_temp.insert($key.to_owned(), $value.to_json());)*
::serialize::json::Object(~_temp)
});
)
fn foo() {
[
{
"name": "University of Screw You",
"tuition": 100000
},
{
"name": "Go To Hell College",
"tuition": 50
}
]
@tomjakubowski
tomjakubowski / Gemfile
Created March 15, 2014 02:47
minimal test case for Sidetiq utc issue
source 'https://rubygems.org/'
gem 'sidetiq', '0.5.0'
@tomjakubowski
tomjakubowski / nrepl-proxy.rb
Last active August 29, 2015 13:56
simple debugging proxy for nrepl
#!/usr/bin/env ruby
require 'bencode'
require 'edn'
require 'socket'
if ARGV.length < 3
puts "usage: #{$0} <source-port> <dest-host> <dest-port>"
exit
end
@tomjakubowski
tomjakubowski / dig.txt
Created February 23, 2014 05:12
starbucks hijacking DNS requests for .me. ?
; <<>> DiG 9.8.3-P1 <<>> @4.2.2.2 fb.me
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 34716
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;fb.me. IN A
$ node foo.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:276:12)
at Socket.Writable.end (_stream_writable.js:335:10)
at Socket.end (net.js:397:31)
at Socket.<anonymous> (/Users/tom/foo.js:9:16)