Skip to content

Instantly share code, notes, and snippets.

View milesrichardson's full-sized avatar
👁️
Miles Richardson

Miles Richardson milesrichardson

👁️
Miles Richardson
View GitHub Profile
@milesrichardson
milesrichardson / eisenstat_log_generator.py
Last active August 29, 2015 14:05
Generate logs according to the format specified by Stan Eisenstat at Yale, for CS 223 and CS 323.
import math
class Log:
def __init__(self, hours_estimate=0, file_path=None):
self.hours_estimate = hours_estimate
self.items = []
self.discussion = "Don't forget a 100+ word discussion!"
if file_path is not None:
@milesrichardson
milesrichardson / runtests.py
Created September 12, 2014 20:08
CPSC 323 Command Line Test Framework
#! /usr/bin/env python
#
# Requires envoy:
# https://github.com/kennethreitz/envoy
import envoy
class BashColors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
@milesrichardson
milesrichardson / Ftp.inc.php
Created July 1, 2011 14:06
PHP FTP Class (+Simple logging)
<?php
class Ftp {
private $conn, $current_dir;
public $log;
public function __construct($host, $username, $password, $passive = false) {
$this->log = new Log;
$this->connect($host, $username, $password, $passive);
}
@milesrichardson
milesrichardson / tmux.conf
Created February 8, 2017 17:09
tmux conf file for new servers
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind r source-file ~/.tmux.conf \;
#set -g default-terminal "screen-256color"
set -g history-limit 10000
#set-window-option -g utf8 on
set -g utf8
set -sg escape-time 1
@milesrichardson
milesrichardson / deploy_parse_schemas.sh
Created May 16, 2017 19:11
Example bash file with inline python for deploying schemas from JSON files to parse-server
#!/usr/bin/env bash
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
SCHEMADIR="$DIR/../src/libcommon/dbschema"
TARGET_SERVER="http://localhost:9595/api/parse"
APPLICATION_ID=""
MASTER_KEY=""
@milesrichardson
milesrichardson / README.md
Last active June 26, 2018 11:42
pairwise.js: Given a list, return a list of all pairs in that list via Array.reduce(). Optionally filter and transform (map) the pairs based on items and indices.

pairwise.js

pairwise(list, options)

Given a list, return a list of all pairs in that list via Array.reduce()

Optionally filter and transform (map) the pairs based on items and indices.

@milesrichardson
milesrichardson / Tutorial.md
Last active December 1, 2018 22:36
Using `wget --continue` to resume broken downloads from Google Chrome

The Problem

You're downloading a big 1GB SQL file with Chrome. It stalls at 120mb. Ok, you try again. Looks like it's working this time. Thirty minutes later... stalls at 800mb. You are pulling your hair out.

What do?

wget --continue to the rescue!

Assumptions:

@milesrichardson
milesrichardson / README.md
Last active December 6, 2018 18:31
Create new mongo database and user with nodejs MongoClient

How to create a previously non-existing mongo database and new user from the nodejs mongodb driver using the admin account.

  1. Connect as admin user to new database, using authSource: admin (assuming adminDbName === admin)
  2. Create new user
@milesrichardson
milesrichardson / docker_host_vm_shell.sh
Created October 16, 2019 02:17
Get shell in docker host VM on mac
docker run -it --rm --privileged --pid=host justincormack/nsenter1
@milesrichardson
milesrichardson / FixTmuxWeirdCharacters.md
Last active November 5, 2019 17:03
How to stop weird characters being inserted on paste in tmux

ChrisJohnsen/tmux-MacOSX-pasteboard#31 (comment)

What happens if you paste (in a pane where you see the problem) while running cat -v? Do you see something like ^[[200~hello world^[[201~? If so, what you are seeing is bracketed paste mode.

You should be able to turn the mode off by running printf '\e[?2004l'