Skip to content

Instantly share code, notes, and snippets.

View mattdodge's full-sized avatar
😺
Oh look! A status that I'll never change again!

Matt Dodge mattdodge

😺
Oh look! A status that I'll never change again!
View GitHub Profile
@mattdodge
mattdodge / php_file_editor.php
Created June 20, 2012 19:19
Simple PHP File Editor
<?php
$the_file = "file.txt";
if (isset($_POST['content'])) {
$content = stripslashes($_POST['content']);
$fp = fopen($the_file,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
@mattdodge
mattdodge / bracketBayes.py
Created March 19, 2013 16:50
Run a Bayesian analysis on matchup probabilities for an NCAA bracket. This will spit out the probability that each seed makes it to a given round
'''
Created on Mar 18, 2013
@author: Matt Dodge
'''
'''
You can put your own probabilities here. It is a dict where the key is the lower seed
(lower by number, not by rank) followed by the higher seed, separated by comma, no space.
@mattdodge
mattdodge / ncaaMatchupProbability.py
Created March 19, 2013 17:52
A utility that hits TeamRankings and gets the matchup probabilities for each team in the NCAA tournament. You will need to hard-code (blech) all of the team IDs for now, I'm lazy
'''
Created on Mar 18, 2013
@author: Matt Dodge
'''
from bs4 import BeautifulSoup as BS
from httplib2 import Http
from urllib import urlencode
import json
@mattdodge
mattdodge / solve24.py
Created July 19, 2013 23:18
Solve the game 24 for any solution target and any numbers n = The target number (e.g. 24) nums = Array of numbers (floating point ok) to use solveStr = A helper string for this recursive method that returns a formula This method will return the first (not exhaustive!) possible solution to the game, or False if none exists Example: For the 24 gam…
def solve(n, nums, solveStr='x'):
''' Solve the game 24 for any solution target and any numbers
n = The target number (e.g. 24)
nums = Array of numbers (floating point ok) to use
solveStr = A helper string for this recursive method that returns a formula
This method will return the first (not exhaustive!) possible solution to the game, or False if none exists
Example: For the 24 game 1,3,4,6 call it the following way:
solve(24, [1,3,4,6])
@mattdodge
mattdodge / solve24.py
Last active December 20, 2015 00:39
Trimmed down 24 solver
def solve(n, nums, solveStr='x'):
''' Play 24 with nums 1,3,4,6 like so:
>>> solve(24, [1,3,4,6])
(6/(1-(3/4))) '''
n = float(n)
solved = False
if len(nums) == 1:
return (solveStr.replace('x', str(int(n))) if n == float(nums[0]) else False)
@mattdodge
mattdodge / gist:90704ecbbfecc78be50f
Created March 2, 2015 19:57
Human Readable Time Difference
function timeAgo(num_seconds) {
function numberEnding (number) {
return (number > 1) ? 's ago' : ' ago';
}
if (num_seconds <= 0) {
return 'just now!';
}
var years = Math.floor(num_seconds / 31536000);
if (years) {
return years + ' yr' + numberEnding(years);

Keybase proof

I hereby claim:

  • I am mattdodge on github.
  • I am mattdodge (https://keybase.io/mattdodge) on keybase.
  • I have a public key whose fingerprint is 4E10 1C96 3077 8865 8293 3F28 9947 BDF9 6192 D7D9

To claim this, I am signing this object:

@mattdodge
mattdodge / solutions.md
Last active May 12, 2023 12:30
Solutions to the game 24
Target (originally 24) Number of Solutions
2 479
3 469
6 462
1 462
5 459
4 457
7 454
9 448
@mattdodge
mattdodge / kiper_mcshay.md
Created May 19, 2017 01:07
Mel Kiper vs Todd McShay 2013 Draft
Pick Team McShay Kiper Actual
1 Kansas City Eric Fisher (OT - Central Michigan) Eric Fisher (OT - Central Michigan) Eric Fisher (OT - Central Michigan)
2 Jacksonville Dion Jordan (DE - Oregon) Luke Joeckel (OT - Texas A&M) Luke Joeckel (OT - Texas A&M)
3 Oakland Sharrif Floyd (DT - Florida) Sharrif Floyd (DT - Florida) Dion Jordan (DE - Oregon)
4 Philadelphia Lane Johnson (OT - Oklahoma) Lane Johnson (OT - Oklahoma) Lane Johnson (OT - Oklahoma)
5 Detroit Ezekiel Ansah (DE - BYU) Ezekiel Ansah (DE - BYU) Ezekiel Ansah (DE - BYU)
6 Cleveland Geno Smith (QB - WVU) Dee Milliner (CB - Alabama) Barkevious Mingo (DE - LSU)
7 Arizona Jonathan Cooper (G - UNC) Dion Jordan (DE - Oregon) Jonathan Cooper (G - UNC)
8 Buffalo Ryan Nassib (QB - Syracuse) Jonathan Cooper (G - UNC) Tavon Austin (WR - WVU)
@mattdodge
mattdodge / headless.sh
Created January 10, 2018 21:45
Make existing kubernetes services headless
kubectl get svc -o json | jq -r '.items[] | select (.spec.clusterIP!="None")' | jq '.spec.clusterIP = "None"' | kubectl replace --force -f -