Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew J. McCullough matthewmccullough

View GitHub Profile
@matthewmccullough
matthewmccullough / UsernameMachinenameGUIDGenerator.java
Created Sep 15, 2008
Generate a GUID composed of username, machine name, and random int
View UsernameMachinenameGUIDGenerator.java
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Random;
public class GetMachineName {
/**
* @param args
@matthewmccullough
matthewmccullough / gist:34347
Created Dec 10, 2008
Walk a Java JNDI tree of all nodes
View gist:34347
InitialContext initialContext;
StringBuffer sb
try {
sb = new StringBuffer();
initialContext = new InitialContext();
loopLevel(sb, initialContext, "java:comp");
} catch (NamingException e) {
writer.println("<html><body>");
@matthewmccullough
matthewmccullough / JavaShellExecute.java
Created Jan 12, 2009
Executes a shell command (a.k.a. Shell Execute) from java, such as to open a PDF file or other registered file type
View JavaShellExecute.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* A Java method to execute and wait for a shell command to complete
*/
public class JavaShellExecute
{
public static void main(String[] args) throws Exception {
@matthewmccullough
matthewmccullough / gist:47267
Created Jan 15, 2009 — forked from halbtuerke/gist:31934
Show Git dirty status in your Unix bash prompt (symbols not compatible with CygWin)
View gist:47267
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@matthewmccullough
matthewmccullough / gist:48058
Created Jan 16, 2009 — forked from halbtuerke/gist:31934
Windows (Cygwin) Show Git dirty status in your Unix bash prompt
View gist:48058
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@matthewmccullough
matthewmccullough / findjars.sh
Created Jan 20, 2009
Look for JARs that contain a given artifact name (Class, Resource, etc.)
View findjars.sh
#!/bin/sh
#Example Usage: findjars com/ambientideas/groovy
CLASSNAMETOFIND="$1"
for eachjar in `find . -iname "*.jar"`
do
echo "Searching in $eachjar ..."
jar tvf $eachjar | grep $CLASSNAMETOFIND > /dev/null
@matthewmccullough
matthewmccullough / findjars.bsh
Created Jan 20, 2009
Look for JARs containing a class name
View findjars.bsh
#!/bin/sh
#Example Usage: findjars com/ambientideas/groovy
CLASSNAMETOFIND="$1"
echo "Searching all JARs recursively..."
for eachjar in `find . -iname "*.jar"`
do
#echo "Searching in $eachjar ..."
@matthewmccullough
matthewmccullough / .bashrc
Created Jan 26, 2009 — forked from henrik/.bashrc
Henrik's Git-Dirty Prompt
View .bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
View 3.0 Tethering
HOW TO ENABLE TETHERING ON YOUR 3.0 iPHONE
Step 1: Check if you own a 3G iPhone. If you're on EDGE (as I am): sorry. Tethering does not seem to work with EDGE phones.
Step 2: Check to see if AT&T is your carrier. If it is: sorry. AT&T will not let you tether.
Step 3: Navigate to ~/Library/iTunes/iPhone Carrier Support. Notice the spaces in that last folder name! If you're at the command line, use backslashes to escape the spaces, i.e. cd ~/Library/iTunes/iPhone\ Carrier\ Support. You will find a file with an ipcc extension. Copy that file: e.g. cp foo.ipcc foo.ipcc.original. This creates a backup for when you mess up.
Step 4: rename the ipcc extension to zip. For me that was ATT_US.ipcc renamed to ATT_US.zip. (Did I mention how I'm on a 1st Gen iPhone with AT&T?). Unzip it. This creates a new folder called Payload.
@matthewmccullough
matthewmccullough / SetSwingDefaultFont.java
Created Apr 1, 2009
Modify the Swing Defaults Table to a new Font
View SetSwingDefaultFont.java
public static void setSwingFontDefault(javax.swing.plaf.FontUIResource newFont) {
java.util.Enumeration<Object> uiManagerKeys = UIManager.getDefaults().keys();
while (uiManagerKeys.hasMoreElements()) {
Object key = uiManagerKeys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource)
UIManager.put(key, newFont);
}
}