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
async function main() { | |
const { body } = await fetch('https://jsonplaceholder.typicode.com/photos') | |
const streamIterator = new StreamChunkIterator(body.getReader()) | |
for await (const chunk of streamIterator) { | |
console.log(chunk) | |
} | |
console.log('Voilà!') | |
} |
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 | |
# usage: cmd | osa_notify.sh | |
/usr/bin/osascript 3<&0 <<'APPLESCRIPT' | |
on run argv | |
set stdin to do shell script "cat 0<&3" | |
display notification stdin with title "osa_notify" sound name "Default" | |
return stdin | |
end run | |
APPLESCRIPT |
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
setTimeout(function() { | |
console.log('queue a print AFTER a second') | |
}, 1000) | |
setInterval(function() { | |
console.log('queue a print EVERY second') | |
}, 1000) | |
setImmediate(function() { | |
console.log('queue a print in the next event loop tick but after IO tasks are done') |
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 count = 0 | |
var countWithDelay = 0 | |
function recurse() { | |
console.log('recurse: %d', count) | |
if (count++ === 100) return | |
setImmediate(recurse) | |
} |
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 expect = require('chai').expect | |
var targetFactory = require('../target') | |
describe('testing targets', function () { | |
var target | |
it('does something sync', function () { | |
expect(target()).to.equal('123') | |
}) | |
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
aws ec2 modify-instance-attribute --profile [profile] --region [region] --instance-id [instanceid] --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\",\"Ebs\":{\"DeleteOnTermination\":false}}]" |
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
moment.utc(new Date()).format('YYYY-MM-DDTHH:mm:ss.SSSSSSSSS[Z]') |
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/sh | |
sub="/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | |
target=$1 | |
if [[ -z $target ]] | |
then | |
target=$(pwd) | |
fi |
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 express = require('express') | |
const browserifyMiddleware = require('browserify-middleware') | |
const path = require('path') | |
browserifyMiddleware.settings('transform', [ | |
[{ presets: ['es2015', 'react', 'stage-2']}, 'babelify'] | |
]) |
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 loEndsWith = require('lodash.endsWith') | |
console.log('naive:', endsWith('asdsds😀', '?')) | |
console.log('naive:', endsWith('asdsds😀?', '?')) | |
console.log('naive:', endsWith('asdsds😀', '😀')) | |
console.log('mozilla polyfill:', mozEndsWith('asdsds😀', '?')) | |
console.log('mozilla polyfill:', mozEndsWith('asdsds😀?', '?')) | |
console.log('mozilla polyfill:', mozEndsWith('asdsds😀', '😀')) |
NewerOlder