Skip to content

Instantly share code, notes, and snippets.

@danhyun
danhyun / kimchi.adoc
Last active May 23, 2020 21:18
Kimchi Recipe
cl_interp 0
cl_interp_ratio 1
cl_cmdrate 128
cl_updaterate 128
rate 128000
fps_max 999
exec netcode
@danhyun
danhyun / HandlerFactory.java
Created December 5, 2014 22:32
First example blocks subsequent requests - Ratpack 0.9.11
package ratpack.example.java;
import ratpack.guice.Guice;
import ratpack.handling.Handler;
import ratpack.launch.LaunchConfig;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@danhyun
danhyun / build.gradle
Created November 10, 2014 15:07
Standard bootstrap Gradle build file
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
// other dependencies go here in Maven style Group:Artifact:Version format
testCompile 'junit:junit:4.11'
@danhyun
danhyun / build.gradle
Created November 10, 2014 15:05
Bare minimum Gradle build file
apply plugin: 'java'
apply plugin: 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'
gretty {
servletContainer = 'tomcat7'
enableNaming = true
jvmArgs '-Xmx2048M', '-XX:+CMSClassUnloadingEnabled'
afterEvaluate {
clean.dependsOn cleanPrepareArchiveWebApp
clean.dependsOn cleanPrepareInplaceWebApp
@danhyun
danhyun / hero.groovy
Created October 15, 2014 16:12
plain ol' groovy
// map based constructor
def nightcrawler = new Hero(name: 'Nightcrawler')
assert nightcrawler.name == 'Nightcrawler'
// with block
def nightcrawler = new Hero().with { h->
name = 'Nightcrawler'
power = 'teleportation'
h
}
line_length = 80
indent_length = 4
def splitAndIndent(line):
indentation = "\n" + (" " * indent_length)
first_line = line[0:line_length]
lines = [first_line]
remainder = line[line_length:len(line)]
if remainder:
indented_length = line_length - indent_length
@danhyun
danhyun / wtf.java
Created September 22, 2014 21:52
public String getPrettyAddress() {
String prettyAddress = null;
if (this.getAddresses() != null && !this.getAddresses().isEmpty()) {
Address mainAddress = null;
if (this.getAddresses().get(BusinessAddressType.PRIMARY.getType()) != null) {
mainAddress = this.getAddresses().get(BusinessAddressType.PRIMARY.getType()).getAddress();
} else if (this.getAddresses().get(BusinessAddressType.SHIPPING.getType().toLowerCase()) != null) {
mainAddress = this.getAddresses().get(BusinessAddressType.SHIPPING.getType().toLowerCase()).getAddress();
}
apply plugin: 'java'
apply plugin: 'idea'
idea {
project.ipr.withXml { provider ->
provider.node.component
.find { it.@name == 'VcsDirectoryMappings' }
.mapping.@vcs = 'Git'
}