Skip to content

Instantly share code, notes, and snippets.

@jart
jart / mtgox.php
Created March 12, 2014 16:05
Some Mt.Gox Source Code
<?php
namespace Money;
class Bitcoin {
#const BITCOIN_NODE = '173.224.125.222'; // w001.mo.us temporary
const BITCOIN_NODE = '50.97.137.37';
static private $pending = array();
public static function update() {
@jart
jart / gist:c32796c46d5bb5b39a04
Last active August 29, 2015 14:04
Poetry generated by Poemy2 using comments posted to Reddit by anarchists
master jart@bean:~/poemy2$ ./poemy --alsologtostderr --foot=trochaic --length=tetrameter --tries=20 --lines=200 --corpora=moonbat --dict=isle 2>/dev/null | python ~/mop.py
when the group is largely roiling, even in the war and losing
by the spanish revolution, as a way of distribution
phony claim that israel murders, please just take it for the last years
who is really important, that resulted in a different
only reason that this matters, opposition to the workers
tv has been waiting, listening to the state demanding
prices are a lot of human, here is the initiation
the position here is blaming, here's a bunch of people doing
soldiers know the whole entire, and with all of the oppressor
import select
import socket
class UDPEchoServer(object):
def __init__(self):
self.sock = socket.socket(type=socket.SOCK_DGRAM)
self.sock.bind(('0.0.0.0', 5000))
@jart
jart / pbkdf2.c
Created September 13, 2011 21:39
Justine's PBKDF2
/* gcc -O3 --std=gnu99 -o pbkdf2 pbkdf2.c sha256.c && time ./pbkdf2 password salt 100000 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "sha256.h"
#define DIGEST_SIZE 32
#define BLOCK_SIZE 64
@jart
jart / gist:3156709
Created July 21, 2012 18:43
Assembly Audio Mixing
/**
* Represents 20ms of 8khz signed linear 16-bit audio
*
* This is how much audio gets put in each RTP packet.
*/
typedef int16_t frame_t[160];
/**
* Fast mix two audio frames together on x86 and x86_64
*
@jart
jart / gotham.py
Created August 23, 2012 05:27
Gothic Poetry Generator
r"""
gotham
~~~~~~
Gothic Poetry Generator
"""
import sys
@jart
jart / gist:3432942
Created August 23, 2012 05:24
Generated Poetry
-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-
IAMBIC PENTAMETER COUPLETS GOTH CORPUS
-~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~--~*~-
we really have to plug my eyes before
black angel i feel hunger for the shore
which answered not with a caress he died
shone for me to the lake of the night tide
with sadness here i opened wide the door
that scream i hear the angels name lenore
@jart
jart / gotham.py
Created August 24, 2012 20:12
Lorem Gotham w/ Rhyming
r"""
gotham
~~~~~~
Gothic Poetry Generator
"""
import marshal
@jart
jart / form_errors.html
Last active December 11, 2015 01:39
An example of how to use Twitter Bootstrap with Django Forms
{% for error in form.non_field_errors %}
<div class="alert alert-error">{{ error }}</div>
{% endfor %}
@jart
jart / gist:4704095
Created February 3, 2013 22:53
Google Open Source Libraries for C++ Development
* http://google-opensource.blogspot.com/
* http://blog.0x1fff.com/2009/12/35-google-open-source-projects-that-you.html
* glog - An excellent C++ logging library.
* gtest - An excellent C++ testing library.
* gflags - The best way to make your C++ program accept command line flags, be documented, and configurable all in one fell swoop.
* breakpad - A good multi-platform crash reporting system for C++ apps.
* gperftools - Faster heap memory and a bunch of tools similar to valgrind. Not as well maintained as it should be.
* sparsehash - An awesome hash map container library for both performance and low memory use cases.
* cityhash - Perhaps the best non-crypto hashing algorithm. 2x faster than MurmurHash.
* re2 - A drop-in replacement for PCRE (Perl Compatible Regular Expressions) that doesn't introduce security and performance risks. Most other regex libraries will run potentially boundless operations which can have surprising performance impacts and allow attackers to perform denial of service attacks.