This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, java | |
res = sys.argv[1] | |
cl = java.lang.Thread.currentThread().getContextClassLoader() | |
url = cl.getResource(res) | |
print(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is for Java scripting engine. | |
// Print all global variables! | |
for (i in this) { println(i + '=' + this[i]); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.quartz-scheduler:quartz:2.1.6') | |
@Grab('org.slf4j:slf4j-simple:1.7.1') | |
import org.quartz.* | |
import org.quartz.impl.* | |
import org.quartz.jobs.* | |
import static org.quartz.DateBuilder.* | |
import static org.quartz.JobBuilder.* | |
import static org.quartz.TriggerBuilder.* | |
import static org.quartz.CalendarIntervalScheduleBuilder.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.thegeekstuff.com/2009/07/linux-apache-mod-ssl-generate-key-csr-crt-file | |
# openssl genrsa -des3 -out www.thegeekstuff.com.key 1024 | |
Generating RSA private key, 1024 bit long modulus | |
.......................................++++++ | |
...................................................++++++ | |
e is 73547 (0x01001) | |
Enter pass phrase for www.thegeekstuff.com.key: | |
Verifying - Enter pass phrase for www.thegeekstuff.com.key: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS TEST; | |
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255)); | |
INSERT INTO TEST VALUES(1, 'Hello'); | |
INSERT INTO TEST VALUES(2, 'World'); | |
SELECT * FROM TEST ORDER BY ID; | |
UPDATE TEST SET NAME='Hi' WHERE ID=1; | |
DELETE FROM TEST WHERE ID=2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package it.data; | |
import java.util.Date; | |
import javax.persistence.Entity; | |
import javax.persistence.Id; | |
@Entity | |
public class User { | |
@Id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Usage | |
groovy tzconverter.groovy '2012-10-24 00:00 EST' | |
groovy tzconverter.groovy '2012-10-24 00:00 CST' EST | |
groovy tzconverter.groovy '2012-10-24 00:00 MST' EST | |
groovy tzconverter.groovy '2012-10-24 00:00 PST' EST | |
groovy tzconverter.groovy '2012-10-24 00:00 EDT' EST | |
*/ | |
fromDt = args[0] | |
toTz = args.length > 1 ? args[1] : TimeZone.getDefault().getID() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String variable substitutions | |
def parseVariableNames(String text) { | |
def names = [] | |
def pos = 0, max = text.length() | |
while (pos < max) { | |
pos = text.indexOf('${', pos) | |
if (pos == -1) | |
break | |
def end = text.indexOf('}', pos + 2) | |
if (end == -1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# String replace on a file, or all files in a directory | |
# Author: Zemian Deng 10/26/2012 | |
# | |
# Usage: | |
# ./replace.sh my_file localhost `hostname` | |
# ./replace.sh my_dir localhost `hostname` | |
# DRY=1 ./replace.sh my_dir localhost `hostname` | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Number comparison: [[ -gt, -ge, -lt, -le ]] | |
# Number comparison: (( <, <=, >, >= )) | |
# String comparison: [[ ==, != ]] | |
# String comparison: -z zero_length_string, -n not_zero_length_string | |
# String comparison: | |
[[ $a == z* ]] # True if $a starts with an "z" (pattern matching). | |
[[ $a == "z*" ]] # True if $a is equal to z* (literal matching). | |
[ $a == z* ] # File globbing and word splitting take place. | |
[ "$a" == "z*" ] # True if $a is equal to z* (literal matching). |