This file contains 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
// instead of ... | |
var writestream = new stream.Stream() | |
writestream.writable = true | |
var readstream = new stream.Stream() | |
readstream.readable = true | |
// wish we could do |
This file contains 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
# node amazon/s3/upload.js --bucket pie-18 --file README.md | |
Region: us-east-1 | |
EndPoint: s3.amazonaws.com | |
AccessKeyId: [removed] | |
SecretAccessKey: [removed] | |
AwsAccountId: [removed] | |
Bucket: pie-18 | |
Filename: README.md | |
File Size: 2644 |
This file contains 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
node_modules | |
*.log | |
*~ |
This file contains 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 str = "a:0,1,2,3|b:4,5,6|c:0,2"; | |
var a = {}; | |
str.split('|').forEach(function(v) { | |
var s = v.split(':'); | |
a[s[0]] = s[1].split(','); | |
}); | |
console.log(a); |
This file contains 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
// middleware which needs access to 'app' | |
app.use(function(req, res, next) { | |
myOtherFunctionWhichNeedsApp(app, req, res, next); | |
}); |
This file contains 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 alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
var alphabetLength = alphabet.length; | |
var i, rnd, trips = 1000000000; | |
var d1 = new Date(); | |
console.log(d1); | |
for (i = 0; i < trips; i++) { | |
rnd = Math.floor(Math.random() * alphabetLength); | |
alphabet.substring(rnd, rnd + 1); |
This file contains 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
package main | |
import ( | |
"flag" | |
"os" | |
"http" | |
"fmt" | |
"io/ioutil" | |
) |
This file contains 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
// Current Code | |
r, err := http.DefaultClient.Do(&req) | |
if err != nil { | |
return nil, err | |
} | |
function_dowork_that_also_calls_r_body_close(r) | |
// My Thoughts |
This file contains 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
package main | |
import ( | |
"strconv" | |
"http" | |
"io" | |
"log" | |
"memcache" | |
) |
This file contains 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
#!/usr/bin/env node | |
var base_str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"; | |
console.log( number_to_base(process.argv[2], base_str) ); | |
function number_to_base(n, str) { | |
if ( n === 0 ) return "0"; | |
var b = ''; | |
while ( n > 0 ) { |
NewerOlder