Skip to content

Instantly share code, notes, and snippets.

Cass mathcass

Block or report user

Report or block mathcass

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mathcass / .direnvrc
Created Jun 19, 2018
Direnv function to aid with loading local virtualenv directories
View .direnvrc
# Usage: layout_virtualenv <path>
# Sets and loads a Python virtualenvironment from a local path
# Eg. `layout_virtualenv venv`
layout_virtualenv() {
local venv_path=${1:-venv}
log_status "Loading $venv_path"
load_prefix ${venv_path}
source ${venv_path}/bin/activate
mathcass /
Created May 31, 2018
Demonstrates how to combine multiple pd.DataFrame objects into an Excel sheet
"""Demonstrate how to save pd.DataFrame objects to named Excel sheets
Requires having openpyxl installed for writing to Excel documents
import pandas as pd
df1 = pd.DataFrame({
mathcass / markdownify.js
Created May 23, 2018
Bookmarklet to turn a website into Markdown
View markdownify.js
// Thanks to
// Copy the start of javascript to the end and paste it into your bookmark.
// Make sure not to have comments
javascript: (function () {
var list= document.getElementsByTagName('link');
for (var i = 0; i < list.length; i++) {
mathcass / arxiv.js
Created May 11, 2018
If someone sends you a Arxiv link and you want to go to the abstract, you can use this bookmarklet
View arxiv.js
var location = window.location;
location.pathname = location.pathname.replace('pdf', 'abs').replace('.pdf', '/')
mathcass /
Created May 6, 2018
Simple BASH script to backup Mozilla bookmarks to script location directory
# The intent here is to copy a daily backup of Mozilla bookmarks. Because the
# SQLITE database file can be as large as 25+ megabytes, if it has been backed up
# within the last day, there's no need to copy it over again.
# If there is a copy of the database already, bail. Otherwise, copy it.
DIR=$(dirname $0)
View decision_tree_structure.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mathcass / json_marshal_example.go
Created Apr 15, 2018
Example of unmarshalling a JSON string in Go "lazily" to ensure that you at least decode some of the items in the event of an error.
View json_marshal_example.go
// Demonstrates how to do "lazy" JSON Unmarshaling if you suspect that the main
// JSON container is formatted correctly but some sub-items may not be formatted
// correctly.
package main
import (
mathcass /
Created Mar 26, 2018
Within a Python virtualenv, remote all instlled packages
pip freeze | xargs -L1 pip uninstall -y
mathcass / notebook-name.js
Created Mar 23, 2018
Creates a bookmarklet to automatically name your Jupyter notebook according to
View notebook-name.js
// javascript:(function(){// your code here })();
// document.activeElement.value = '2018-03-23-cp-.ipynb'
javascript:(function () {
initials = 'cp';
d = new Date();
dateStr = d.toISOString().slice(0, 10);
notebookTpl = dateStr + '-' + initials + '-.ipynb';
mathcass /
Created Mar 17, 2018
Default aliases for Ubuntu
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
You can’t perform that action at this time.