Skip to content

Instantly share code, notes, and snippets.

View paul-english's full-sized avatar

Paul English paul-english

View GitHub Profile
@paul-english
paul-english / code_review.md
Last active April 20, 2017 03:49
Code Review Checklists

General

  • Does this cover any code you've personally worked on in the past 6 months? -- If so, you'll want to do a more thorough review to ensure it doesn't cause you any later headaches
  • Will you have to work on this code or area of the codebase in the future? -- Also a good reason to do a more thorough review of the code base.
  • Is the code cleanly formatted? (whitespace, code organization, commenting, etc)
  • Do the tests pass?
  • Is there commented code that can be removed?
  • If function calls are removed, do those functions get called anywhere else? and if not can the function itself be removed?
pub fn int_from_bytes(x: &[u8]) -> i64 {
from_utf8(x).unwrap().parse::<i64>().unwrap()
}
pub fn float_from_bytes(x: &[u8]) -> f64 {
from_utf8(x).unwrap().parse::<f64>().unwrap()
}
named!(pub number<&[u8], i64>,
do_parse!(opt!(multispace) >>
@paul-english
paul-english / asana.py
Created January 4, 2017 16:26
Asana Python Social Auth
import json
import urllib.error
import urllib.parse
import urllib.request
from social.backends.oauth import BaseOAuth2
class AsanaOAuth2(BaseOAuth2):
"""Asana OAuth authentication backend"""
@paul-english
paul-english / fake_people.py
Created December 21, 2016 18:30
fake_people.py
#!/usr/bin/env python
import random
import string
import numpy as np
import pandas as pd
from faker import Faker
from tqdm import tqdm
#!python
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=True
cimport cython
import sys
from collections import namedtuple
import numpy as np
def offensive_score(player):
score = 0
score += player['passing_yds']*0.04
score += player['passing_tds']*4
score += player['passing_int']*-1
score += player['rushing_yds']*0.1
score += player['rushing_tds']*6
score += player['receiving_rec']*0.5
score += player['receiving_yds']*0.1
score += player['receiving_tds']*6
macro_rules! caseless_tag (
($i:expr, $inp: expr) => (
{
#[inline(always)]
fn as_lower(b: &str) -> String {
let s = b.to_string();
s.to_lowercase()
}
let expected = $inp;
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 8.
date,hosted_by,dl,ul,results_img
2016-02-08 11:03:14,"Hosted by Utah Education Network (Salt Lake City, UT) [8.73 km]: 25.578 ms",662.45,110.55,http://www.speedtest.net/result/5069169190.png
2016-02-08 11:03:14,"Hosted by Utah Education Network (Salt Lake City, UT) [8.73 km]: 25.578 ms",662.45,110.55,http://www.speedtest.net/result/5069169190.png
2016-02-07 08:03:21,"Hosted by Utah Education Network (Salt Lake City, UT) [8.26 km]: 26.077 ms",136.70,108.52,http://www.speedtest.net/result/5066107780.png
2016-01-27 05:03:10,"Hosted by Utah Education Network (Salt Lake City, UT) [9.41 km]: 29.196 ms",374.00,117.15,http://www.speedtest.net/result/5033314995.png
2016-01-27 02:03:17,"Hosted by Utah Education Network (Salt Lake City, UT) [9.41 km]: 25.664 ms",230.01,103.32,http://www.speedtest.net/result/5032918852.png
2016-01-26 23:03:22,"Hosted by Utah Education Network (Salt Lake City, UT) [9.41 km]: 25.882 ms",171.36,116.52,http://www.speedtest.net/result/5032590592.png
2016-01-26 20:03:15,"Hosted by Utah Educati
@paul-english
paul-english / ansible-playbook
Created January 29, 2016 17:07
ansible-playbook
#!/usr/bin/env bash
# Place this script in a directory that preceeds the location of
# the real ansible-playbook script in your PATH. When run, it
# will add passwords found in the .ansible-vars file, then call
# the real ansible-playbook script.
set -e
#set -x
@paul-english
paul-english / .tmux.conf
Created November 16, 2015 22:30
tmux config
unbind C-b
set -g prefix C-Space
set -g mode-keys vi
# Set XTerm key bindings
setw -g xterm-keys on
# Set XTerm overrides
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@"