Skip to content

Instantly share code, notes, and snippets.

View kiy0taka's full-sized avatar
🔒

Kiyotaka Oku kiy0taka

🔒
View GitHub Profile
@kiy0taka
kiy0taka / user_stream.groovy
Created June 11, 2011 08:57 — forked from irof/gist:1020274
twitter4j-streamを使ってみる
@Grab('org.twitter4j:twitter4j-stream:2.2.3')
import twitter4j.*
new TwitterStreamFactory().instance.with {
addListener([onStatus:{println "@${it.user.screenName}: ${it.text}"}] as UserStreamAdapter); user()
}
@Grab('org.twitter4j:twitter4j-core:[2.1,)')
import twitter4j.*
new TwitterFactory().instance.updateStatus "${args[0]} #twitter4j_reading"
import java.awt.print.*;PrinterJob.printerJob.with{printable={g,p,i->g.drawString "Hello World!",50,50;i}as Printable;printDialog()&&it.print()}
String.metaClass.rightShiftUnsigned = { delegate > it ? it:delegate }
def better = 'Groovy' >>> '越えられない壁' >>> 'Java'
println "Hello $better!"
import grails.plugin.geb.GebSpec
import geb.Page
import spock.lang.Shared
class PersonEditSpec extends GebSpec {
@Shared fixtureLoader
def 'きれいなURLで編集画面を開く'() {
given:
@Grab('net.sf.groovydice:groovydice:1.4.1')
import net.sf.groovydice.*
class TinTiroRinPlugin {
def dynamicMethods = { api ->
api.add(method:'ttr') { dice ->
if (dice.allDice.size() != 3) return "ションベン!"
def stats = [all:dice.allDice, count:dice.allDice.countBy{it}]
switch (stats) {
case { it.count.size() == 1 && it.count[1] }:
@kiy0taka
kiy0taka / CreateAlias.groovy
Created April 28, 2011 12:46
[Grails] Create command alias.
/*
* Copyright 2011 kiy0taka
*
* 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
@Grapes([@Grab('org.xerial:sqlite-jdbc:3.7.2'), @GrabConfig(systemClassLoader=true)])
import groovy.beans.Bindable
import groovy.sql.Sql
import groovy.swing.SwingBuilder
import java.awt.event.*
import javax.swing.*
import javax.swing.table.*
import javax.swing.tree.*
import java.util.logging.*
@GrabResolver(name='seasar.org', root='http://maven.seasar.org/maven2/')
@Grab('net.arnx.jsonic:jsonic:1.2.0')
import net.arnx.jsonic.JSON
println JSON.encode([
name:'Kiyotaka OKu',
tags:['java', 'groovy', 'jenkins']
])
@Grab('org.grails:grails-web:1.3.6')
@Grab('org.slf4j:slf4j-nop:1.6.1')
import grails.converters.*
import org.codehaus.groovy.grails.web.converters.marshaller.*
import org.codehaus.groovy.grails.web.converters.configuration.*
interface MyMarshaller extends ObjectMarshaller, NameAwareMarshaller {}
ConvertersConfigurationHolder.setDefaultConfiguration(XML, new DefaultConverterConfiguration(encoding:'UTF-8'))