Skip to content

Instantly share code, notes, and snippets.

View nathanharper's full-sized avatar
🤠

Nathan Harper nathanharper

🤠
View GitHub Profile
@nathanharper
nathanharper / tmux_irssi_niclist.sh
Last active October 29, 2018 08:39
A quick attempt to automate opening up a tmux session with Irssi and its nicklist.pl running.
#!/usr/bin/env bash
# This should work whether you are already in a TMUX session or not...
# Irssi directory is assumed to be in the user's home dir
if [ -z "$TMUX" ]
then
tmux new-session -d -s ircuser
tmux split-window -tircuser -h -l20
tmux send-keys -tircuser "tmux send-keys -t0 \"irssi\" C-m; \
tmux send-keys -t0 \"/set nicklist_height \$(stty size | cut -f1 -d' ' -)\" C-m; \
tmux send-keys -t0 \"/set nicklist_width \$(stty size | cut -f2 -d' ' -)\" C-m; \
@nathanharper
nathanharper / .vimrc
Created September 19, 2012 13:04
My .vimrc file
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
@nathanharper
nathanharper / tinyurl.pl
Created September 27, 2012 21:37
Irssi script to convert URLs in messages to TinyURL
# I use iTerm2, which enables clicking to open URLs, but if the line wraps in the middle of one,
# iTerm2 does not recognize this. This script greatly decreases the chance that long URLs will wrap
# by using the Tiny URL API to shorten the URL. The script intercepts the message, and converts all URLs in place.
#
# DEPENDENCIES: must have the cURL command line utilities installed.
# DISCLAIMER: I don't use Windows, I don't know how cURL works on Windows, and I don't guarantee this will work. If it does, great!
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
@nathanharper
nathanharper / .tmux.conf
Created November 30, 2012 18:22
My tmux config
set-option -g default-command "reattach-to-user-namespace -l sh"
# change bind key to C-a
unbind -n C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# disable mouse
bind-key m \
set -g mode-mouse off \;\
@nathanharper
nathanharper / cnake.c
Created April 9, 2013 13:50
crappy C/ncurses implementation of "Snake" game
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* Functions */
void mvdraw(int,int,int);
void push(int);
void game_over(int);
void place_fruit(void);
@nathanharper
nathanharper / weenote.lua
Created May 26, 2013 20:53
Simple notification script for weechat, uses my fork of lnotify
weechat.register("weenote",
"Nathan",
"1.0",
"Beerware",
"My personal notification script",
"",
"UTF-8")
local settings = {
match = "my_nick"
@nathanharper
nathanharper / draggable.lua
Last active April 25, 2017 19:16
Really basic example of a draggable shape in the Love2D framework
local box = {x=10,y=10,w=50,h=80}
local mouseButton = 1
function love.load()
love.graphics.setBackgroundColor(255,255,255)
love.graphics.setColor(225,62,62)
end
function love.draw()
love.graphics.rectangle("fill", box.x, box.y, box.w, box.h)
@nathanharper
nathanharper / bright.py
Last active December 26, 2022 21:05
Wonky-ass script to adjust brightness on my Asus laptop running Crunchbang and Arch Linux.
#!/usr/bin/env python
"""
Adjust screen brightness.
Usage: `bright 10`
Default is to adjust brightness via hardware.
'-s' flag will make the tool adjust brightness via software.
'-g' flag prints current brightness (hardware)
Use '-d' and '-i' to decrement and increment, respectively. (hardware)
TODO: make '-sg' show software brightness
"""
@nathanharper
nathanharper / nathan.zsh-theme
Last active January 3, 2016 05:29
oh-my-zsh theme I'm working on
prompt_setup_nathan(){
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%}✚"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%}✹%{$reset_color%}"
# ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
@nathanharper
nathanharper / tounicode.scala
Created February 10, 2014 19:44
Convert STDIN to equivalent output in Unicode code points. If the input was a Scala program, you can run the output! YAY!
for (ln <- io.Source.stdin.getLines)
println(ln map {c => "\\u%04X".format(c.toInt)} mkString)