Skip to content

Instantly share code, notes, and snippets.

View alex's full-sized avatar

Alex Gaynor alex

View GitHub Profile
@alex
alex / -
Created February 26, 2015 03:18
commit a86d54fa34727c7f91e77f83e6c4e76e7fbd5b5f
Author: Alex Gaynor <alex.gaynor@gmail.com>
Date: Tue Oct 7 21:51:38 2014 -0700
these aren't going to be published
diff --git a/content/drafts/long-live-curl.rst b/content/drafts/long-live-curl.rst
deleted file mode 100644
index d9cf18b..0000000
--- a/content/drafts/long-live-curl.rst
FROM ubuntu
ENV LAST_UPDATED 0
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y php5 php5-curl curl
RUN curl -sS https://getcomposer.org/installer | php
import sys
def key_schedule(key):
S = bytearray(range(256))
j = 0
for i in xrange(256):
j = (j + S[i] + ord(key[i % len(key)])) & 255
S[i], S[j] = S[j], S[i]
return S
#include <stdlib.h>
#include <sys/types.h>
#include <spawn.h>
#include <stdio.h>
#include <errno.h>
extern char **environ;
int main() {
pid_t pid;
import socket
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
s.bind(("eth0", 0x88CC))
while True:
print repr(s.recv(8192))
diff -r 1bc0a8310b9f Lib/hashlib.py
--- a/Lib/hashlib.py Thu Apr 17 20:11:19 2014 +0200
+++ b/Lib/hashlib.py Fri Apr 18 17:34:04 2014 -0700
@@ -60,7 +60,7 @@
algorithms = __always_supported
-__all__ = __always_supported + ('new', 'algorithms')
+__all__ = __always_supported + ('new', 'algorithms', 'pbkdf2_hmac')
@alex
alex / keybase.md
Last active August 29, 2015 13:57

Keybase proof

I hereby claim:

  • I am alex on github.
  • I am alex_gaynor (https://keybase.io/alex_gaynor) on keybase.
  • I have a public key whose fingerprint is E27D 4AA0 1651 72CB C5D2 AF2B 125F 5C67 DFE9 4084

To claim this, I am signing this object:

Automatic detection and optimization of immutable fields on POPOs

Sometimes you write some Python code with some objects, and the objects have some attributes that don't ever change. It's useful for the VM to be able to notice this, for example, say you wrote your own version of @property:

class property(object):
pypi=> select installer_type, count(*) from downloads where package_name = 'Twisted' group by installer_type order by count(*) desc;
installer_type | count
----------------+-------
pip | 625
distribute | 44
setuptools | 18
| 10
browser | 9
bandersnatch | 3
(6 rows)
@alex
alex / gist:6427878
Last active December 22, 2015 05:59
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#define N 10000000