Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / keybase.md
Created February 28, 2014 20:57
keybase.md

Keybase proof

I hereby claim:

  • I am directionless on github.
  • I am seph (https://keybase.io/seph) on keybase.
  • I have a public key whose fingerprint is 862F 624E 4D89 D0DD 5826 E89C 2590 35C7 4ACB 4497

To claim this, I am signing this object:

@directionless
directionless / output
Created July 30, 2014 06:59
Testing string conversion performance in python
Wed Jul 30 02:58:53 2014 /tmp/python.string.stats
2100004 function calls in 1.436 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
300000 0.500 0.000 0.529 0.000 random.py:173(randrange)
1 0.278 0.278 1.436 1.436 foo.py:24(main)
300000 0.154 0.000 0.683 0.000 random.py:237(randint)
@directionless
directionless / import test
Created August 14, 2014 02:09
Python WTF
#!/usr/bin/python
import random
import cProfile
import pstats
import math
from math import cos, sin, pi
def TESToverhead(a):
# This is just to check the call overhead
@directionless
directionless / octocat pagination
Created December 23, 2014 17:35
Octocat pagination
# WTF Octocat. This should be cleaner.
members = client.org_members(ORGNAME)
next_url = client.last_response.rels[:next]
while ! next_url.nil? do
page = next_url.href.gsub(/.*page=(\d+)/,'\1')
puts "Fetching page #{page}"
members.concat client.org_members(ORGNAME, :page => page)
next_url = client.last_response.rels[:next]
end
@directionless
directionless / ttc2ttf.py
Last active August 29, 2015 14:12 — forked from kayahr/ttc2ttf.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite "Beer"
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@directionless
directionless / gist:cc561241acfeee98020d
Created May 12, 2015 17:16
Python describing functions
class TestClass(object):
STRINGS={}
STRINGS["func1"] = lambda t: "func1 {0}".format(t)
def func1(self, t):
return "I did func1"
STRINGS["func2"] = lambda t: "func2 {0}".format(t)
def func2(self, t):
return "I did func2"
@directionless
directionless / firefox.txt
Created May 13, 2015 15:28
Simple python server
get
<__main__.RequestHandler instance at 0x104e677a0>
['MessageClass', '__doc__', '__init__', '__module__', 'address_string', 'client_address', 'close_connection', 'command', 'connection', 'date_time_string', 'default_request_version', 'disable_nagle_algorithm', 'do_GET', 'do_POST', 'end_headers', 'error_content_type', 'error_message_format', 'finish', 'handle', 'handle_one_request', 'headers', 'log_date_time_string', 'log_error', 'log_message', 'log_request', 'monthname', 'parse_request', 'path', 'protocol_version', 'raw_requestline', 'rbufsize', 'request', 'request_version', 'requestline', 'responses', 'rfile', 'send_error', 'send_header', 'send_response', 'server', 'server_version', 'setup', 'sys_version', 'timeout', 'version_string', 'wbufsize', 'weekdayname', 'wfile']
127.0.0.1 - - [13/May/2015 11:28:17] "GET / HTTP/1.1" 200 -
#!/usr/bin/ruby
# Note that this takes about 100 minutes to run.
require 'rubygems'
require 'aws/s3'
LOCAL_FILE=ARGV[0]
BUCKET=ARGV[1]
REMOTE_FILE=ARGV[2]
@directionless
directionless / webrat-test.rb
Created December 30, 2010 04:13
Testing webrat and = in form values
# for
# https://webrat.lighthouseapp.com/projects/10503/tickets/401-webrat-doesnt-handle-form-fields-with-an-equals-sign#ticket-401-1
require 'webrat'
require 'webrat/adapters/mechanize'
include Webrat::Methods
TESTURL = "http://www.directionless.org/webrat-test.pl"
Webrat.configure do |config|