Skip to content

Instantly share code, notes, and snippets.

@wesleybliss
wesleybliss / BusProvider.java
Last active August 29, 2015 00:59
Example Otto Event Bus Provider
package com.foo.bar.utils;
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
import com.squareup.otto.ThreadEnforcer;
/**
# GIT aliases and syntax highlights
alias gs='git status'
alias gl='git log'
alias gb='git branch'
alias gbb='git branch -al'
alias gc='git commit -am'
alias ga='git add'
alias gaa='git add -A'
alias gco='git checkout'
alias gfa='git fetch --all'
@wesleybliss
wesleybliss / zip_all_files.php
Last active August 29, 2015 13:57
Quick example of zipping a bunch of files in PHP.
<?php
// Where the files will be added from
$path = './';
$archiveName = 'test.zip';
$zip = new ZipArchive;
$res = $zip->open( $archiveName, ZipArchive::CREATE );
if ( $res !== TRUE ) {
@wesleybliss
wesleybliss / open.sh
Created March 17, 2014 16:27
Simple open shortcut for Cygwin
#!/bin/bash
# Very basic open script that either opens a path specified,
# or opens your current directory, in Windows Explorer, also
# accounting for path translation (via cygpath)
#
# Usage:
# $ open # Opens current directory
# $ open /my/unix/path # Opens a given path
@wesleybliss
wesleybliss / git_latest.sh
Created April 25, 2014 18:36
List most recently touched GIT branches
#!/bin/bash
# Note: this only works in 256bit color terminal
# http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
rs="\e[0m"
dc="\e[38;5;227m"
cc="\e[38;5;051m"
git for-each-ref --sort=-committerdate refs/heads --format="%(committerdate:short) %(refname:short)" | \
@wesleybliss
wesleybliss / last_modified_files.sh
Created May 8, 2014 17:40
Show the last N modified files, recursively.
#!/bin/bash
count=10
filter='*.*'
if [ ! -z "$1" ]; then
if [ "$1" == "--help" ]; then
echo "USAGE $0 [count] [filter (e.g. *.java)]"
exit 0
fi
@wesleybliss
wesleybliss / js_classical_inheritance_01__person_olympian
Created August 28, 2014 16:27
JavaScript Classical Inheritance #1
var Person = function( name ) {
this.name = name;
};
Person.prototype.hello = function() {
console.log( this.name + ' says hello!' );
};
Person.prototype.walk = function( distance ) {
@wesleybliss
wesleybliss / git_rename_branches
Created September 4, 2014 16:34
Rename GIT branches based on a pattern
#!/bin/bash
echo
show_usage() {
cat << EOF
Rename a set of branches, effectively DELETING old
branches and creating new ones based on the old ones.
USAGE
@wesleybliss
wesleybliss / git_rename_branches.lua
Created September 4, 2014 22:01
Rename GIT branches based on a pattern
#! /usr/bin/env lua
print("")
local showUsage = function()
print([[
Rename a set of branches, effectively DELETING old
branches and creating new ones based on the old ones.
USAGE
@wesleybliss
wesleybliss / trim_all_mysql_tables.php
Created October 8, 2014 18:22
Trim All MySQL Tables
<?php
// Config (change these if you want)
define( 'DISABLE_TIME_LIMIT', true );
define( 'DISABLE_OUTPUT_BUFFERING', true );
define( 'CUSTOM_ERROR_HANDLING', false );
define( 'DB_HOST', 'localhost' );
define( 'DB_PORT', 3306 );
define( 'DB_USER', 'root' );
define( 'DB_PASS', '' );