Skip to content

Instantly share code, notes, and snippets.

View lhotari's full-sized avatar

Lari Hotari lhotari

View GitHub Profile
#!/bin/bash
# Disables Spotlight / mdworker and Time Machine backups for all build and .gradle directories under the working directory.
/usr/bin/find . '(' -name build -or -name .gradle ')' -exec touch "{}/.metadata_never_index" \;
/usr/bin/find . '(' -name build -or -name .gradle ')' -exec xattr -w com.apple.metadata:com_apple_backup_excludeItem com.apple.backupd "{}" \;
// Example of using StAX to split a large XML document and parse a single element using XmlSlurper
import javax.xml.stream.XMLInputFactory
import javax.xml.stream.XMLStreamReader
import javax.xml.transform.Transformer
import javax.xml.transform.TransformerFactory
import javax.xml.transform.sax.SAXResult
import javax.xml.transform.stax.StAXSource
def url = new URL("http://repo2.maven.org/maven2/archetype-catalog.xml")
@lhotari
lhotari / DeltaStateMapDecorator.java
Created September 27, 2010 05:53
Map decorator that stores the state of map changes and doesn't change the original decorated map
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@lhotari
lhotari / SyncSql.groovy
Last active December 31, 2015 02:29
extensions to groovy.sql.Sql for doing UPDATE and INSERT statements
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@lhotari
lhotari / JsonWorkaroundBootStrap.groovy
Created November 22, 2013 09:35
GRAILS-10823 workaround. add this file to grails-app/conf directory
import org.codehaus.groovy.grails.web.json.JSONObject
class JsonWorkaroundBootStrap {
def init = { servletContext ->
// activate workaround for GRAILS-10823
println("activating workaround for GRAILS-10823 - use this only for Grails 2.3.3")
org.springframework.util.ReflectionUtils.findField(JSONObject, "useStreamingJavascriptEncoder").with {
accessible = true
set(null, false)
}
@lhotari
lhotari / PatchedHibernatePluginSupport.groovy
Created September 28, 2012 19:59
GRAILS-9411 and GRAILS-9412 monkey patch for Grails 2.1.1
// src/groovy/grailspatch/PatchedHibernatePluginSupport.groovy
/*
* Copyright 2004-2005 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@lhotari
lhotari / DiagnosticCommandMBeanHelper.java
Created May 6, 2015 17:20
dumping threads in code on Java8+
import javax.management.DynamicMBean;
import javax.management.MBeanException;
import javax.management.ReflectionException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class DiagnosticCommandMBeanHelper {
public static String threadPrint() throws ReflectionException, MBeanException {
try {

Keybase proof

I hereby claim:

  • I am lhotari on github.
  • I am lhotari (https://keybase.io/lhotari) on keybase.
  • I have a public key whose fingerprint is 53A8 9613 1119 4A6B 0A44 97D9 E535 CAAF 8594 137E

To claim this, I am signing this object:

/*
* Script for generating Markdown for
* https://github.com/grails/grails-core/wiki/Travis-CI-status
*/
@GrabResolver(name='grailsCore', root='https://repo.grails.org/grails/core/', m2Compatible='true')
@Grab(group='org.slf4j', module='slf4j-nop', version='1.7.10')
@Grab(group='org.grails', module='grails-datastore-rest-client', version='4.0.0.M3')
import grails.plugins.rest.client.RestBuilder
def githubApiToken = System.getenv('GH_API_TOKEN')
@lhotari
lhotari / gist:8d615fc20aa852247f35
Created December 9, 2014 12:27
install_vagrant_on_macosx.sh
brew install caskroom/cask/brew-cask
brew cask install virtualbox
brew cask install vagrant
vagrant plugin install vagrant-cachier
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-omnibus