Skip to content

Instantly share code, notes, and snippets.

View beefy's full-sized avatar
✌️

Nate Schultz beefy

✌️
  • Zendesk
  • Philadelphia, PA
  • 15:13 (UTC -04:00)
View GitHub Profile
@beefy
beefy / parker_square.py
Created August 13, 2017 19:42
Try to find a 3x3 magic square
# written by: https://github.com/beefy
# for: https://www.reddit.com/r/math/comments/6tcrxs/3x3_magic_square_of_squares_1000_prize/
import numpy as np
while(1):
# generate a random 3x3 matrix
parker = np.random.randint(1000, size=(3, 3))
@beefy
beefy / client.c
Last active July 26, 2017 13:05 — forked from evanradcliffe/client.c
simple network in C from CS283
#include "csapp.h"
/* usage: ./echoclient host port */
int main(int argc, char **argv)
{
int clientfd, port;
char *host, buf[MAXLINE];
rio_t rio;
host = argv[1];
port = atoi(argv[2]);
@beefy
beefy / git-alias.sh
Last active May 10, 2017 17:34
An alias to simplify git committing
#!/usr/bin/env bash
do_push() {
while true; do
read -p "ready to push? " yn
case $yn in
[Yy]* ) read -p "commit msg: " msg; git add . -A; git commit -m "$msg"; git push; break;;
* ) kill -INT $$;;
esac
done
/* $begin csapp.c */
#include "csapp.h"
/**************************
* Error-handling functions
**************************/
/* $begin errorfuns */
/* $begin unixerror */
void unix_error(char *msg) /* unix-style error */
{
@beefy
beefy / chess_scrape.py
Last active December 29, 2020 03:56
Scrapes all live chess game PGNs from chess.com and concatenates the resulting files
#!/usr/bin/python
import spynner
import pyquery
import urllib
import os
# author: Nate Schultz
# contact: github.com/beefy
# created: 10/22/16
@beefy
beefy / yahoo_scrapper.py
Last active October 4, 2016 20:34
finance.yahoo.com web scrapper in python
#!/usr/bin/env python2.7
# taken from https://www.youtube.com/user/sentdex
import time
import urllib2
from urllib2 import urlopen
from lxml import html
sp500short = ['a', 'aa', 'aapl', 'abbv', 'abc', 'abt', 'ace', 'aci', 'acn', 'act', 'adbe', 'adi', 'adm', 'adp']
@beefy
beefy / gen_pdf.py
Created September 20, 2016 20:51
Generate pdf files from LaTeX tex files
import os
# execute `sudo apt-get install texlive-full` to install pdflatex
files = [file for file in os.listdir('.') if file.endswith('.tex')]
for file in files:
os.system('pdflatex '+file)
@beefy
beefy / sketch_aug15
Created August 15, 2016 21:47
arduino pulse
void setup()
{
}
void loop()
{
digitalWrite(9,HIGH);
delay(100);
digitalWrite(9,LOW);
delay(900);
@beefy
beefy / client.js
Last active July 13, 2016 18:38
A simple nodejs/socket.io chat
var socket = require('socket.io-client')('http://127.0.0.1:3000');
socket.on('connect', function(){});
socket.on('event', function(data){});
socket.on('disconnect', function(){});
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
@beefy
beefy / bom_encode.py
Last active July 8, 2016 15:40
Reads a file with legacy encoding
# taken from:
# http://stackoverflow.com/questions/22459020/python-decode-utf-16-file-with-bom
def decode_legacy(file_name):
encoded_text = open(file_name,'rb').read()
bom = codecs.BOM_UTF16_LE
assert encoded_text.startswith(bom)
encoded_text= encoded_text[len(bom):]
decoded_text= encoded_text.decode('utf-16le')
return decoded_text