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
const log = require('single-line-log').stdout | |
let i = 0 | |
const id = setInterval(() => { | |
log(i++) | |
if (i === 100) { | |
clearInterval(id) | |
log.clear() | |
log('done\n') |
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
touch .npmrc; grep -q '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' .npmrc || echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc |
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
'use strict'; | |
const http = require('http'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
let i = 0; | |
const server = http.createServer((req, res) => { |
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
'use strict'; | |
const timestamp = 'timestamp: "{{timestamp}}"'; | |
const title = 'title: "{{title}}"'; | |
const file = 'file: "{{file}}"'; | |
const line = 'line:"{{line}}"'; | |
const method = 'method: "{{method}}"'; | |
const message = 'message: "{{message}}"'; | |
const jsonlogger = require('tracer').console({ | |
format: `{${timestamp},${title},${file}, ${line},${method},${message}}` |
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
# Created by .ignore support plugin (hsz.mobi) | |
### Node template | |
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
# Runtime data | |
pids | |
*.pid |
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
#!/bin/bash | |
# -n => test only | |
# rename -n 's/\.sample$//' *.sample | |
# Do it for real | |
rename 's/\.sample$//' *.sample |
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
// https://github.com/cthackers/JSProfiler/blob/master/test.html | |
function readable(bytes, precision) { | |
var kilobyte = 1024, | |
megabyte = kilobyte * 1024, | |
gigabyte = megabyte * 1024, | |
terabyte = gigabyte * 1024; | |
precision = precision || 2; | |
if ((bytes >= 0) && (bytes < kilobyte)) { | |
return bytes + ' B'; | |
} else if ((bytes >= kilobyte) && (bytes < megabyte)) { |
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 sharp = require('sharp'); | |
var fs = require('fs'); | |
// Read image data from readableStream, resize and write image data to writableStream | |
for (var i=0; i < 100; i++) { | |
var rs = fs.createReadStream('./direct.png'); | |
var ws = fs.createWriteStream(`./thumbs/direct-thumb-${i}.png`); | |
rs.pipe(sharp() | |
.resize(437, 315) |
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
// Does (still) have bad performance. But think can be fixed? | |
package main | |
import "fmt" | |
import "github.com/nfnt/resize" | |
import "github.com/rwcarlsen/goexif/exif" | |
import "net/http" | |
import "strings" | |
import "strconv" |
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 ( | |
"github.com/nfnt/resize" | |
"image/png" | |
"log" | |
"os" | |
) | |
func main() { |