(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| 'use strict' | |
| // see: https://github.com/nodejs/node/pull/6157 | |
| var startTime = process.hrtime() | |
| var startUsage = process.cpuUsage() | |
| // spin the CPU for 500 milliseconds | |
| var now = Date.now() | |
| while (Date.now() - now < 500) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| var isoCountries = { | |
| 'AF' : 'Afghanistan', | |
| 'AX' : 'Aland Islands', | |
| 'AL' : 'Albania', | |
| 'DZ' : 'Algeria', | |
| 'AS' : 'American Samoa', | |
| 'AD' : 'Andorra', | |
| 'AO' : 'Angola', | |
| 'AI' : 'Anguilla', | |
| 'AQ' : 'Antarctica', |
| #!/usr/bin/env bash | |
| # This script prints out all of your Redis keys and their size in a human readable format | |
| # Copyright 2013 Brent O'Connor | |
| # License: http://www.apache.org/licenses/LICENSE-2.0 | |
| human_size() { | |
| awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } ' | |
| } |
| // Encrypt where jo is input, and query is output and ENCRPYTION_KEy is key | |
| byte[] input = jo.toString().getBytes("utf-8"); | |
| MessageDigest md = MessageDigest.getInstance("MD5"); | |
| byte[] thedigest = md.digest(ENCRYPTION_KEY.getBytes("UTF-8")); | |
| SecretKeySpec skc = new SecretKeySpec(thedigest, "AES/ECB/PKCS5Padding"); | |
| Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); | |
| cipher.init(Cipher.ENCRYPT_MODE, skc); | |
| byte[] cipherText = new byte[cipher.getOutputSize(input.length)]; |