Skip to content

Instantly share code, notes, and snippets.

Mac gaulinmp

View GitHub Profile
View formats.txt
Accounting:
_($* #,##0_);[Red]_($* (#,##0);_($* "-"_);_(@_)
* Left align $, parenthesis and red for negatives, - for 0, empty for empty.
@gaulinmp
gaulinmp / Grading,js
Last active Nov 15, 2018
Canvas Javascript workarounds
View Grading,js
// Wrap in for bookmarklet:
javascript: (function () {/* CODE HERE */})()
// Set Empty to Full Points
javascript: (function () {
$("#speedgrader_iframe").contents().find("body").find('span.question_points_holder > div').each(
function(index, elem){
var current_val = $(elem).find('input').val();
var full_val = $(elem).find('span').text().match(/\d+/)[0];
if (String(current_val) == "") {
@gaulinmp
gaulinmp / similarity_example.ipynb
Last active Mar 20, 2019
N-Gram Similarity Comparison
View similarity_example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gaulinmp
gaulinmp / progress.py
Created May 25, 2016
Ipython Progress
View progress.py
from IPython.display import display
import ipywidgets
df = list(range(100))
f = ipywidgets.FloatProgress(min=0, max=len(df))
out = ipywidgets.Output()
display(f, out)
for i in df:
@gaulinmp
gaulinmp / download_ff_industry.py
Last active Feb 17, 2016
Download Fama French industry classifications
View download_ff_industry.py
from io import BytesIO
from zipfile import ZipFile
import requests
def download_ffind_zip(ind_num):
zip_url = ('http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/Siccodes{}.zip'
.format(ind_num))
data = requests.get(zip_url)
zipfile = ZipFile(BytesIO(data.content))
@gaulinmp
gaulinmp / singularize.py
Last active Aug 29, 2015
Singularize function from patterns codebase
View singularize.py
#### SINGULARIZE #########################################################
# Adapted from Bermi Ferrer's Inflector for Python:
# http://www.bermi.org/inflector/
# Copyright (c) 2006 Bermi Ferrer Martinez
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software to deal in this software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of this software, and to permit
# persons to whom this software is furnished to do so, subject to the following
@gaulinmp
gaulinmp / new_flask_from_mold.sh
Last active Sep 3, 2015
Project from git template
View new_flask_from_mold.sh
#!/bin/bash
# From http://kevinthompson.info/blog/2013/11/11/using-git-repos-as-project-templates.html
# removed --depth 1, because that messes up GitHub hosting.
# Get flask_mold with latest version. Name it first passed in arg
git clone --origin source git@github.com:gaulinmp/flask_mold $1
cd $1
# Use Git Hub command to create repo on your git and set it to origin.
@gaulinmp
gaulinmp / cleaner.py
Last active Aug 29, 2015
Clean CSV Files (py3.4)
View cleaner.py
import re
import pandas as pd
with open("TAR_fourseasons.txt") as fh:
txt = fh.read()
#rgx = r'(\|1?\d\|(?:19|20)\d{2}\|[\w ]+\|[01]\|[\w ]+\|[\w ]+)[\n\r]+'
hotel_name = 'fourseasons'
rgx = r'[\n\r]+{}'.format(hotel_name)
i, matches = 0, []
rs = re.search(rgx, txt)
@gaulinmp
gaulinmp / .screenrc
Last active Apr 24, 2018
screenrc and associated files
View .screenrc
# Don't display the copyright page
startup_message off
# keep scrollback n lines
defscrollback 3000
# load ipython and my flask site in background, zsh in foreground.
screen -t py 0 bash -c 'jupyter lab; exec bash'
screen -t htop 1 bash -c 'htop; exec bash'
screen 2 zsh
View gaulinmp.zsh-theme
# reference colors
GREEN="%{$fg_bold[green]%}"
RED="%{$fg_bold[red]%}"
CYAN="%{$fg_bold[cyan]%}"
YELLOW="%{$fg_bold[yellow]%}"
BLUE="%{$fg_bold[blue]%}"
MAGENTA="%{$fg_bold[magenta]%}"
WHITE="%{$fg_bold[white]%}"
COLOR_ARRAY=($GREEN $RED $CYAN $YELLOW $BLUE $MAGENTA $WHITE)
You can’t perform that action at this time.