Skip to content

Instantly share code, notes, and snippets.

View eriwen's full-sized avatar

Eric Wendelin eriwen

View GitHub Profile
@eriwen
eriwen / test.gradle
Created March 26, 2013 14:47
Separating tests from integration tests with Gradle
// Usage: gradlew [-Dtest.type=all|unit|integration] test
test {
String testType = System.properties['test.type']
if (testType == 'integration') {
include '**/*IntegrationTest.*'
include '**/*IntegrationSpec.*'
} else if (testType == 'unit') {
include '**/*Test.*'
include '**/*Spec.*'
@eriwen
eriwen / gist:188105
Created September 16, 2009 15:33
apache httpd performance settings
# Set expires header and Remove ETags
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
# Set cache-control header
<FilesMatch "\.(ico|jpg|png|gif)(\.gz)?$">
Header set Cache-Control "public"
@eriwen
eriwen / pretty_thunderbird_labels.css
Created December 29, 2010 00:12
userChrome.css snippet for Thunderbird to have pretty labels
/* Default Important Label */
treechildren::-moz-tree-cell(lc-FF0000) {
border-bottom: 1px solid #FF0000 !important; background-color: #FFCCCC !important;
}
treechildren::-moz-tree-cell-text(lc-FF0000) {
color: #000000 !important;
}
treechildren::-moz-tree-cell(lc-FF0000, selected) {
background-color: #FF0000 !important;
}
@eriwen
eriwen / relativePath.js
Created September 12, 2011 16:11
Get relative file path in JavaScript
/**
* Given a source directory and a target filename, return the relative
* file path from source to target.
* @param source {String} directory path to start from for traversal
* @param target {String} directory path and filename to seek from source
* @return Relative path (e.g. "../../style.css") as {String}
*/
function getRelativePath(source, target) {
var sep = (source.indexOf("/") !== -1) ? "/" : "\\",
targetArr = target.split(sep),
@eriwen
eriwen / pre-commit
Last active January 13, 2021 08:22
Pre-commit git hook for tracking new TODO/FIXME comments
#!/usr/bin/ruby
$refname = ARGV[0]
$oldrev = ARGV[1]
$newrev = ARGV[2]
def tasks
puts 'Checking TODOs...'
todo_pattern = /^\s*\+\s*([\/\#]+|<\!\-\-)\s*(FIXME|TODO)\W*([\s\w]+)(\-\->)?$/
# Find task-oriented comments added with this commit
@eriwen
eriwen / buildSrc_build.gradle
Last active July 4, 2020 21:38
Minify individual files with Google Closure Compiler using Gradle
repositories {
mavenCentral()
}
dependencies {
compile localGroovy()
compile gradleApi()
compile ('com.google.javascript:closure-compiler:v20151015') {
exclude module: 'junit'
}
@eriwen
eriwen / viewport-size.js
Created September 6, 2011 15:41
Get viewport dimensions for all browsers
function getViewportSize() {
var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
return [windowWidth, windowHeight];
}
@eriwen
eriwen / test_dns_speed.sh
Created February 26, 2012 04:49
Test DNS speed of a given domain
#!/bin/sh
for i in "lifehacker.com" "facebook.com" "manu-j.com" "reddit.com" "tb4.fr" "bbc.co.uk" "eriwen.com"
do
for j in "4.2.2.2" "8.8.8.8" "68.87.85.98" "68.87.69.146"
do
echo $j $i `dig @$j $i | grep Query | awk -F ":" '{print $2}'`
done
done
@eriwen
eriwen / chain.js
Created September 6, 2011 15:35
Simple function chaining with a timeout (not ES5 compatible)
Array.prototype.chain = function chain(delay) {
var tasks = this, pos = 0, delay = delay || 17;
setTimeout(function() {
tasks[pos++]();
if (pos < tasks.length) setTimeout(arguments.callee, delay);
}, delay);
return this;
};
// Usage;
@eriwen
eriwen / debug.js
Created August 27, 2011 04:40
Useful functions for web debugging (via @LeaVerou)
function $(id) { return document.getElementById(id); }
function $t(tag, con) { return (con || document).getElementsByTagName(tag); }
function $$(expr, con) { return (con || document).querySelectorAll(expr); }