Skip to content

Instantly share code, notes, and snippets.

View willjobs's full-sized avatar

Will Jobs willjobs

View GitHub Profile
@willjobs
willjobs / Fastmail-tampermonkey.txt
Last active October 2, 2017 04:14
Tampermonkey/greasemonkey script to fix FastMail's email body width (which is set to 938px) to fit on the page
// ==UserScript==
// @name Fastmail - email body width
// @description Fix width of emails being wider than screen
// @author Will Jobs
// @id fastmail-emailwidth
// @include https://www.fastmail.com/mail/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
@willjobs
willjobs / enumerate_bin.R
Last active October 2, 2017 03:04
R script to enumerate all binary strings of a certain length and type. Useful for getting all possible combinations of columns, for example.
# "enumerate_bin("1xx000") generates a vector of all binary strings: c("100000","101000","110000","111000")
enumerate_bin <- function(input_str) {
strlen<-nchar(input_str)
for(i in 1:strlen) {
if(tolower(substr(input_str,i,i))=="x") {
str0 <- paste(substr(input_str,1,i-1),"0",substr(input_str,i+1,strlen),sep="")
str1 <- paste(substr(input_str,1,i-1),"1",substr(input_str,i+1,strlen),sep="")
return(c(enumerate_bin(str0), enumerate_bin(str1)))
}
}
@willjobs
willjobs / megabackup.sh
Last active October 1, 2017 10:14 — forked from matteomattei/megabackup.sh
Mega server backup using megatools (revised for updated megatools, serverpilot app locations, and to include timestamps)
#!/bin/bash
now=$(date +"%T")
echo "Starting backup at ${now}..." | tee -a /root/megabackup.log
SERVER="servername"
DAYS_TO_BACKUP=7
WORKING_DIR="/root/backup_tmp_dir"
BACKUP_MYSQL="true"