Skip to content

Instantly share code, notes, and snippets.

View phsteve's full-sized avatar
🚀
😻

Steve Katz phsteve

🚀
😻
View GitHub Profile
@phsteve
phsteve / horserace gist
Created August 23, 2013 00:49
Bet tracking program
#!/usr/bin/python
#This is a program to calculate payouts for horse racing. The user is prompted
#for the names of the horses, then the names of the bettors, then for any number
#of bets. At the end, it displays the winnings of each bettor.
#It uses parimutuel-style betting, where the odds for each horse are calculated
#by dividing the total amount bet on all the horses by the amount bet on the
#specific horse. The people who have bet on a winning horse divide up all the
#money bet in proportion to the relative amount of their respective bets on the
@phsteve
phsteve / p14.py
Last active December 22, 2015 09:48
Project Euler Problem 14
#The Collatz sequence is defined by the following rules on the set of positive numbers:
# n -> n/2 if n is even
# n -> 3n + 1 if n is odd
#Starting with 13, the sequence proceeds:
# 13 - 40 - 20 - 10 - 5 - 16 - 8 - 4 - 2 - 1
#Which starting number, under 1,000,000 produces the longest chain?
@phsteve
phsteve / Change
Last active December 27, 2015 08:19
My recursive change counting algorithm.
#n is the total amount, L is the list of change denominations.
def change(n, L):
if n < 0:
return 0
if n == 0:
return 1
if L == []:
return 0
return change(n, L[:-1]) + change(n-L[-1], L)

Keybase proof

I hereby claim:

  • I am phsteve on github.
  • I am katz (https://keybase.io/katz) on keybase.
  • I have a public key whose fingerprint is 1D0C 64CA 0D92 3DFC 297A 5D43 ECD4 3433 A588 AE06

To claim this, I am signing this object:

To learn you really you need to do it a while. But we'll discuss some techniques that are helpful.
Starting:
clone (always, if you want to study)
git ls-files, skim, to see where code is
Finding where some feature is implemented, bottom up:
usually the easiest way to find anything specific
demo example: CPython, __add__
grep, preferably git grep, or grep foo -- $(find . -name \*.c) etc.
diff --git a/dispatch.py b/dispatch.py
index ba7c064..fd5f136 100644
--- a/dispatch.py
+++ b/dispatch.py
@@ -1,29 +1,36 @@
import requests
import json
-base_url = 'http://maps.googleapis.com/maps/api/distancematrix/json'
+class Client(object):
@phsteve
phsteve / -
Created September 18, 2014 22:05
GIST
msg: http://lunchlady.neverware.com/centos/6/updates/repodata/1e07fe299b6b8246f02eae9fcb583c793da533ab23c1c33f842d7322e7ab424f-filelists.sqlite.bz2: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: failure: repodata/1e07fe299b6b8246f02eae9fcb583c793da533ab23c1c33f842d7322e7ab424f-filelists.sqlite.bz2 from updates: [Errno 256] No more mirrors to try.
@phsteve
phsteve / pythoninstall.md
Last active August 29, 2015 14:22
Python and Pip installation with Homebrew

Python on Mac OS X

If you're writing Python:

Do which -a python to see how many Pythons you have installed.

If you see only /usr/bin/python, then you're good to go.

If not:

@phsteve
phsteve / psget_error.txt
Created May 4, 2017 19:57
psget.avail_modules is not available
PS C:\Users\skatz> C:\salt\salt-call.bat --local chocolatey.install psget
local:
Chocolatey v0.10.5
Installing the following packages:
psget
By installing you accept licenses for the packages.
psget v1.0.4.407 already installed.
Use --force to reinstall, specify a version to install, or try upgrade.
Chocolatey installed 0/1 packages. 0 packages failed.