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
function createPromise(name){ | |
return new Promise(function(resolve, reject){ | |
setTimeout(function(){ | |
if (Date.now()%2 === 0) { | |
console.log(name+" is reolved"); | |
resolve(name+"_success"); | |
}else{ | |
console.log(name+" is rejected"); | |
reject(name+"_fail"); | |
} |
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
function parse(val){ | |
return Promise.resolve().then(function(){ | |
return JSON.parse(val); | |
}); | |
} | |
function parse2(val){ | |
return new Promise(function(resolve, reject){ | |
try{ | |
resolve(JSON.parse(val)); |
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
encrypt | |
------- | |
$ echo "Hello World" | openssl enc -e -des -base64 -out encrypted -k myKey | |
result | |
------- | |
$ cat encrypted | |
U2FsdGVkX19pZy6kjZ4GTbTNeKeI1lWvoLjrpBqy0bw= | |
decrypt |
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
# !/bin/sh | |
echo 'if(typeof EventEmitter === "undefined") EventEmitter = require("events");' > src.js | |
browserify src.js -o dist.js | |
nodeversion=`node -v` | |
browsrifyversion=`browserify -v` | |
cat << EOF > version.txt | |
// This file is created by Browserify(http://browserify.org/) | |
// Node version : $nodeversion | |
// Browsreify version : $browsrifyversion |
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
keytool -exportcert -alias alias -keypass keypass -keystore sample_keystore.jks -storepass storepass -file KEYSTORE.der | |
keytool -importkeystore -srckeystore sample_keystore.jks -srcstoretype JKS -srcstorepass srcstorepass -srcalias srcalias -srckeypass srckeypass \ | |
-destkeystore KEYSTORE.p12 -deststoretype PKCS12 -deststorepass deststorepass -destalias destalias -destkeypass destkeypass -noprompt |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Google login example</title> | |
<script src="https://apis.google.com/js/client:platform.js" async defer></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<style media="screen"> | |
h3 { | |
color:green; | |
} |
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
var Utils = {}; | |
var deferApply = function() { | |
var args = Array.prototype.slice.apply(arguments), | |
f = args[0], | |
realArgs = args.slice(1) | |
; | |
return new Promise(function(done, reject) { | |
return f.apply(null, [done, reject].concat(realArgs)); | |
}); | |
}; |
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
For ruby + mysql development | |
### Download | |
* Vagrant 1.6.5 | |
https://www.vagrantup.com/downloads.html | |
* ChefDK | |
http://downloads.getchef.com/chef-dk/mac/#/ |
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
[xx@msg-ap01 ~]$ cat /etc/redhat-release | |
CentOS release 6.4 (Final) | |
[xx@msg-ap01 ~]$ echo $SHELL | |
/bin/bash | |
------------------ | |
inline script with double quotation | |
[xx@msg-ap01 ~]$ /bin/bash -c "echo $#" a b c |
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
function twoDigit(int) { | |
return (int < 10) ? ('0' + int) : ('' + int); | |
} | |
ObjectId.prototype.getDateObj = function() { | |
var d = new Date(parseInt(this.str.slice(0,8), 16)*1000); | |
d.setTime(d.getTime() + d.getTimezoneOffset()*60*1000); | |
return d; | |
}; |