Skip to content

Instantly share code, notes, and snippets.

@penn201500
penn201500 / iterm2.zsh
Created October 24, 2019 08:52 — forked from wadey/iterm2.zsh
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
@penn201500
penn201500 / .ripgreprc
Last active September 13, 2019 03:37 — forked from asrivascrealytee/.ripgreprc
ripgreprc
#First, you need to set the RIPGREP_CONFIG_PATH environment variable to the file path of your config file
# export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
# Don't let ripgrep vomit really long lines to my terminal.
--max-columns=150
--max-columns-preview
# Add my 'web' type.
--type-add
web:*.{html,css,js}*
#!/bin/sh
#
set -ex
TEMP_DIR="$(mktemp -d -t XXXX)"
# cleanup
trap 'RESULT=$?; rm -rf "$TEMP_DIR" ; exit $RESULT' INT TERM EXIT QUIT
OLD_PWD="$PWD"
cd "$TEMP_DIR"
@penn201500
penn201500 / switch.el
Last active December 13, 2021 13:04 — forked from celadevra/switch.el
Sane switching of input methods when using evil-mode in Emacs on OSX;change some conf for qwerty keyboard, and default-im keyboard changed to be self-conf.
;; switch to english input method when switching to normal mode
;; and switch back when entering insert/replace modes
;; need external script support, currently mac-only
(defvar default-im "org.unknown.keylayout.layoutformc" "Default ascii-only input method")
(defvar prev-im (substring (shell-command-to-string "/usr/local/bin/im-select") 0 -1)
"IM that I use when starting Emacs and exiting insert mode")
(defun im-use-english ()
"Switch to english input method on a Mac. im-select is a tool
provided at https://github.com/daipeihust/im-select"
@penn201500
penn201500 / emacs_hammerspoon.lua
Created May 18, 2019 17:11 — forked from justintanner/emacs_hammerspoon.lua
Emacs Hammerspoon Script
--- Emacs Hammerspoon Script
-- Author: Justin Tanner
-- Email: work@jwtanner.com
-- License: MIT
--- What does this thing do?
-- Allows you to have Emacs *like* keybindings in apps other than Emacs.
-- You can use Ctrl-Space to mark and cut text just like Emacs. Also enables Emacs prefix keys such as Ctrl-xs (save).
--- Installation
@penn201500
penn201500 / install_packages.sh
Created May 10, 2019 16:15 — forked from luiscape/install_packages.sh
Install Python dependency packages from requirements.txt using conda.
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.
@penn201500
penn201500 / install-tmux.sh
Created April 15, 2019 05:28 — forked from pokev25/install-tmux.sh
Install tmux 2.8 on centos 7
# Install tmux 2.8 on Centos
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=/usr/local
@penn201500
penn201500 / netpps.sh
Created July 24, 2018 12:50 — forked from joemiller/netpps.sh
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
@penn201500
penn201500 / tmux.md
Created September 20, 2017 02:01 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@penn201500
penn201500 / python dict get method
Created August 29, 2017 10:10
python dict get method
# The get() method on dicts
# and its "default" argument
name_for_userid = {
382: "Alice",
590: "Bob",
951: "Dilbert",
}
def greeting(userid):