Skip to content

Instantly share code, notes, and snippets.

@derwolfe
derwolfe / make
Last active August 29, 2015 13:55
makefile with test, build, clean etc. Not excellent make, but works.
# you should put all of the tests to be run for each of the
# files as they are being built
CC=rustc
BUILDDIR=~/Code/matasano/rust/build
DOCDIR=~/Code/matasano/rust/docs
CCFLAGS=--out-dir $(BUILDDIR)
DC=rustdoc --output $(DOCDIR)
all: score single_cipher decrypt_single fixed_xor encode64
@derwolfe
derwolfe / new output with verbose
Last active August 29, 2015 13:57
gdb/rust symbols
(gdb) set verbose
(gdb) b main
Breakpoint 1 at 0x100000e70
(gdb) r foo.rs --out-dir ./bar/baz
Starting program: /Users/chris/Code/rust/x86_64-apple-darwin/stage1/bin/rustc foo.rs --out-dir ./bar/baz
warning: platform-specific solib_create_inferior_hook did not load initial shared libraries.
# this is on os x
@derwolfe
derwolfe / longrunning.py
Last active August 29, 2015 14:02
example of long running task with intermediate status result
# XXX many of the addBoths should be changed to involve error handling
"""
longrunning
This is an example of how one can develop a system using twisted.web
that can process long running results but still provide a short
request-response cycle.
This implements the following pattern:
1) request received by twisted application
from twisted.internet import reactor
from twisted.web import server, resource
from autobahn.wamp1.protocol import WampClientFactory, WampCraClientProtocol
from autobahn.twisted.websocket import connectWS
class SomeClient(WampCraClientProtocol):
def doSomething(self, something):
return something
@derwolfe
derwolfe / gist:ca5f7e86790e1c2df6ca
Created November 20, 2014 16:41
irc notes about twisted packaging/docs - ticket #3696
09:41 <herrwolfe45> I'm working on ticket #3696 and am a bit stuck on what type of documentation I should write - I'm thinking I should write a how-to describing how one should install twisted and it's various optional dependencies. This how-to would be in the narrative docs for twisted core. Does this sound like a decent idea?
09:41 <glyph> herrwolfe45: That sounds fantastic.
09:42 <herrwolfe45> glyph: excellent, I'll start with that - thanks
09:45 <herrwolfe45> ergh its
09:48 <exarkun> When writing that, don't forget that `pip install Twisted` is the least preferred installation method. When possible people should prefer an OS-supplied package. (But it's certainly not always possible.)
09:49 <exarkun> (Or possibly tailoring different sections of the document to different audiences makes sense - developers working on Twisted have slightly different requirements from developers using Twisted have very different requirements from end-users using an application that depends on Twisted.)
09:50 <glyph> exarkun:
# File: data_handlers.py
from models import MyDataObject
class MyDataHandler:
""" responsible for working on the data only."""
def __init__(self, data_object):
self.data_object = data_object
def mult_data_by_two(self):
return self.data_object.numeric_data * 2
@derwolfe
derwolfe / irclog.txt
Created December 31, 2014 17:15
irclog
12:06 <herrwolfe> is there a configuration option to specify a tox environment to only run on osx? I'm bundling an application and would like go through the long process of getting pyobjc installed, but only when actually necessary
12:11 → Ivo and avanderneut1 joined ⇐ jaraco, Jurko, antocuni, cr3 and avanderneut quit ↔ wirrrbel, maryokhin, dowwie and wirrrbel1 popped in
Wednesday, December 31st, 2014
02:03 → jaraco, wirrrbel and cr3 joined ↔ antocuni and Jurko popped in ↔ bubenkoff and untitaker nipped out
09:30 <ronny> herrwolfe: im not aware of a easy way to do that right now
09:33 ⇐ wirrrbel quit (~Thunderbi@dslb-088-066-055-002.088.066.pools.vodafone-ip.de) Ping timeout: 264 seconds
09:53 <herrwolfe> ronny: thanks - it seems like that is something I should probably handle at a different level anway
10:06 ↔ pf_moore nipped out
10:07 <ronny> herrwolfe: as faras i can tell, platform tags for tox might be a good idea
10:07 <ronny> (solutions on other levels seem uneasonably complex at first thou
import os
import pem
from twisted.application.service import Application
from twisted.application.internet import (
TCPServer,
SSLServer
)
@derwolfe
derwolfe / translate.py
Created April 7, 2015 19:26
I love python
import csv
def translate_file(fname):
translated = []
with open(fname, 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
reader.next()
for row in reader:
translated.append(to_class(row[0], row[1], row[2]))
return to_string_list(translated)
@derwolfe
derwolfe / keybase.md
Created August 19, 2015 17:05
keybase.md

Keybase proof

I hereby claim:

  • I am derwolfe on github.
  • I am derwolfe (https://keybase.io/derwolfe) on keybase.
  • I have a public key whose fingerprint is B256 481D 41F3 7AF2 29C2 A3D2 A008 BD38 361C 4770

To claim this, I am signing this object: