org.apache.commons.codec.binary.Base64

Base64.decodeBase64(str)

Advertisements

[java] Cipher

javax.crypto.Cipher

Encrypt

Cipher cipher = Cipher.getInstance( "AES/CBC/PKCS5Padding" );

cipher.init(Cipher.ENCRYPT_MODE, key);

byte [] cipherBytes = cipher.doFinal(plainBytes);

Decrypt

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

cipher.init(Cipher.DECRYPT_MODE,key);

byte [] plainBytesDecrypted = cipher.doFinal(cipherBytes);

ref : http://www.pixelstech.net/article/1439554008-Java-Cipher-encryption-decryption-example

 

 

vim ctags

Overview

Support 41 languages

Installation

sudo apt-get install exuberant-ctags

Generate tags file

ctags -R --exclude='.git' .

vim command

Ctrl+] – go to definition
Ctrl+T – Jump back from the definition.

ref : http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks

, http://benoithamelin.tumblr.com/post/15101202004/using-vim-exuberant-ctags-easy-source-navigation

[ python ] OptionParser

from optparse import OptionParser

parser = OptionParser()
parser.add_option("-f", "--file", dest="filename")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")

(options, args) = parser.parse_args()

options.filename

options.verbose

ref : https://docs.python.org/2/library/optparse.html

memcached

sudo apt-get install memcached

Default URL is http://localhost:11211

Test get stats

telnet localhost 11211

stats items

Test get key

telnet localhost 11211

stats cachedump [number] 100

get

telnet localhost 11211

get [key] 100

set

set [key] 0 900 9
memcached

flag → 0

exptime → 900 (expiry time in seconds)

bytes → 10 (size of data balue in bytes)

linux get command

echo "get [key]" | nc localhost 11211

ref : http://stackoverflow.com/questions/19560150/get-all-keys-set-in-memcached

 

Flash

telnet localhost 11211

flush_all