Skip to content

Instantly share code, notes, and snippets.

🍿
Software developer @ Elastic working on Kibana. Previously @ NodeSource, IBM.

Patrick Mueller pmuellr

Block or report user

Report or block pmuellr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pmuellr
pmuellr / async-early-return.js
Last active Jul 3, 2018
see what async functions return when returning early, and after an await
View async-early-return.js
'use strict'
async function delay (ms) {
return new Promise((resolve, reject) => setTimeout(resolve, ms))
}
async function foo (returnEarly) {
if (returnEarly) return new Date()
await delay(1000)
@pmuellr
pmuellr / throwing-catching-logging.js
Created May 10, 2018
see what stack traces look like for nested async await calls
View throwing-catching-logging.js
'use strict'
const states = 'abcde'.split('') // [ 'a', 'b', ... ]
async function main () {
for (let state of states) {
try {
await a(state)
} catch (err) {
console.log(`state: ${state}`, err)
@pmuellr
pmuellr / nscm-network-debugging.md
Last active Apr 12, 2018
nscm network debugging
View nscm-network-debugging.md

nscm network debugging

HTTP(S)_PROXY env vars

$ set | grep -i HTTP

print nscm config

@pmuellr
pmuellr / weather-data-info.txt
Created Jan 2, 2018
weather data from api.weather.gov
View weather-data-info.txt
weather forecast from api.weather.gov:
given geolocation:
GET https://api.weather.gov/points/35.6912,-78.8012
extract:
properties.forecastGridData: eg, https://api.weather.gov/gridpoints/RAH/67,53
properties.relativeLocation.properties.city, eg, "Holly Springs"
View observable-object.js
'use strict'
module.exports = create
// Observable Objects are objects which contain properties for which you can
// observe changes.
//
// To create an ObservableObject, use:
// observableObject = ObservableObject.create()
//
@pmuellr
pmuellr / rpromise.js
Last active Sep 26, 2017
Promise class that returns promises that can be directly resolved or rejected via `.resolve(data)` or `.reject(data)`
View rpromise.js
'use strict'
// prints "0ms", then "1000ms", then "2000ms", ...
function main () {
for (let i = 0; i < 5; i++) {
const pr = new RPromise()
const millis = i * 1000
setTimeout(() => pr.resolve(`${millis}ms`), millis)
pr.then(data => console.log(data))
View profile.d.ts
interface Profile {
meta: Meta
nodes: Node []
scripts: Script []
pkgs: Pkg []
urlBase: string // common full url across packages and mainModule
totalTime: number // microseconds
maxSelfTime: number // microseconds
maxTotalTime: number // microseconds
}
@pmuellr
pmuellr / sample.cpuprofile
Created Jul 27, 2017
node cpu profile that chrome won't load
View sample.cpuprofile
{
"profile": {
"nodes": [
{
"id": 1,
"callFrame": {
"functionName": "(root)",
"scriptId": "0",
"url": "",
"lineNumber": -1,
@pmuellr
pmuellr / styles.less
Last active May 9, 2018
atom personal style sheet in ~/.atom/styles.less
View styles.less
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@pmuellr
pmuellr / atom-styles.less
Created Apr 28, 2017
some personal style settings for Atom that do some fun stuff
View atom-styles.less
/* your personal stylesheet */
atom-text-editor {
/* comments are white on green */
.syntax--definition.syntax--comment,
.syntax--comment.syntax--line,
.syntax--comment.syntax--block {
background-color: green;
color: white;
}
You can’t perform that action at this time.