Skip to content

Instantly share code, notes, and snippets.

@emiller
emiller / ruby-switch
Created July 3, 2018 00:51
ruby-switch
#!/bin/bash
#
# ppa: brightbox/ruby-ng/ubuntu
#
BINS="gem irb rake ruby ri rdoc erb"
VERS="1.9 1.9.1 2.0 2.1 2.2 2.3"
function display_alternatives() {
update-alternatives --display ${1:?"bin name"}
#!/usr/bin/env python
import os
import math
from numpy import interp
from random import choice, sample
from time import sleep
from math import log1p
# from colour import Color
@emiller
emiller / .bash_aliases
Created October 25, 2015 01:11
.bash_aliases
#!/bin/bash
export LANG="en_US.UTF-8"
export LANGUAGE="en_US"
txtrst='\033[00m' # Text Reset (\e[0m')
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
@emiller
emiller / i3status
Last active October 25, 2015 01:14
i3status
#
# i3 `status_command` config
#
# @author emiller
# @date 2014-09-09
#
general {
interval = 5
colors = true
@emiller
emiller / i3config
Last active October 25, 2015 01:13
i3config
#
# i3 config
#
# Written under the assumption that capslock is rebound via
# the following .Xmodmap config:
#
# clear mod3
# clear lock
# remove mod1 = Hyper_L
# remove mod2 = Hyper_L
@emiller
emiller / twentyfivesixty-over-hdmi
Last active December 29, 2015 03:08
Ghetto-fabulous script that sets up a 2560x1440 mode for a laptop's HDMI output, even if it doesn't allow it, and allows toggling usage.
#!/bin/bash
#
# twentyfivesixty-over-hdmi -- force an HDMI output to drive 2560x1440
#
# Ghetto-fabulous script that sets up a 2560x1440 mode for an HDMI output
# and allows toggling usage.
#
# I've been using a Dell U2713HM as an external monitor at work with my
# Lenovo Yoga 13, but unfortunately the HDMI port doesn't detect the native
# resolution of the monitor (2560x1440) as a valid output. In fact, all
@emiller
emiller / git-mv-with-history
Last active February 6, 2024 13:17
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@emiller
emiller / port-route
Last active December 24, 2015 08:09
Simple utility script that allows you to route incoming TCP traffic on one port to another.
#!/bin/bash
#
# port-route -- route one port's traffic to another.
#
# Simple utility that wraps `iptables` to enable routing TCP
# traffic of one port to another.
#
# Usage:
#
# port-route <up|down|show> <source port> <destination port>
@emiller
emiller / proxy
Last active December 24, 2015 04:59
proxy (socks ssh proxy)
#!/bin/bash
#
# proxy -- simple socks proxy for those open wifi networks.
#
# Usage is simple:
#
# proxy <up|down|watch|show|ssh> [alt remote port] [alt remote host]
#
# `proxy up` will create a socks proxy listening locally on 8000 by
# default, through a rhost server via ssh over port 53 (dns/domain).
@emiller
emiller / yoga-auto-rotate
Last active March 25, 2021 10:15
Lenovo Yoga 13 tablet mode / auto rotation script (ubuntu/debian)
#!/bin/bash
#
# yoga-auto-rotate -- ghetto-style tablet mode, with keyboard and all.
#
# Simple little script that will detect an orientation change for a
# Lenovo Yoga 13 (very hackily) and adjust the active display's
# orientation and disable/enable the touchpad as necessary.
#
# The Yoga 13 will emit keycode `e03e` at one second intervals
# when the screen is flipped into tablet mode. Since this keycode