Skip to content

Instantly share code, notes, and snippets.

@derwolfe
derwolfe / server.tac
Created July 31, 2017 00:48
twisted site with HSTS
import os
import pem
from twisted.application.service import Application
from twisted.application.internet import (
TCPServer,
SSLServer
)
@derwolfe
derwolfe / gist:434ba30127660781730e
Last active July 7, 2018 10:38
Installing twisted on windows
  1. install python 2.7.9 from here https://www.python.org/downloads/; if using a different python, then you may need to install pip using get-pip.py
  2. add the directory located at C:\python27\scripts to the end of your path with ;C:\python27\scipts
  3. upgrade pip to ensure that you have a version that supports installing wheels - pip install -U pip
  4. run pip install virtualenv
  5. run virtualenv venv
  6. if using:
    • cmd run .\venv\activate
    • powershell run .\venv\Scripts\activate.ps1. By default, powershell doesn't allow execution of unsigned scripts. This can be turned off by setting the execution policy to a more permissive setting. This can be done with open powershell and typing: Set-ExecutionPolicy Unrestricted. You will then be prompted about whether or not you'd like to really allow this; to accept type Y and hit enter.
    • git bash prompt run source ./venv/Scripts/activate
> There's two routes I see to making our system resilient.
There are two routes...
> And of course they nothing in this attack 
And of course they do nothing ...
@derwolfe
derwolfe / req_bench.py
Last active March 29, 2017 14:26
requests/treq work
from __future__ import print_function
"""
The "tests" here are intended to be used as benchmarks to help in performance
optimization.
"""
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, as_completed
from time import time
> create table spam(spot inet[]);
> insert into spam values (ARRAY['192.168.1.1'::inet]);
> account_service=> select * from spam;
spot
---------------
{192.168.1.1}
@derwolfe
derwolfe / main.py
Created January 10, 2017 18:00
example of twisted web
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.resource import Resource
class Page(Resource):
def render_GET(self, request):
return "hi".encode('utf-8')
"""
Dump current deferred state.
> Anyway, given a tree of deferreds, this will produce a whatever.dot
> file, which can be fed to graphviz' "dot -Tpdf whatever.dot >
> whatever.pdf", >and the pdf has a rather nice-looking graph of the
> deferreds.
http://twistedmatrix.com/pipermail/twisted-python/2012-July/025867.html

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 A274 2664 0C95 BAF9 A452 E51C BC97 2703 EE6A 93EC

To claim this, I am signing this object:

@derwolfe
derwolfe / key-cycle-msg.txt
Created August 8, 2016 16:11
gpg key cycle
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I am cycling my GPG key.
My old key has fingerprint:
B256 481D 41F3 7AF2 29C2 A3D2 A008 BD38 361C 4770
My new key has fingerprint:
@derwolfe
derwolfe / requirements.txt
Last active March 30, 2016 17:08
klein capture error routes
klein