Skip to content

Instantly share code, notes, and snippets.

View Oshuma's full-sized avatar

Dale Campbell Oshuma

View GitHub Profile
@Oshuma
Oshuma / minecraft.sh
Created February 10, 2011 11:45
Minecraft shell script launcher.
#!/bin/sh
client_jar="`dirname $0`/minecraft.jar"
max_heap_size="1024M"
initial_heap_size="512M"
java -Xms$initial_heap_size -Xmx$max_heap_size -cp $client_jar net.minecraft.LauncherFrame
if ((player.inShuffle() && player.playedSongCount() > 0 && !player.isDirty() && this.main.playerScreen.playButtonAvailable()) ||
(!player.inShuffle() && ((player.getQueueIndex() - 1) >= 1) && !player.isDirty() && this.main.playerScreen.playButtonAvailable())) {
// What the fuck just happened up there?
}
bind r source-file ~/.tmux.conf
bind k up-pane
bind j down-pane
set-option -g status-keys vi
# Increase this if running shell commands from this config.
set -g status-interval 15
# Automatically reconnects an ssh session on $interval.
# To halt this function, do this: touch $HOME/.ssh_stop_reconnect
function auto_ssh() {
stop_file="$HOME/.ssh_stop_reconnect"
interval=5
if [[ -f $stop_file ]]; then
echo "Cleaning restart file: $stop_file"
rm -f $stop_file
fi
require 'rubygems' if RUBY_VERSION =~ /1\.8/
require 'rack'
require "#{File.dirname(__FILE__)}/webapp"
if __FILE__ == $0
def usage
STDERR.puts("Usage: #{$0} <webrick, thin, mongrel>")
exit
end
[user]
name = YOUR NAME
email = YOUR EMAIL
[github]
user = GITHUB_USERNAME
token = GITHUB_TOKEN
[core]
pager = less -FMRX
@Oshuma
Oshuma / geo_ip.rb
Created November 13, 2010 09:04
Simple script to make an attempt at geolocating an IP.
#!/usr/bin/env ruby
dependencies = %w{
ipaddr
geokit
optparse
}
begin
dependencies.each { |lib| require lib }
@Oshuma
Oshuma / deny_ip.rb
Created November 11, 2010 22:25
Simple script which adds the given IPs to /etc/hosts.deny (or the specified file).
#!/usr/bin/env ruby
require 'ipaddr'
require 'optparse'
# Simple script which adds the given IPs to /etc/hosts.deny (or the specified file).
class DenyIP
DEFAULT_DENY_FILE = '/etc/hosts.deny'
def self.run!(*args)
@Oshuma
Oshuma / bot_protector.rb
Last active May 3, 2017 15:53
Rack middleware to fuck with bot requests.
module NerdNode
# Rack app to reject common bot attacks. Returns a random HTTP status and content type, along with some LOLs.
#
# Usage:
# use NerdNode::BotProtector, /phpmyadmin\/scripts|mysql\/scripts/
#
# # ...or use the Regexp helper which takes an array of URL strings...
# blacklist = BotProtector.build_regex(['phpmyadmin/scripts', 'mysql/scripts'])
# use NerdNode::BotProtector, blacklist
#
@Oshuma
Oshuma / trash.rb
Created October 26, 2010 08:29
Command line tool to send something to the Gnome Trash (with restore info).
#!/usr/bin/env ruby
# Command line tool to send something to the Gnome Trash (with restore info).
# TODO: Support trashing files of the same name.
class Janitor
TRASH_DIR = File.expand_path(File.join(ENV['HOME'], '.local/share/Trash'))
FILES_DIR = File.join(TRASH_DIR, 'files')
INFO_DIR = File.join(TRASH_DIR, 'info')