Skip to content

Instantly share code, notes, and snippets.

View tweekmonster's full-sized avatar

Tommy Allen tweekmonster

View GitHub Profile
@tweekmonster
tweekmonster / client.sh
Created September 26, 2015 01:42
Monitor FIFO pipe with Bash
#!/bin/bash
echo -en "${@}\x04" > /tmp/fifo_queue
@tweekmonster
tweekmonster / AutoIndent_Demo.scpt
Created February 24, 2016 18:04
Script for creating the autoindent GIF for braceless.vim
-- Script for creating the autoindent GIF for braceless.vim
-- https://github.com/tweekmonster/braceless.vim
to slowType(someText)
tell application "System Events"
repeat with i from 1 to count characters of someText
keystroke (character i of someText)
delay 0.15
end repeat
end tell
@tweekmonster
tweekmonster / agtrunc
Created May 18, 2015 17:53
A script to truncate the_silver_searcher's output in Vim
#!/usr/bin/env python
'''Truncates matches from ag
Place this script somewhere in your $PATH, like ~/bin and pipe ag into it.
Vim could be setup like this:
if executable('ag')
set grepprg=ag\ --vimgrep\ -w\ $*
if executable('agtrunc')
@tweekmonster
tweekmonster / edit-command-line.zsh
Created April 22, 2016 05:40
zsh edit-command-line zle widget that sets the cursor position in Vim
function edit-command-line() {
tmpfile=$(mktemp -t zsheditXXXXXXXX.sh)
print -R - "$PREBUFFER$BUFFER" > $tmpfile
editor=${VISUAL:-${EDITOR:-vi}}
args=()
if [[ "$editor" =~ vim ]]; then
pb=${#PREBUFFER}
(( b=pb+CURSOR ))
args+=("-c" ":call cursor(byte2line($b), ($b - $pb) + 1)")
fi
@tweekmonster
tweekmonster / python-imports.vim
Created April 27, 2016 06:09
Vim script to quickly edit the top portion of Python scripts using NrrwRgn
" A little annoying becuase NrrwRgn doesn't seem to be well suited for this.
" But, it gets the job done.
" Uses <leader>i in normal mode to open the split.
function! s:nrrw_head() abort
let saved = winsaveview()
keepjumps normal! 1G
let start = 1
let end = search('^\%(def\|class\)\s', 'ncW')
if !end
@tweekmonster
tweekmonster / gen-terminfo.sh
Created May 24, 2016 04:20
Enable italics and standout in tmux
#!/bin/bash
# Generate xterm-256color and screen-256color terminfo files that supports
# italicized text and standout display style. This will override the system's
# descriptions of xterm-256color and screen-256color for your shell.
#
# To enable in tmux:
# set -g default-terminal "xterm-256color"
#
# tmux recommends creating an `tmux-256color` terminfo file and setting the
# default-terminal to "xterm", but this causes ssh sessions to not display
@tweekmonster
tweekmonster / xtreme_python_def.py
Created July 6, 2016 05:21
I like python, but you can write some awful shit with it.
# This illustrates how ridiculous python functions can get.
# It is far from a common way to write functions.
# Though, I've seen comments inside of multiline arguments
# in the stdlib modules.
def hello \
( # This starts the hello function
arg1, # This is arg1
# I'm an extra comment
@tweekmonster
tweekmonster / java8_install.sh
Created May 6, 2015 15:56
Script for installing Oracle's Java 8 Server JRE on Ubuntu 14.04 LTS
#!/bin/sh
# This is a quick script to download and install Oracle's Java 8 Server JRE
# It was made with Ubuntu 14.04 LTS in mind, and installs to /usr/local
# curl pipe this script to sh if you enjoy the thrill of getting into an internet stranger's van
prefix="/usr/local"
java_url="http://download.oracle.com/otn-pub/java/jdk/8u45-b14/server-jre-8u45-linux-x64.tar.gz"
dl_file="/tmp/oracle-java8.tar.gz"
ohshi()
@tweekmonster
tweekmonster / python-2.7.9_install.sh
Created May 6, 2015 18:27
Script for compiling Python 2.7.9 on Ubuntu 14.04 LTS
#!/bin/sh
# Script for compiling Python 2.7.9 on Ubuntu 14.04 LTS and installing it to /usr/local
# * Source files are downloaded and left at /usr/local/src
# * Uses checkinstall to generate a deb package, so it will take a while.
# * Can be uninstalled using 'dpkg -r private-compiled-python2.7'
# * Uncomment line 57 if you *don't* want to install virtualenv and supervisor
# * Gists will be downloaded if supervisor's conf or init script doesn't exist.
# * You'll need to add /usr/local/bin to your PATH if it's not already
ohshi()
highlight default NonComment ctermfg=8 ctermbg=none cterm=none guifg=#333333 guibg=none gui=none
function! s:toggle_comments() abort
if exists('w:toggle_comments')
silent! call matchdelete(w:toggle_comments)
unlet! w:toggle_comments
else
let w:toggle_comments = matchadd('NonComment', '^\%(\s*'.split(escape(&commentstring, '^$.*/"'''), '%s')[0].'\)\@!.*')
endif
endfunction