Skip to content

Instantly share code, notes, and snippets.

@kknd22
kknd22 / scala variance and bounds
Last active December 23, 2015 10:39
scala variance and bounds
1. List[+T] is convariant
2. def ::(elem child):List[me] ----> List[child] < List[me)
3. def ::[parent >: me](x: parent):List[parent] ----> parent::List[me] returns List[parent]
scala> class parent
defined class parent
scala> class me extends parent
defined class me
@kknd22
kknd22 / grails custom build hook
Last active July 3, 2023 11:38
grails custom build hook
/**
* create Events.Groovy under directory <grails-project>/scripts
**/
eventCreateWarStart = {warName, stagingDir ->
//def wd = grailsSettings.projectWorkDir
println "###eventCreateWarStart [${stagingDir}]"
def today = System.currentTimeMillis()
def spt_js_dir= "spt_${today}"
@kknd22
kknd22 / pom.xml
Created February 28, 2014 14:30
Maven pom - downnload a jar only
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.myproject</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>My App</name>
<properties>
<org.springframework.version></org.springframework.version>
</properties>
@kknd22
kknd22 / backup bash xargs cp
Last active August 29, 2015 14:00
gitbash backup preserve original directory back up
#!/bin/sh
# daily backup for gradle in gradle project
cd C:/x/y/z
find . -name "build.gradle" -print0 2>/dev/null | xargs -0 --replace cp -P {} C:/a/b/c/d/gradle-dayily-back
@kknd22
kknd22 / HibernateProxyTypeAdapter.java
Created April 29, 2014 15:12
GSON hibernate lazy fix
/**
* http://stackoverflow.com/questions/13459718/could-not-serialize-object-cause-of-hibernateproxy
*
* in bootstrap:
* import hbadapter.HibernateProxyTypeAdapter
*
* class BootStrap {
*
* def init = { servletContext ->
*
@kknd22
kknd22 / HibernateProxyAdapterFactory.java
Last active August 29, 2015 14:00
register for hibernate proxy gson factory adapter
/**
* in grails-app/resource/spring/resource.groovy
* beans = {
* hibernateProxyAdapterFactory(hbadapter.HibernateProxyAdapterFactory)
* }
*
*/
package hbadapter;
import org.hibernate.proxy.HibernateProxy;
@kknd22
kknd22 / WebApplicationInitializer.java
Created May 14, 2014 13:08
webapplicationinitializer example
/**
http://stackoverflow.com/questions/17370176/webapplicationinitializer-is-not-launched-on-jettyselenium
*/
public class WebappConfig implements WebApplicationInitializer {
protected final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
@kknd22
kknd22 / SampleEndpointTest.java
Created June 6, 2014 12:08
xml-less spring jersey test
package t;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spring.SpringLifecycleListener;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@kknd22
kknd22 / build.gradle
Created June 11, 2014 13:32
gradle add file to existing war jar
task addToWar(type: Jar) {
destinationDir = file('dist')
archiveName = 'drools-guvnor.war'
from zipTree('ss/drools-guvnor.war')
from(file("ss/RRR.txt")) {
into ('META-INF')
}
}
@kknd22
kknd22 / Me.me.java
Last active August 29, 2015 14:03
gradle javaExec task
package me;
import java.util.Enumeration;
import java.util.Properties;
/**
* Created with IntelliJ IDEA.
* User: chris
* Date: 7/4/14
* Time: 3:54 PM