Navigation Menu

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
package de.nerdno.rpc.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
@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 / plex.sh
Last active February 27, 2020 14:58
Spin up a Plex docker container
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "$(basename $0) <claim-token>"
echo -e "\nGet claim token here: https://www.plex.tv/claim/"
exit 1
fi
claim_token=$1
@Oshuma
Oshuma / restore
Created October 27, 2017 00:41 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@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
#
function git_daily --description 'Daily stats for given git branch'
# git log --since=1.day --author='<YOUR_EMAIL>' --shortstat $argv | awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } END { printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d) }'
git log --since=12.hours --author='<YOUR_EMAIL>' --shortstat $argv | awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } END { printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d) }'
end
bind r source-file ~/.tmux.conf
# remap prefix to Control-a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
set -g default-terminal "screen-256color"
@Oshuma
Oshuma / mac.zsh
Created October 11, 2009 01:58
mac.zsh
# ----------------------
# variables
# ----------------------
PATH="$PATH:/opt/local/bin:/opt/local/sbin:/usr/games:/usr/local/mysql/bin:/usr/local/sbin"
MANPATH="$MANPATH:/opt/local/man"
IRB_HISTORY_FILE=$HOME/.irb_history
LESS='-M -R -X'
# ----------------------
function mount_iso() {
local iso_file
local mnt_directory
local opt
while getopts f:d:h opt; do
case $opt in
(h)
print "Options:"
print " -f <file.iso>"