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://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html | |
// MessageDisgest | |
// - Take input text/bytes and produce a fixe length digest | |
// - MD5, MD2, msgDigest-1 | |
// | |
// Cipher | |
// - Take cleartext text and key and produce a ciphertext | |
// - Symmetric uses secret key (fast): DES, 3DES are fixed key length | |
// - Asysmmetric uses public/private key (slow): AES, RSA are variable length |
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
# Set bash shell prompt - show current working dir and shell name in two lines. | |
# The '\e]2;\w\a' will set and update the term title bar | |
export PS1='\e]2;\w\a\e[32m\]\u@\h:\e[33m\]\w\e[0m\] | |
$(basename $SHELL)> ' | |
# Set kshshell prompt - show current working dir and shell name in two lines. | |
export PS1='$USER@$HOSTNAME:$PWD | |
$(basename $SHELL)> ' | |
# Grep dir recursively with certain file types only |
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). |
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
// 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
/* 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
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
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
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
@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.* |