Skip to content

Instantly share code, notes, and snippets.

View erickbrower's full-sized avatar

Erick Brower erickbrower

View GitHub Profile
@erickbrower
erickbrower / gist:8034136
Created December 19, 2013 03:48
My tmux.conf
set-option -g default-shell $SHELL
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g default-terminal "screen-256color"
set -g status-utf8 on
set -g history-limit 100000
set -g base-index 1
set -s escape-time 0
@erickbrower
erickbrower / apartments_com.js
Last active August 25, 2016 02:28
A quick attempt at scraping apartment data from Apartments.com with Node, PhantomJS, and jQuery. Currently borked.
var page = require('webpage').create(), stepIndex = 0, loadInProgress = false;
page.onLoadStarted = function() {
loadInProgress = true;
console.log('loading...');
};
page.onLoadFinished = function() {
loadInProgress = false;
console.log('loading complete');

Mapping Shell Commands in Vim

A really useful tool I use religiously is an on-the-fly mapping of a keycombo to run a shell command without leaving Vim. Say you're working on a spec, making lots of small changes and re-running the spec. Mapping that command to a couple of keystrokes saves a lot of time.

Here's an example command: :map ,r :wa\|!bundle exec rspec %<cr>

Yes, it looks like somebody puked in the prompt. Let's make some sense of this.

  • :map - If you don't know what this is, go home programmer. You're drunk.
  • ,r - The keycombo we'd like to use, in this case a comma followed by r

Easier Split Pane Navigation in Vim

Using Control+ww to switch panes causes a problem in ChromeOS, so I went looking for an alternative. This remaps it to Control+j (or k, h, l) to switch panes in the selected direction. Add them to your ~/.vimrc file.

nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-l> :wincmd l<CR>

Credit goes to this Stack Overflow answer

@erickbrower
erickbrower / eventcmd_prowl
Last active December 14, 2015 06:49
eventcmd script for mcabber that sends an email when a new message arrives. Designed for use with Prowl.
#!/usr/bin/python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
import os, sys
gmail_user = "youremail@gmail.com"
@erickbrower
erickbrower / mcabberrc
Created February 27, 2013 04:59
An example mcabberrc file pre-configured for google talk, logging, and OTR enabled.
# Note about this file syntax:
# - Leading and trailing spaces are ignored.
# - Empty lines and lines beginning with a '#' are ignored.
# Please provide your Jabber (XMPP) identifier:
set jid = youremail@gmail.com
# If password is not given, it will be interactively asked for.
# Note: if the password contains leading or trailing spaces, you must# enclose it with quotes: set password = " example password"
#set password = yourpassword
# You can provide a server name if you want mcabber to connect# to a specific server.
set server = talk.google.com

Chat Like a Hacker: Command Line Gtalk with OTR and iOS Push Notifications

MCabber Screenshot

My workflow nowadays involves a lot of time at the shell. I've recently become a disciple of Unix as an IDE, so over time I've replaced my GUI-based dev tools with their shell-based counterparts. Sublime Text with vintage mode was quickly dumped for Vim and a few plugins. Tabs in gnome-terminal were replaced with tmux (and somewhere, a choir of angels burst into song) hosting tons of ssh or psql connections. If I don't need to look anything up online, I can work for at least a couple of hours before coming up for air at the desktop.

So naturally I started thinking about a shell-based replacement for chat. My go-to solution has always been Pidgin for its simplicity, plugins, and OTR (Off The Record) encryption support. I strictly use gtalk, so the client wouldn't need to

@erickbrower
erickbrower / eventcmd
Last active December 14, 2015 03:39
Eventcmd script for mcabber, uses libnotify
#!/usr/bin/python
import sys
from gi.repository import Notify
if 'MSG' in sys.argv and 'IN' in sys.argv:
Notify.init('New Message')
window = Notify.Notification.new('New Message', 'from %s' % sys.argv[3], 'dialog-information')
window.show()
# A shortcut function that simplifies usage of xclip.
# - Accepts input from either stdin (pipe), or params.
# ------------------------------------------------
# Credit goes to: http://madebynathan.com/2011/10/04/a-nicer-way-to-use-xclip/
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"