Skip to content

Instantly share code, notes, and snippets.

(req, res, next) => {
let parsing = false;
const RE_BOUNDARY = /^multipart\/.+?(?:; boundary=(?:(?:"(.+)")|(?:([^\s]+))))$/i;
if (req.headers['content-type']) {
const regexResult = RE_BOUNDARY.exec(req.headers['content-type']);
if (regexResult) {
parsing = true;
const boundary = regexResult[1] || regexResult[2];
const d = new Dicer({ boundary });
d.on('part', p => {
import time, threading, socket, SocketServer, BaseHTTPServer, SimpleHTTPServer
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
header = 'X-Forwarded-For'
ip_address = self.headers[header]
if header is not None:
reversed_dns = socket.gethostbyaddr(ip_address)
print 'Serving for %s (%s)' % (ip_address, reversed_dns[0])
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
import React from "react";
import styled, { keyframes } from "styled-components";
// PIXELS per SECOND
const RATE = 100;
class DVDBox extends React.Component {
constructor(props) {
super(props);
this.state = {
#import <Foundation/Foundation.h>
typedef uint64_t CGSSpace;
typedef uint64_t CGSManagedDisplay;
typedef int CGSConnection;
typedef enum _CGSSpaceSelector {
kCGSSpaceCurrent = 5,
kCGSSpaceOther = 6,
kCGSSpaceAll = 7
#!/usr/bin/env python3.3
import nlzss.lzss3
import pygame
import struct
import sys
from optparse import OptionParser
DEBUG_MODE = False
def debug(*args, **kwargs):
@mmmulani
mmmulani / extract.sh
Created December 14, 2014 16:09
Generates a class-dump for all of Xcode along with C symbols
#!/bin/bash
# Run this with:
# find /Applications/Xcode.app/ -type f -perm -100 -exec ./extract.sh '{}' \;
# Afterwords run: (to remove all empty directories)
# find . -d -type d -empty -exec rmdir {} \;
APP=$1
BASE_DIR=`pwd`
@mmmulani
mmmulani / lol.py
Created March 20, 2013 00:05
Move terminal in a circle
#!/usr/bin/python -u
import math
import time
x_start = 400
y_start = 500
# 100 = 1 full rotation
TICKS = 500
# Measured in pixels.
SIZE = 100