Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / http_cvp.py
Created January 8, 2012 17:10
Python / Mumble: My tweaks to http://0xy.org/http_cvp.py
#!/usr/bin/env python
# -*- coding: utf-8
#
# Copyright (C) 2012 Benjamin Jemlich <pcgod@users.sourceforge.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
@cowboy
cowboy / pre-commit
Created January 5, 2012 19:08 — forked from miketaylr/pre-commit
#!/bin/bash
# pre-commit hook to prevent html5 video or audio files from being checked
# into the repo. because large binary files in a git repo sucks. bad.
media_files=$(git diff --cached --name-only --diff-filter=ACR | \
egrep -i '\.(webm|mp4|ogg|mp3|ogv|m4v|avi|vp8|mov|oga|mp1|mp2|mpeg|3gp|wav)$')
if [[ "$media_files" ]]; then
echo 'Commit failed. Are you trying to check in media files into the repo?'
exit 1
@cowboy
cowboy / ping_stuff.sh
Created December 29, 2011 03:00
I want to know what machines I have on my network. Is there a better (also faster) way than to ping machines 192.168.0.1 - 192.168.0.255?
#!/bin/bash
for oct in {1..254}; do
ip="192.168.0.$oct"
echo -en "\033[s$ip"
ping -c 1 -t 1 "$ip" >/dev/null 2>&1 && echo || echo -en "\033[1K\033[u"
done
@cowboy
cowboy / log.md
Created December 28, 2011 14:46
My dotfiles on Ubuntu linux 11.04

cowboy@ubuntu:~$ sudo apt-get -qq update && sudo apt-get -qq upgrade && sudo apt-get -qq install curl && \
> bash -c "$(curl -fsSL https://raw.github.com/cowboy/dotfiles/master/bin/dotfiles)" && source ~/.bashrc
[sudo] password for cowboy:
Dotfiles - "Cowboy" Ben Alman - http://benalman.com/

Installing Git
Selecting previously deselected package emacsen-common.
(Reading database ... 47723 files and directories currently installed.)
Unpacking emacsen-common (from .../emacsen-common_1.4.19ubuntu2_all.deb) ...
Selecting previously deselected package liberror-perl.

@cowboy
cowboy / prompt_exit_code.sh
Created December 23, 2011 18:51
Bash: an $? exit code var that clears itself when <enter> is pressed and no command is run.
# Maintain a per-execution call stack.
prompt_stack=()
trap 'prompt_stack=("${prompt_stack[@]}" "$BASH_COMMAND")' DEBUG
function prompt_command() {
prompt_exit_code=$?
# If the first command in the stack is prompt_command, no command was run.
# Set exit_code to 0 and reset the stack.
[[ "${prompt_stack[0]}" == "prompt_command" ]] && prompt_exit_code=0
prompt_stack=()
@cowboy
cowboy / xQuery.js
Created December 23, 2011 03:58
Why doesn't jQuery "do it kinda like this" ?
function xQuery(selector, context) {
if (xQuery.caller !== xQuery) {
return new xQuery(selector, context);
}
if (selector === "body" && !context && document.body) {
this.context = document;
this[0] = document.body;
this.selector = selector;
this.length = 1;
}
@cowboy
cowboy / Folder Preferences
Created December 21, 2011 13:25 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@cowboy
cowboy / silly-array-shuffle.js
Created December 1, 2011 17:22
JavaScript: Silly Array Shuffle
// Array.indexed(4) returns [0, 1, 2, 3]
Array.indexed = function(n) {
var result = [];
while (n--) {
result[n] = n;
}
return result;
};
// Shuffle an array in a not too efficient way.
@cowboy
cowboy / do_this_stuff.sh
Created November 30, 2011 16:21
Install Znc 0.202 in Ubuntu 11.04 (apt-get installs 0.092 by default)
# IIRC, this is what I had to do to install Znc 0.202 in Ubuntu 11.04:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:trekcaptainusa-tw/backports
sudo apt-get update
sudo apt-get install znc
# Don't forget to open the port in iptables. And while this opens the port, it
# won't restore the settings upon next boot. You'll want to use iptables-save
# for that, like: iptables-save > /etc/iptables.rules (this depends on your setup)
sudo iptables -A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
@cowboy
cowboy / ED Toolbar Colorset.SWSColor
Created November 22, 2011 14:23
Reaper: "Fixed" colors for ED's Color Toolbar v2.5
[SWS Color]
custcolor1=13959168
custcolor2=13979648
custcolor3=13993216
custcolor4=14006784
custcolor5=14013696
custcolor6=10474752
custcolor7=7001344
custcolor8=54528
custcolor9=54687