Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / solar notes.md
Last active February 11, 2016 15:45
Notes about Solar (Massachusetts, circa 2014)

I wrote this in Feburary 2014, as a note to a friend, about solar. Though the market has changed, it might be useful to you.


My partner and I bought a house a couple years ago, and our roof is pretty ideal for solar. This fall, we spent awhile trying to understand the options, and we completed our installation in December. How programs work vary by state and year.

@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 -
@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"
#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 / 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):
@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 / 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 / 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 / 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:

rindge:graphs seph$ ./test-irr.rb
-0.8461538461538315
-0.5233728905609968
-0.3055754160809478
-0.16941929133206396
-0.08153134104840357
-0.02240080635339052
0.018877821951107262
-1.7310946662195288
0.07055058069605046