Skip to content

Instantly share code, notes, and snippets.

@luoka
luoka / AESUtil.java
Last active August 28, 2018 06:18
AES加密解密
public class AESUtil
{
private static final Logger LOGGER = LoggerFactory.getLogger(AESUtil.class);
/**将二进制转换成16进制
* @param buf
* @return
*/
public static String parseByte2HexStr(byte buf[]) {
StringBuffer sb = new StringBuffer();
@luoka
luoka / prototype.js
Created April 1, 2014 01:07
javascript 原型链实现继承
function Person(){
this.name = "person name";
}
Person.prototype.showName = function(){
console.log(this.name);
}
function Student(){
this.name = "student name";
@luoka
luoka / callTest.js
Created April 1, 2014 01:06
javascript call方法说明
//function is object
//测试call方法,function.call(object, arguments...) ==> object.function(arguments...); 以object为上下文执行function方法
function add(a, b){
console.log(a + b);
}
function sub(a, b){
console.log(a - b);
}

Node 出现 uncaughtException 之后的优雅退出方案

Node 的异步特性是它最大的魅力,但是在带来便利的同时也带来了不少麻烦和坑,错误捕获就是一个。由于 Node 的异步特性,导致我们无法使用 try/catch 来捕获回调函数中的异常,例如:

try {
    fs.read('SOME_FILE_DOES_NOT_EXIST', function readCallback(err, content) {
        if (err) {
            throw err; // 抛出异常
 }
#!/usr/bin/perl
use strict;
chomp(my $filename=$ARGV[0]);
chomp(my $username=$ARGV[1]);
chomp(my $password=$ARGV[2]);
if (!$filename || !$username || !$password) {
print "USAGE: ./crypt.pl filename username password\n\n";
} else {
upstream some_app_server {
server 127.0.0.1:9393;
}
server {
listen 80;
server_name my-upload-endpoint.com ;
@luoka
luoka / gist:5370058
Created April 12, 2013 06:59
install cloud foundry vmc for windows x64
1.install Ruby and Rubygems
download ruby and install
run Start Command Prompt With Ruby
2.update rubygems
gem update --system
3.install vmc
gem install vmc
4.targets the PaaS Cloud Foundry
vmc target https://api.cloudfoundry.com
5.to show current target
@luoka
luoka / gist:5211372
Created March 21, 2013 07:52
cron usage
introduction:http://en.wikipedia.org/wiki/Cron;
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "00 09 * * 1-5 echo hello" >> mycron
#install new cron file
crontab mycron
rm mycron
@luoka
luoka / gist:5204046
Created March 20, 2013 11:43
Maven common commands
mvn clean
mvn eclipse:clean
mvn eclipse:eclipse
mvn package
mvn dependency:copy-dependencies -DoutputDirectory=/target/lib
mvn tomcat:run
mvn jetty:run
mvn clean tomcat:run -Dlog4j.debug=true
@luoka
luoka / gist:5166878
Created March 15, 2013 01:41
redis batch delete
Run in bash:
./redis-cli KEYS preffix* | xargs ./redis-cli DEL