Skip to content

Instantly share code, notes, and snippets.

View jackfischer's full-sized avatar

Jack Fischer jackfischer

View GitHub Profile
@jackfischer
jackfischer / config.fish
Created September 8, 2022 19:43
Fish config
if status is-interactive
# Commands to run in interactive sessions can go here
end
alias gs='git status'
alias gc='git commit'
alias gp='git pull'
alias gpush='git push'
alias ga='git add'
alias gaa='git add --all'
@jackfischer
jackfischer / setup.sh
Last active October 4, 2022 19:32
ubuntu server setup
# https://fishshell.com/
sudo apt-add-repository ppa:fish-shell/release-3 -y
sudo apt update
sudo apt install -y fish
chsh -s `which fish`
# git shortcuts
mkdir -p ~/.config/fish/
touch ~/.config/fish/config.fish
echo "
#Python 3
import fileinput
import os
TARGET_EXTENSION = ".php"
FIND = "REMOTE_ADDR"
REPLACE = "HTTP_CF_CONNECTING_IP"
def replace(f):
"""
Bound by our cache table which is every combination of subproblem, so
cities * months. Worst case we fill each of those cells (every city is
neighbors with every other city); filling in a cell takes worst case #cities
work (if it's neighbors with every other city) giving us overall bounding
O( cities * months * cities )
"""
from collections import defaultdict
table = defaultdict(dict)
from bs4 import BeautifulSoup
import requests
states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
for state in states:
stateselection = "http://www.icee.com/locationsICEE.asp?state=%s" % state
r = requests.get(stateselection)
soup = BeautifulSoup(r.text, "html.parser")
rows = soup.find_all("option")
from github import Github
username = "username"
password = "pass"
g = Github(username, password)
user = g.get_user()
pages = user.get_repos()
i = 1
@jackfischer
jackfischer / monty.py
Last active December 16, 2016 19:45
Simple monty hall problem simulation
import random
trials = 100
stay = []
switch = []
for t in range(trials):
possibilities = [1,2,3]
ans = random.choice(possibilities)
stay_ans = random.choice(possibilities)
stay.append(stay_ans == ans) #either true or false
@jackfischer
jackfischer / flaskapp.py
Last active August 29, 2015 14:25
flask boilerplate
from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def hello():
if request.method == 'GET':
request.args["field"]
return "Hello World"
if request.method == 'POST':
@jackfischer
jackfischer / capsSetup.sh
Created July 13, 2015 19:07
ubuntu: disable caps lock and set key to escape for vim
setxkbmap -option caps:none
xmodmap -e "keycode 66 = Escape"
@jackfischer
jackfischer / Wayback.py
Last active August 29, 2015 14:21
Quickly pipe a list of pages into Archive.org's Wayback Machine
from selenium import webdriver
import re, time
driver = webdriver.Firefox()
regex = re.compile("https?://([\S]+)")
for line in open ('FILE.txt', 'r'):
m = regex.search(line)
if m != None:
wayback = "https://web.archive.org/save/" + m.group(1)