Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""
Given n people what's the probability that there is a
birthday on each day of the year (assuming equal prob
for each day & no leap year)?
"""
import random
// Compile run with:
// cc piper.c -o piper ; ./piper
// From Season 3 Episode 1 of HBO's Silicon Valley
#include <stdio.h>
#include <stdlib.h>
void _ctx_iface(__int128_t s, int i)
{
@evanlong
evanlong / gist:3368734
Created August 16, 2012 09:30
spring board into libc
3a: 89 04 24 mov %eax,(%esp)
3d: 31 db xor %ebx,%ebx
3f: 89 58 02 mov %ebx,0x2(%eax)
42: bb 08 a0 04 08 mov $0x804a008,%ebx
47: 8b 03 mov (%ebx),%eax
49: bb ff ff ff 7f mov $0x7fffffff,%ebx
4e: 81 eb 2f 59 fc 7f sub $0x7ffc592f,%ebx
54: 29 d8 sub %ebx,%eax
56: 83 ec 04 sub $0x4,%esp
59: ff e0 jmp *%eax
@evanlong
evanlong / fun.m
Created August 4, 2012 20:54
ParticleFun
- (void)viewDidLoad {
[super viewDidLoad];
UIView *holderView = [[UIView alloc] initWithFrame:CGRectMake(50.0f, 50.0f, 200.0f, 200.0f)];
CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];
emitterLayer.frame = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
emitterLayer.emitterSize = CGSizeMake(20.0f, 20.0f);
emitterLayer.emitterPosition = CGPointMake(90.0f, 90.0f);
@evanlong
evanlong / .osx
Created July 29, 2012 00:14
OS X for Hackers
# ~/.osx — http://mths.be/osx
###############################################################################
# General UI/UX #
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
scutil --set ComputerName "MathBook Pro"
scutil --set HostName "MathBook Pro"
scutil --set LocalHostName "MathBook-Pro"
@evanlong
evanlong / .profile-ios.sh
Created May 14, 2012 21:09
Charles Proxy SSL certificate for iOS
#ios simulator helpers
_install-cert() {
if [ -f "$SQLITEDBPATH" ]; then
cp -n "$SQLITEDBPATH" "$SQLITEDBPATH.charlesbackup"
sqlite3 "$SQLITEDBPATH" <<EOF
INSERT INTO "tsettings" VALUES(X'189B6E28D1635F3A8325E1E002180DBA2C02C241',X'3123302106035504030C1A436861726C65732050726F78792053534C2050726F7879696E6731243022060355040B0C1B687474703A2F2F636861726C657370726F78792E636F6D2F73736C3111300F060355040A0C08584B3732204C74643111300F06035504070C084175636B6C616E643111300F06035504080C084175636B6C616E64310B3009060355040613024E5A',X'3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D225554462D38223F3E0A3C21444F435459504520706C697374205055424C494320222D2F2F4170706C652F2F44544420504C49535420312E302F2F454E222022687474703A2F2F7777772E6170706C652E636F6D2F445444732F50726F70657274794C6973742D312E302E647464223E0A3C706C6973742076657273696F6E3D22312E30223E0A3C61727261792F3E0A3C2F706C6973743E0A',X'3082045E30820346A003020102020101300D06092A864886F70D01010505003081913123302106035504030C1A436861726C6573205072
@evanlong
evanlong / build+archive.sh
Created April 7, 2012 08:20 — forked from wmerrifield/build+archive.sh
A shell script to perform the equivalent of Xcode's "Build & Archive" command.
#!/bin/sh
#
# Copyright (c) 2010 Warren Merrifield
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@evanlong
evanlong / fast.sh
Created April 6, 2012 00:14 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env bash
##
# Install:
# curl -sL https://raw.github.com/gist/2108403/fast.sh | sh
#
# Share your feedbacks on:
# https://gist.github.com/2108403
#
# Author: @DAddYE (Twitter/Github)
@evanlong
evanlong / hack.sh
Created March 31, 2012 17:47 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@evanlong
evanlong / MakeNprShow.py
Created March 25, 2012 07:07
Used to create a single mp3 file for the various NPR news shows that are not on iTunes as a podcast.
"""
Used to create a single mp3 file for the various NPR news shows that are not on
iTunes as a podcast.
Dependency on:
mp3wrap which can be installed with your favorite package manager
"""
import os
import os.path