Skip to content

Instantly share code, notes, and snippets.

View lyhcode's full-sized avatar

Kyle Lin lyhcode

View GitHub Profile
@lyhcode
lyhcode / rmfile.vbs
Created October 5, 2011 03:20
刪除過期的檔案
'***********************
'刪除過期的檔案(VBScript)
'***********************
'天數
daysAgo = 3
'路徑
dirPath = "C:\\test"
@lyhcode
lyhcode / gist:1271820
Created October 8, 2011 03:40
Groovy using s3cmd upload file to amazon s3 aws.
cmd = "s3cmd put -P filename s3://contpub/filename"
proc = cmd.execute()
proc.waitFor()
println proc.in.text
@lyhcode
lyhcode / jrst2html.groovy
Created October 9, 2011 14:45
JRST rst2html usages
@Grab('org.nuiton.jrst:jrst:1.4')
import org.nuiton.jrst.*
def reader = new StringReader('''
Title
=====
Contents here.
Sub title
@lyhcode
lyhcode / html.py
Created October 12, 2011 14:50
Patch sphinx/writers/html.py for Chinese letters and spaces look feel
def visit_Text(self, node):
text = node.astext().replace("\n", '')
encoded = self.encode(text)
if self.protect_literal_text:
@lyhcode
lyhcode / build.gradle
Created October 29, 2011 01:02
Gradle jettyRun with jetty-env.xml
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
repositories {
mavenCentral()
}
dependencies {
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5'
@lyhcode
lyhcode / SimpleReadWriteSpecification.groovy
Created November 2, 2011 03:06
Gradle with Groovy and SpockFramework testing
import spock.lang.Specification
class SimpleReadWriteSpecification extends Specification {
def "Simple PLXML file read"() {
}
}
@lyhcode
lyhcode / Hello.java
Created November 2, 2011 07:19
Gradle + Spock Unit Test
package com.example;
public class Hello {
public String sayHello(String who) {
return "Hello, " + who;
}
}
@lyhcode
lyhcode / markdownj.groovy
Created November 13, 2011 01:21
Groovy + MarkdownJ (GrabResolver)
@GrabResolver(name='scala-tools', root='http://scala-tools.org/repo-releases')
@Grab('org.markdownj:markdownj:0.3.0-1.0.2b4')
import com.petebevin.markdown.MarkdownProcessor
def m = new MarkdownProcessor()
println m.markdown('''
Heading
=======
// PostgreSQL
@GrabConfig(systemClassLoader=true)
@Grab('postgresql:postgresql:9.0-801.jdbc4')
def sql = groovy.sql.Sql.newInstance(
"jdbc:postgresql://host.example.org/database",
"username", "password", "org.postgresql.Driver")
// MySQL
@GrabConfig(systemClassLoader=true)
@lyhcode
lyhcode / gist:1372738
Created November 17, 2011 08:58
Small Java Code Editor in Groovy + SwingBuilder
@Grab(group='net.sf.jedit-syntax', module='jedit-syntax', version='2.2.2')
import org.syntax.jedit.JEditTextArea
import org.syntax.jedit.tokenmarker.*
import groovy.swing.SwingBuilder
def mpanel
def editor
new SwingBuilder().edt {
frame(title:'Editor', pack: true, show: true, locationRelativeTo: null) {