Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Hawkes azhawkes

View GitHub Profile
@azhawkes
azhawkes / .vimrc
Created Jan 15, 2014
Finally decided to fix my .vimrc and other configs
View .vimrc
" Vundle package manager
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Vundle packages
Bundle 'gmarik/vundle'
Bundle 'maksimr/vim-jsbeautify'
Bundle 'einars/js-beautify'
@azhawkes
azhawkes / spider.sh
Created Jan 13, 2014
Really simple wget spider to obtain a list of URLs on a website, by crawling n levels deep from a starting page.
View spider.sh
#!/bin/bash
HOME="http://www.yourdomain.com/some/page"
DOMAINS="yourdomain.com"
DEPTH=2
OUTPUT="./urls.csv"
wget -r --spider --delete-after --force-html -D "$DOMAINS" -l $DEPTH "$HOME" 2>&1 \
| grep '^--' | awk '{ print $3 }' | grep -v '\. \(css\|js\|png\|gif\|jpg\)$' | sort | uniq > $OUTPUT
@azhawkes
azhawkes / gist:5009567
Last active Dec 14, 2015
Workaround to disable SWT full-screen mode on the Mac, to get around this nasty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389486
View gist:5009567
public static void disableFullScreen(Shell shell) {
try {
Field windowField = Shell.class.getDeclaredField("window");
windowField.setAccessible(true);
Object window = windowField.get(shell);
invoke(window.getClass(), window, "setCollectionBehavior", new Long[] { 0L });
} catch (Exception e) {
log.error("couldn't disable full screen mode", e);
}
@azhawkes
azhawkes / SwtImageSprite.java
Created Dec 20, 2012
Simple Java/SWT class for image sprites. Quickly slice up a larger image into smaller ones, while preserving alpha transparency. Most of the existing examples out there don't handle alphas properly.
View SwtImageSprite.java
package com.andyhawkes.gists;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
/**
* Simple class that demonstrates how to slice up regions of a sprite image in SWT, while preserving
* alpha transparency. There are shorter ways to do this if you don't care about alpha transparency.