Skip to content

Instantly share code, notes, and snippets.

View tomfbush's full-sized avatar
🏠
Working from home

Tom Bush tomfbush

🏠
Working from home
View GitHub Profile
@tomfbush
tomfbush / clean.r
Created November 22, 2018 20:30
Clean a specific column
# function to substitute matching string and everything after it with nothing
# note leading space if that applies to your dataset
removeCrap <- function(crapThing) {
gsub(" (0|[1-9][0-9]*)\ ?(GB).*$", "", crapThing)
}
# load data from csv into a dataframe
d <- read.csv("input.csv", sep = ",")
# display a few rows of the dataframe 'd'
@tomfbush
tomfbush / nb_remove_output.py
Created August 23, 2021 09:57 — forked from decabyte/nb_remove_output.py
Remove output from Jupyter notebook from the command line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Remove output from existing Jupyter Notebooks.
Modified from remove_output by Minrk, damianavila, gabraganca.
References:
[0]: https://github.com/jupyter/nbformat
[1]: http://nbformat.readthedocs.org/en/latest/index.html
@tomfbush
tomfbush / gist:285f2db050fb82a2ff85c867ffb9b775
Last active January 2, 2022 13:34
Search a path for a pattern in text files
# via https://stackoverflow.com/a/16957078/4421532
grep -rnw '/path/to/somewhere/' -e 'pattern'
@tomfbush
tomfbush / emacs-cheat-sheet.md
Created July 15, 2022 08:50 — forked from dherman/emacs-cheat-sheet.md
My emacs cheat sheet

In penance for cracking stupid jokes on Twitter, here's my Emacs cheat sheet. Emacs has a steep learning curve, so I've tried to order them by importance so you could learn them in stages.

One overall rule of thumb: pay attention to the minibuffer (the line at the bottom of the editor). It will often guide you through a process, and also gives you hints about what state you're in, such as the middle of a multi-chord sequence.

The other rule of thumb: when in doubt, C-g it out.

Basics (mandatory)

You simply can't get by without having these at your fingertips.

@tomfbush
tomfbush / TwitterClient.cs
Created December 2, 2022 21:21 — forked from sdesalas/TwitterClient.cs
An ultra-lightweight Twitter client in C# using OAuth
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using System.Linq;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;
@tomfbush
tomfbush / saliency.py
Created September 14, 2024 10:46 — forked from tatome/saliency.py
Simple Itty-Koch-Style Saliency Maps
# coding=utf-8
#
#!/usr/bin/python
#
# Copyright 2013 Johannes Bauer, Universitaet Hamburg
#
# This file is free software. Do with it whatever you like.
# It comes with no warranty, explicit or implicit, whatsoever.
#
# This python script implements an early version of Itti and Koch's