Skip to content

Instantly share code, notes, and snippets.

View nathanharper's full-sized avatar
🤠

Nathan Harper nathanharper

🤠
View GitHub Profile
function! BddFindFunction()
ruby<<E___
line = VIM::Buffer.current.line
if /^\s*(?:[Gg]iven|[Ww]hen|[Tt]hen|[Bb]ut|[Aa]nd)\s+"([^"]+)".*$/ =~ line
function_name = $1.gsub(/[^A-Za-z0-9\s]/, "").gsub(/\s+/, "_").downcase
Vim::command('call searchpos("def ' + function_name + '")')
else
Vim::message "Not a BDD :^("
end
E___
@nathanharper
nathanharper / ikill.pl
Last active August 29, 2015 14:02
simple process search/destroy menu
#!/usr/bin/env perl
BEGIN { $Curses::OldCurses = 1; }
use strict;
use warnings;
use Curses;
use perlmenu;
my $ARGC = $#ARGV + 1;
my $killid = 15;
my @all_pids;
@nathanharper
nathanharper / davmail_updater.pl
Last active August 29, 2015 14:02
Script to look for a new version of Davmail on Sourceforge, download it, and install it.
#!/usr/bin/perl
use strict;
use warnings;
use File::Path qw(make_path);
my $download_url = "http://sourceforge.net/projects/davmail/files/latest/download?source=files";
my $user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36';
my $version_file = "davmail_version";
my $davmail_deb = "davmail_latest.deb";
my $version_path = "$ENV{'HOME'}/.config/davmail_updater";
@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)
@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 / 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 / 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 / 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 / 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 / .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 \;\