Skip to content

Instantly share code, notes, and snippets.

@johndaley-me
johndaley-me / devops_bamboo_testem.sh
Created January 29, 2016 19:49
Devops script for running testem inside virtual display on Bamboo node.
echo 'Running tests in Xvfb virtual display for Firefox'
xvfb-run testem ci --reporter=xunit --launch=firefox
# ensure that non-zero is returned for any failures
# because xvfb-run may return 0 even in case of a test failure
if [ -r test-reports/testem.xml ]; then
# check results for failures
failures=$(grep --count '<failure' ./test-reports/testem.xml)
if [ $failures -eq 0 ]; then
@johndaley-me
johndaley-me / httpry.sh
Last active March 28, 2016 16:13
Capture network requests oracle linux
# install epel repo
# yum -y install httpry
httpry -i eth0
# Format options:
# httpry -i eth0 -f 'host,request-uri'
# see https://github.com/jbittel/httpry/blob/master/doc/format-string
@johndaley-me
johndaley-me / promise-vs-await.js
Last active July 23, 2017 02:09
Promise vs await
// Promise
doSomethingAsync
.then((value) => console.log(value));
.catch((error) => console.log(error));
// or instead use await
try {
const value = await doSomethingAsync();
console.log(value);
} catch (error) {
@johndaley-me
johndaley-me / overusing-await.js
Last active July 23, 2017 02:20
Overusing await
function findFooById(id) {
// pretend this is a DB query or something asynchronous
return Promise.resolve({
id,
name: 'Foo'
});
}
async function findFoo1() {
console.log('finding foo 1');
const rval = await findFooById(1);
@johndaley-me
johndaley-me / promises-only.js
Last active July 23, 2017 02:21
Promises only
function findFooById(id) {
// pretend this is a DB query or something asynchronous
return Promise.resolve({
id,
name: 'Foo'
});
}
function findFoo1() {
console.log('finding foo 1');
return findFooById(1);
@johndaley-me
johndaley-me / extra-promise-await.js
Created July 23, 2017 02:15
Extra Promise and await
// these two functions are conceptually equivalent
async function findFoo1() {
console.log('finding foo 1');
const rval = await findFooById(1);
console.log('I have foo 1');
return rval;
}
function findFoo1() {
console.log('finding foo 1');
return findFooById(1).then((foo1) => {
@johndaley-me
johndaley-me / cloudSettings
Last active January 19, 2018 19:27
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-01-19T19:27:44.276Z","extensionVersion":"v2.8.7"}