Skip to content

Instantly share code, notes, and snippets.

View yorkie's full-sized avatar
🎯
Focusing

Yorkie Makoto yorkie

🎯
Focusing
View GitHub Profile
@yorkie
yorkie / v8_try.rs
Created July 4, 2015 08:39
v8_try macros for rust
macro_rules! v8_try {
($expr:expr, $args:ident) => ({
let ret;
match $expr {
Ok(val) => {
ret = Some(val);
},
Err(err) => {
ret = None;
$args.GetReturnValue().SetWithBool(false)
var tls = require('tls');
var start = Date.now();
function connect() {
tls.connect({host:'imap.gmail.com', port:993} , function() {
console.log('connected', Date.now() - start);
});
}
var max = 50
@yorkie
yorkie / makefile
Created February 21, 2015 08:57
How to create a modular test suite in Makefile (also namely: using parameters in Makefile)
test:
ifneq ($(module),)
mocha /path/to/your/tests/$(module).js
else
mocha /path/to/your/tests/*.js
function parseQuerystring (key) {
var href = location.href;
var start = href.indexOf('?');
var obj = href.slice(start+1).split('&');
var ret = {};
obj.forEach(function (item) {
var vals = item.split('=');
var key = vals[0];
var val = decodeURI(vals[1]).replace(/\+/g, ' ');
ret[key] = val;
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
var multiline = function (f) {
return f.toString().split('\n').slice(1, -1).join('\n');
};
var data = multiline(function() {/*
<html>
<body>
<h1>Hello, Parallel World</h1>
</body>
</html>
@yorkie
yorkie / ghci-progress.hs
Created November 13, 2014 17:22
haskell exercise
import Data.Char
-- toUpperCase() --
map isUpper "abcDEF"
-- compute the number of containing lower/upper chars --
length (filter isLower "xxxXXXX")
-- will return 3
@yorkie
yorkie / generate-self-signed-certification.sh
Created November 6, 2014 08:22
how to create self-signed certification
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > cert.pem
@yorkie
yorkie / gen-ssh-key-for-mac.sh
Created October 16, 2014 04:29
generate ssh key for mac
ssh-keygen -t rsa -C "yorkiefixer@gmail.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
pbcopy < ~/.ssh/id_rsa.pub
pgclient.connect(function () {
pgclient.query('select distinct user_id, gender from users where gender == NULL', function (err, resukt) {
console.log(result.rows); // []
});
pgclient.query('select distinct user_id, gender from users where gender is NULL', function (err, result) {
console.log(result.rows); // [...]
});
});