Skip to content

Instantly share code, notes, and snippets.

View pal's full-sized avatar

Pål Brattberg pal

View GitHub Profile
C:\Documents and Settings\palbra\Desktop\cucumber_try>mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building cucumber_try
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
@pal
pal / ClasspathInspector.java
Created May 11, 2009 15:40
Find classes in the classpath (reads JARs and classpath folders).
package com.palbrattberg.classpathtools;
import java.io.File;
import java.io.FilenameFilter;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
@pal
pal / plural.php
Created November 25, 2009 12:28
Pluralizer Helper for CakePHP. Makes for easier use of the Inflector.
<?php
/**
* Pluralizes a singular term based on a count.
*
* This function will take a count and a singular term and pluralize
* the term if the count is not equal to 1.
*
* Example usage:
* <code>
@pal
pal / check_emails.as
Created November 26, 2009 17:39
Check either single email addresses or strings with multiple email addresses (coming from a textarea or similar)
/*
* Check if supplied String is a valid email adress.
* RegEx courtesy http://www.regular-expressions.info
*
* Use like so: is_valid_email('pal@subtree.se');
*/
function is_valid_email(inputEmail:String):Boolean {
var emailRegEx:RegExp = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/;
//trace(emailRegEx.test(email));
return emailRegEx.test(email);
@pal
pal / Capfile
Created February 4, 2010 00:52
Complete Capistrano deployment example for a very simple PHP-site.
# Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
require 'rubygems'
require 'railsless-deploy'
load 'config/deploy'
NoMethodError: private method `write_uploader' called for #<Article:0x1057e5e40>
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activemodel-3.0.0/lib/active_model/attribute_methods.rb:364:in `method_missing'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activerecord-3.0.0/lib/active_record/attribute_methods.rb:46:in `method_missing'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/carrierwave-0.4.10/lib/carrierwave/mount.rb:275:in `write_identifier'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/carrierwave-0.4.10/lib/carrierwave/mount.rb:228:in `write_image_identifier'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-3.0.0/lib/active_support/callbacks.rb:429:in `_run_save_callbacks'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activerecord-3.0.0/lib/active_record/callbacks.rb:277:in `create_or_update'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activerecord-3.0.0/lib/active_record/persistence.rb:39:in `save'
/Users/pal/Developer/.rvm/gems/ruby-1.8.7
@pal
pal / mobile-icon-sizes.rb
Created February 7, 2011 13:49
Simple Sinatra-app for listing icon sizes for mobile development, run using ruby mobile-icon-sizes.rb
require 'rubygems'
require 'sinatra'
require "sinatra/reloader" if development?
configure do
ICON_DATA = [
['320x480', 'Default.png', 'Launch image for iPhone and iPod touch (only one available in iOS < 3.2)', :ios],
['320x480', 'Default~iphone.png', 'Launch image for iPhone and iPod touch (to separate from ~ipad)', :ios],
['640x960', 'Default@2x.png', 'Launch image for iPhone high resolution (iPhone 4) (also Default@2x~iphone.png)', :ios],
['768x1004', 'Default-Portrait.png', 'Launch image for iPad (also Default~ipad.png)', :ios],
@pal
pal / organize.sh
Created March 20, 2011 14:14
Organize my newly imported images to the correct folder
#!/bin/sh
# Used in an Automator action that is run as a Image Capture Plugin
# Setup some constants
SRC_DIR=${1:-"$HOME/Pictures"} # defaults to "$HOME/Pictures" or file argument
DEST_DIR="$HOME/Backuped/originals/pictures"
# use exiftool to organize all pictures, yay!
# http://www.sno.phy.queensu.ca/~phil/exiftool/
@pal
pal / remove_duplicates.sh
Created March 20, 2011 18:02
Removes duplicate files (found using SHA1 checksum)
#!/bin/bash
# Used in an Automator action that is run as a Image Capture Plugin after file organization
#Delete duplicate files starting at $1 recursive
SRC_DIR=${1:-"$HOME/Backuped/originals/pictures"} # defaults to "$HOME/Backuped/originals/pictures"
temp_file="/tmp/fl$$" # $$ is process ID
find "$SRC_DIR" -type f -exec shasum {} \; | sort -r > $temp_file
# use substr($0, index($0, " ")); instead of $2 to handle filenames with spaces
@pal
pal / organize_pictures.sh
Created March 20, 2011 21:16
All-in-one script for organizing my massive amount of images. Still not stream-lined for images sans EXIF data and movies.
#!/bin/sh
# Complete script for organizing pictures and removing duplicates
# Setup some constants
SRC_DIR=${1:-"$HOME/Pictures"} # defaults to "$HOME/Pictures" or file argument
DEST_DIR="$HOME/Backuped/originals/pictures"
# use exiftool to organize all pictures, yay!
# http://www.sno.phy.queensu.ca/~phil/exiftool/