Skip to content

Instantly share code, notes, and snippets.

@rothgar
rothgar / bash_kb_shortcuts.md
Last active August 29, 2015 14:06
Helpful bash/emacs keyboard shortcuts
Shortcut Action
Ctrl + a Move cursor to beginning of line
Ctrl + e Move cursor to end of line
Ctrl + u Delete characters on line before cursor
Ctrl + k Delete characters on line after cursor
Ctrl + w Delete word in front of cursor
Alt + d Delete word after cursor
Alt + f Move cursor forward one word
Alt + b Move cursor back one word
@rothgar
rothgar / systemd_sysvinit.md
Last active November 5, 2018 01:51
Systemd vs SysVinit

Services

action sysvinit systemd
start service service foo start systemctl start foo[.service]
stop service service foo stop systemctl stop foo[.service]
restart service service foo restart systemctl restart foo[.service]
reload service service foo reload systemctl reload foo[.service]
service status service foo status systemctl status foo[.service]
restart if running service foo condrestart systemctl condrestart foo[.service]
@rothgar
rothgar / get-gists.py
Created September 28, 2014 21:54
Python unicode attribute error
If I curl for a github gist I get
$ curl https://api.github.com/gists/cecfbd74597cc35a6018
{
"url": "https://api.github.com/gists/cecfbd74597cc35a6018",
"forks_url": "https://api.github.com/gists/cecfbd74597cc35a6018/forks",
"commits_url": "https://api.github.com/gists/cecfbd74597cc35a6018/commits",
"id": "cecfbd74597cc35a6018",
"git_pull_url": "https://gist.github.com/cecfbd74597cc35a6018.git",
@rothgar
rothgar / esc_chroot.pl
Created January 12, 2015 18:18
Escape chroot
!#/usr/bin/perl -w
chdir "/"; opendir JAILROOT, ",";
mkdir "subdir"; chdir "subdir";
chroot "."; chdir(*JAILROOT);
while ((stat("."))[0] != (stat(".."))[0] or (stat("."))[1] != (stat(".."))[1]) }
chdir "..";
}
chroot ".";
system("/bin/sh");
@rothgar
rothgar / gsettings
Created January 14, 2015 00:37
gnome 3 gconf settings
# disable terminal scrollbar
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles/:$(gsettings get org.gnome.Terminal.ProfilesList default)/ scrollbar-policy never
@rothgar
rothgar / bitch.zsh
Last active August 29, 2015 14:14
bitch
# create bitch function
bitch() {
if [[ "${BUFFER}" == *" bitch" ]] && [[ "${BUFFER}" != su(do|)\ * ]]; then
# add sudo to beginning of line (remove bitch from end)
BUFFER="sudo ${BUFFER% bitch}"
elif [[ "${BUFFER}" == "bitch" ]]; then
LAST_CMD=$(fc -l -1)
BUFFER="sudo ${LAST_CMD#* }"
fi
# still need to run accept-line widget
#!/usr/bin/env bash
# Creates a dialog using Zenity that lists all of your open windows and then switches to whatever window matches your input
# Requires Zenity and wmctrl packages
IFS_BAK=$IFS
IFS_LINE=$'\n'$'\r'
IFS=$IFS_LINE
i="0"
WINDOW_LIST=$(wmctrl -l | grep -v "\-1")
@rothgar
rothgar / c2b.sh
Created June 3, 2015 15:37
curl2bash
# Curl to bash
# c2b http://random/script/you/shouldn't/trust.sh
c2b() {
curl -L ${1} | sudo bash
}
@rothgar
rothgar / set-matrix.sh
Last active August 29, 2015 14:27
set hdmi matrix output
#!/bin/bash
# Set matrix spliter display
# Designed for Monoprice 4x4 Matrix Switch
# http://www.monoprice.com/Product?p_id=5704
declare -A INPUT_HASH
declare -A OUTPUT_HASH
CHECKSUM='\xd5\x7b'
if [[ $# -eq 0 ]] && [ -z $MATRIX_CONFIG ]; then
@rothgar
rothgar / .bashrc
Created October 15, 2015 21:19 — forked from marioBonales/.bashrc
Default .bashrc for ubuntu
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace