Skip to content

Instantly share code, notes, and snippets.

View kiy0taka's full-sized avatar
🔒

Kiyotaka Oku kiy0taka

🔒
View GitHub Profile
@uasi
uasi / gist:214109
Last active September 11, 2015 03:06
Show branch name in Zsh's right prompt
#
# Show branch name in Zsh's right prompt
#
autoload -Uz VCS_INFO_get_data_git; VCS_INFO_get_data_git 2> /dev/null
setopt prompt_subst
function rprompt-git-current-branch {
local name st color gitdir action
@ataylor284
ataylor284 / webapp.groovy
Created November 16, 2010 19:31
inspired by gist: 675667 -- expose any groovy object over the web
import com.sun.net.httpserver.*
Object.metaClass.webapp = {
{ path ->
try {
def attrs = path.split('/')[1..-1]
[200, owner.delegate.invokeMethod(attrs.head(), attrs.tail() as Object[]) as String]
} catch (Exception e) {
[500, e as String]
}
@berngp
berngp / MarshallerSpecSupport.groovy
Created April 14, 2011 17:53
Unit Testing Custom Object Marshallers with Spock in Grails
package org.osscripters.grails.common.web.converters.marshaller
import grails.plugin.spock.ControllerSpec
import org.codehaus.groovy.grails.support.MockApplicationContext
import org.codehaus.groovy.grails.web.converters.ConverterUtil
import org.codehaus.groovy.grails.web.converters.configuration.ConvertersConfigurationInitializer
import org.springframework.validation.Errors
import org.springframework.web.context.WebApplicationContext
/**
@aviflax
aviflax / clipboardserver.groovy
Created May 9, 2011 03:13
Simple little web app for clipboard exchange -- handles text and files
#!/usr/bin/env groovy
@GrabResolver(name='restlet', root='http://maven.restlet.org/')
@Grab(group='org.restlet.jse', module='org.restlet', version='[2.0,2.1[')
@Grab('commons-lang:commons-lang:2.4')
import java.awt.*
import java.awt.datatransfer.*
import java.io.*
import java.util.logging.*
import com.softsynth.jsyn.*
//groovy script for phone call
class DualToneMultiFrequency{
def num
def buf
SineOscillator high
SineOscillator low
AddUnit mixer
LineOut out
@founddrama
founddrama / VersionComparator.groovy
Last active April 20, 2023 12:55
a version comparator (e.g., "1.0.2" < "1.0.10")
def versions = []
def f = new File('mock-version-tags.txt')
f.eachLine { versions << it }
def versionComparator = { a, b ->
def VALID_TOKENS = /._/
a = a.tokenize(VALID_TOKENS)
b = b.tokenize(VALID_TOKENS)
for (i in 0..<Math.max(a.size(), b.size())) {
@karmi
karmi / tagcloud.sh
Last active September 4, 2017 02:01
Simple tag cloud with ElasticSearch `terms` facet
# (Re)create the index
curl -X DELETE "http://localhost:9200/tagcloud"
curl -X PUT "http://localhost:9200/tagcloud"-d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
@Dierk
Dierk / build.gradle
Created October 7, 2011 22:43
build.gradle for setting up a new gradle-based project
apply plugin:'groovy'
apply plugin:'idea'
repositories { mavenCentral() }
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.8.2'
}
task makeDirs(description:'make all dirs for project setup') << {
@ohtake
ohtake / gist:3217143
Created July 31, 2012 13:44
JUC2012 slides

スライドと Togetter と日本語訳へのリンクは http://build-shokunin.org/juc2012/sessions/ にも載るようになったのでこの Gist はもうメンテナンスされないかも。

スライド

@irof
irof / 1.groovy
Created August 20, 2012 12:32
GStringの評価が遅延されてるように見えるケースの
// プログラミングGROOVY P69
list = ['x']
def gs = "$list ${list[0]}"
assert gs instanceof GString
assert gs == '[x] x'
list[0]='y'
assert gs == '[y] x'