Skip to content

Instantly share code, notes, and snippets.

View josephmisiti's full-sized avatar

Joseph Misiti josephmisiti

View GitHub Profile
@josephmisiti
josephmisiti / gist:2373049
Created April 13, 2012 02:22 — forked from redpony/gist:2341487
Constant time sampling from multinomials (linear time initialization)
#ifndef _ALIAS_SAMPLER_H_
#define _ALIAS_SAMPLER_H_
#include <vector>
#include <limits>
// Placed in the public domain by Chris Dyer <cdyer@cs.cmu.edu>
// April 9, 2012
//
// R. A. Kronmal and A. V. Peterson, Jr. (1977) On the alias method for
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@josephmisiti
josephmisiti / index.html
Created February 11, 2013 04:11 — forked from wrr/index.html
<!DOCTYPE html>
<!-- By Jan Wrobel (http://mixedbit.org) -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Random walk</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
import sys
from PIL import Image, ImageDraw
try:
import cv
except ImportError:
print 'Could not import cv, trying opencv'
import opencv.cv as cv

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@josephmisiti
josephmisiti / RSA.py
Created September 2, 2013 20:48 — forked from avalonalex/RSA.py
# October 2011
# Author Yuhan Hao
# Email: yuhanhao@seas.upenn.edu
# Tested under python3.2.2
import random
import math
import copy
def euclid(a,b):
#------------------------------------------------------------------------------
# Make things VirtualEnv aware (Windows version).
# More info: http://www.swegler.com/becky/blog/2011/08/28/python-django-mysql-on-windows-7-part-3-ipython-virtual-environments/
# add this to the end of ipython_config
# (or course, for virtualenvs created via --no-site-packages, it would
# be much easier just to install iPython)
#------------------------------------------------------------------------------
import sys
import site
from os import environ
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto