Skip to content

Instantly share code, notes, and snippets.

View alexalemi's full-sized avatar

Alex Alemi alexalemi

View GitHub Profile
@alexalemi
alexalemi / quiz1.py
Created December 7, 2011 12:20
Reddit Python Quiz 1
#! /usr/bin/env python
import sys, itertools
def wordchecker(dictfile,*lets):
""" Find the longest words made up of lets that are contained in dictfile """
dictionary = set( w.rstrip() for w in open(dictfile,'r')) #SpellChecker(['ospd.txt'])
def allwords(lets):
""" Return a generator of the longest words """
breakout = False
@alexalemi
alexalemi / emailme.py
Last active June 12, 2024 00:16
Python Gmail Email notification sender, with SMS and docopt.
#! /usr/bin/env python
""" Email Me.
Usage:
emailme <message>
emailme [-s] <message>
emailme [-s] <subject> <message>
emailme <toaddr> <subject> <message>
emailme <toaddr> <fromaddr> <subject> <message>
emailme -h | --help
@alexalemi
alexalemi / welford.py
Created March 21, 2012 19:29
Python Welford Algorithm
import math
class Welford(object):
""" Implements Welford's algorithm for computing a running mean
and standard deviation as described at:
http://www.johndcook.com/standard_deviation.html
can take single values or iterables
Properties:
mean - returns the mean
@alexalemi
alexalemi / Makefile
Created November 29, 2012 16:00
Simple LaTeX rubber makefile
.PHONY: clean all cleanall
# Make sure this has all of the right dependencies
DEPENDS=tex/*.tex *.sty *.bib *.tex
TARGET=aexam
all: $(TARGET).pdf
%.pdf: %.tex $(DEPENDS)
@alexalemi
alexalemi / BinaryPlot
Created December 3, 2012 19:49
BinaryPlot, showing an array of binary digits for a list of numbers
BinaryPlot[nums_, K_: 0, opts : OptionsPattern[BinaryPlot]] :=
MatrixPlot[
Table[BitGet[nums[[j]], i], {j, 1, Length[nums]}, {i, 0,
If[K > 0, K, nums // Log2 // Floor // Max]}],
Evaluate@FilterRules[{opts, { DataReversed -> {False, True},
Mesh -> True, FrameTicks -> None, Frame -> False }},
Options@MatrixPlot]]
BinaryPlot::usage =
"BinaryPlot[list] Creates and array showing the binary \
representation of a list of numbers. Takes the same options as \
@alexalemi
alexalemi / racquetball.ipynb
Created July 23, 2014 06:37
ipython notebook of simulated sound in racquetball court
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexalemi
alexalemi / ParticularRevisited.ipynb
Created August 5, 2014 23:44
illustration of the modified method of particular solutions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexalemi
alexalemi / sky.ipynb
Created August 11, 2014 22:59
Where did the blue go?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.