Skip to content

Instantly share code, notes, and snippets.

@codeslinger
codeslinger / counter.py
Created August 19, 2011 01:58 — forked from ericmoritz/counter.py
A counter stored in Riak that handles conflict resolutions on read
import logging
import riak
log = logging.getLogger(__name__)
class RiakCounter(object):
def __init__(self, bucket, key):
self.bucket = bucket
self.bucket.set_allow_multiples(True)
self.key = key
@codeslinger
codeslinger / Migration-Syntax.clj
Created November 8, 2011 17:42 — forked from RickMoynihan/Migration-Syntax.clj
Rails like Database Migrations in Clojure... Using clojure.contrib.sql
(def migrations (sorted-map
;; Migrations are numbered by integer values to explicitly document them
1 {
:doc "Foo Table"
:up (fn []
(create-table
:Foo
[:id :int "PRIMARY KEY" "NOT NULL GENERATED ALWAYS AS IDENTITY"]
; store a JSON blob in here for the screening record
@codeslinger
codeslinger / gist:1542668
Created December 31, 2011 03:11
too many headers
> curl -I "http://www.rogerebert.com/apps/pbcs.dll/article?AID=/20111228/COMMENTARY/111229973/"
HTTP/1.0 200 OK
Cache-Control: max-age=0, s-maxage=0
Content-Length: 74284
Content-Type: text/html; charset=iso-8859-1
Expires: Sat, 31 Dec 2011 02:21:46 GMT
Last-Modified: Sat, 31 Dec 2011 02:21:46 GMT
Server: Microsoft-IIS/7.0
Set-Cookie: PBCSPERMUSERID=873450176906098; path=/; expires=Sat, 29 Dec 2012 21:21:46 GMT
Set-Cookie: PBCSSESSIONID=873450176906098; path=/
@codeslinger
codeslinger / DisruptorTest.java
Created January 10, 2012 20:15 — forked from jbrisbin/DisruptorTest.java
Disruptor RingBuffer-based simplistic NIO HTTP test server
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 267 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: /data/github/current/lib/github/config/resque.rb:27: undefined method `constantize' for "GitHub::Jobs::GistStats":String (NoMethodError)
remote: from /data/github/current/lib/github/config/resque.rb:26:in `each'
remote: from /data/github/current/lib/github/config/resque.rb:26
remote: from /data/github/current/lib/rock_queue.rb:9:in `require'
remote: from /data/github/current/lib/rock_queue.rb:9
remote: from hooks/post-receive:27:in `require'
@codeslinger
codeslinger / gist:1917396
Created February 26, 2012 15:28 — forked from evandrix/gist:1901352
Stripe CTF Challenge - Solutions to all Levels
Stripe CTF - Work Notes
mpetrov ([email protected])
These notes are very rough. They should give a general idea of how each level was solved.
---- LEVEL 01 (login: e9gx26YEb2) -----
Solution: modifying PATH env variable
Password: kxlVXUvzv
date.c
@codeslinger
codeslinger / ctf_mpetrov.c
Created February 26, 2012 15:28 — forked from michaelpetrov/ctf_mpetrov.c
Stripe CTF Challenge Level 06 Solution
//
// Created by Michael Petrov on 12-02-23.
// Copyright (c) 2012 TenthBit Inc. All rights reserved.
// http://michaelpetrov.com ([email protected])
//
//
// This solution performs a timing attack on the fork system call. By monitoring the process closely
// it is possible to discover where the fork likely happened. With some basic heuristics, it's possible
// to infer where the wrong character is. With very minor brute force searching it becomes very easy
// to find the password one letter at a time.
@codeslinger
codeslinger / gist:2122256
Created March 19, 2012 18:11 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@codeslinger
codeslinger / Rationale.md
Created March 19, 2012 18:27 — forked from leegao/Rationale.md
JIT for dummies: JIT compiling RPN in python

If you don't care about the explanation, scroll down to find the code, it's 50 some odd lines and written by someone who doesn't know any better. You have been warned.

What it does

This is a very simple proof of concept jitting RPN calculator implemented in python. Basically, it takes the source code, tokenizes it via whitespace, and asks itself one simple question: am I looking at a number or not?

First, let's talk about the underlying program flow. Pretend that you are a shoe connoisseur with a tiny desk. You may only have two individual shoes on that desk at any one time, but should you ever purchase a new one or get harassed by an unruly shoe salesman without realizing that you have the power to say no (or even maybe?), you can always sweep aside one of the two shoes on the desk (the one on the right, because you're a lefty and you feel that the left side is always superior) onto the messy floor, put the other shoe on the right hand side, and then place your newly acquired shoe in

@codeslinger
codeslinger / hack.sh
Created March 31, 2012 13:25 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#