Skip to content

Instantly share code, notes, and snippets.

@shenie
shenie / memory-leak.groovy
Last active January 3, 2016 07:39
Memory leak in groovy with toString() on instances of mixed in class
class BarMixin {
}
Date.mixin(BarMixin)
100.times {
println "#${it + 1}"
def bar = new Date()
bar.toString()
sleep 100
@shenie
shenie / .gitignore
Created October 5, 2011 03:18
Fix mp3 meta tags based on filename & path
*.mp3
@shenie
shenie / load_spec.rb
Created July 8, 2011 01:46
Standalone capybara+rspec
require 'active_record'
require 'mysql2'
require 'capybara'
require 'rspec'
require 'capybara/rspec'
include Capybara::DSL
Capybara.default_driver = Capybara.javascript_driver
@shenie
shenie / GrailsViewResolver.groovy
Created June 9, 2011 23:52
How to use Category in gsp without calling "use" in the .gsp itself
class MyGrailsViewResolver extends GrailsViewResolver {
@Override
protected View loadView(String viewName, Locale locale) {
new MyView(super.loadView(viewName, locale))
}
static class MyView implements View {
def View view
// Written for Advanced Scraping (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//
var util = require('util')
public String convertToString(GPathResult doc) {
def defaultNamespace = doc.lookupNamespace('')
if (defaultNamespace) {
def docWithNamespace = {
mkp.declareNamespace("": defaultNamespace)
out << doc
}
return new StreamingMarkupBuilder().bind(docWithNamespace)
} else {
@shenie
shenie / itunes.markdown
Created January 31, 2010 07:38
iTunes applescript
osascript -e 'tell app "iTunes" to set sound volume to sound volume +20'
osascript -e 'tell app "iTunes" to next track'
osascript -e 'tell app "iTunes" to previous track'
osascript -e 'tell app "iTunes" to playpause'
osascript -e 'tell app "iTunes" to play'
osascript -e 'tell app "iTunes" to pause'
osascript -e 'tell application "iTunes" to return name of current track'
osascript -e 'tell application "iTunes" to set song repeat of current playlist to one'
osascript -e 'tell application "iTunes" to set shuffle of current playlist to not shuffle of current playlist'
@shenie
shenie / glom.java
Created January 29, 2010 20:08
dhanji take 2
public void _glom(Stack<String> stack, String...a) {
if (a.length == 0) {
if (stack.peek() == "") {
stack.pop();
}
return;
}
String s = a[0];
if (s != "") {
public List<String> glom(String...a) {
Stack<String> stack = new Stack<String>();
stack.push("");
for (String s : a) {
if (s != "") {
stack.push(stack.pop() + s);
} else {
if (stack.peek() != "") {
stack.push("");
@shenie
shenie / Readme.md
Created January 27, 2010 06:01
tab-fu

This script will open a new Terminal tab at the current directory or another directory relative to the current directory. Assuming tab.sh is somewhere in your PATH. For example I saved it in my ~/bin then you can just do:

tab.sh

tab.sh ../another_project