Skip to content

Instantly share code, notes, and snippets.

Avatar

Lari Hotari lhotari

  • DataStax
  • Espoo, Finland
  • 12:39 (UTC +02:00)
  • Twitter @lhotari
View GitHub Profile
@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
View DeltaStateMapDecorator.java
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 / PatchedHibernatePluginSupport.groovy
Created September 28, 2012 19:59
GRAILS-9411 and GRAILS-9412 monkey patch for Grails 2.1.1
View PatchedHibernatePluginSupport.groovy
// 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 / add_modes_to_screen.sh
Created May 24, 2013 13:16
script for adding standard modes to beamer for presenting on linux
View add_modes_to_screen.sh
#!/bin/bash
# script for adding standard modes to beamer for presenting on linux
# use xrandr to find out screen name of external output port
# xrandr is in x11-xserver-utils package on debian/ubuntu
SCREENNAME=$1
if [ -z "$SCREENNAME" ]; then
SCREENNAME=VGA-0
fi
function addmode() {
xrandr --newmode `cvt $1 $2 |grep Modeline | sed -e 's/^Modeline //' | sed -e 's/\"//g'`
@lhotari
lhotari / JsonWorkaroundBootStrap.groovy
Created November 22, 2013 09:35
GRAILS-10823 workaround. add this file to grails-app/conf directory
View JsonWorkaroundBootStrap.groovy
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 / SyncSql.groovy
Last active December 31, 2015 02:29
extensions to groovy.sql.Sql for doing UPDATE and INSERT statements
View SyncSql.groovy
/*
* 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 / pre-push
Created April 14, 2014 12:28
git pre-push hook script to prevent unintentional force pushs
View pre-push
#!/bin/bash
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
View manifest.yml
---
applications:
- name: grailsorg-dev
memory: 2G
instances: 1
path: site-2.3.0.war
timeout: 120
buildpack: https://github.com/cloudfoundry/java-buildpack.git
env:
JAVA_OPTS: -Dinitial.admin.password=verysecure -Dload.fixtures=true -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US
View Test3Controller_jdk7.java
15:13:23.848 INFO jd.cli.Main - Decompiling ./build/classes/test/org/codehaus/groovy/grails/web/servlet/mvc/Test3Controller.class
package org.codehaus.groovy.grails.web.servlet.mvc;
import grails.artefact.Artefact;
import grails.artefact.Enhanced;
import grails.web.Action;
import grails.web.controllers.ControllerMethod;
import groovy.lang.Closure;
import groovy.lang.GroovyObject;
import groovy.lang.MetaClass;
@lhotari
lhotari / jira_spam_cleaner.groovy
Created July 29, 2014 04:04
Jira Groovy Script for cleaning comment spam from a certain user
View jira_spam_cleaner.groovy
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.search.SearchException
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
View delete_remote_issue_links.groovy