Skip to content

Instantly share code, notes, and snippets.

View mxstbr's full-sized avatar
💅
writing JavaScript

Max Stoiber mxstbr

💅
writing JavaScript
View GitHub Profile
@mxstbr
mxstbr / grab.js
Last active August 21, 2020 18:47 — forked from SirPepe/grab.js
// Benötigt PhantomJS. Benutzung: $ phantomjs grab.js
var page = require('webpage').create();
page.viewportSize = {
width: 10000, // A0: 9933
height: 15000 // A0: 14043
};
page.open('http://localhost/~peter/map/map.html', function(){
setTimeout(function(){
@mxstbr
mxstbr / asyncify.js
Last active March 13, 2018 09:14 — forked from ForbesLindesay/iter.js
A reusable utility to turn a callback-based listener into an async iterable
// @flow
// Turn a callback-based listener into many async iterators without buffering
import { $$asyncIterator } from 'iterall';
type Listener = ((arg: any) => void) => Promise<any>;
const defaultOnError = (err: Error) => {
throw new Error(err);
};

First, start Chrome and open the page you want to profile:

./chrome --js-flags=”--prof” --no-sandbox http://localhost:8080/index.html

Note: This page should do things on-load, simply close Chrome once it's done

Then preprocess the biggest .log file you get: (since the biggest one should be from the main renderer):

@mxstbr
mxstbr / send-email.js
Created November 13, 2017 17:06
A send email util for Postmark
import postmark from 'postmark';
const debug = require('debug')('send-email');
const stringify = require('json-stringify-pretty-compact');
let client;
if (process.env.POSTMARK_SERVER_KEY) {
client = new postmark.Client(process.env.POSTMARK_SERVER_KEY);
} else {
console.log(
'\nℹ️ POSTMARK_SERVER_KEY not provided, debug mode enabled. Will log emails instead of actually sending them.'
import createLogger from 'graphql-log';
let list = [];
const logExecutions = createLogger({
logger: (name) => {
list.push(name);
fs.writeFileSync('resolvers.js', JSON.stringify(list, null, 2));
},
});

Keybase proof

I hereby claim:

  • I am mxstbr on github.
  • I am mxstbr (https://keybase.io/mxstbr) on keybase.
  • I have a public key whose fingerprint is 78D3 829B 9CE0 7924 2C15 4E38 673F 4304 C9E3 A511

To claim this, I am signing this object:

@mxstbr
mxstbr / README.md
Last active September 1, 2017 02:02
Syntax highlighting ESNext (inc. JSX) for Keynote presentations

Syntax Highlighting ESNext (inc. JSX)

To get syntax highlighting for ESNext (including JSX), you need to have pygments-lexer-babylon installed:

pip install pygments pygments-lexer-babylon

Now when you run pygmentize on a .jsx file it'll automatically use the new lexer! 🎉

@mxstbr
mxstbr / esnextbin.md
Created March 2, 2016 10:27
esnextbin sketch
@mxstbr
mxstbr / esnextbin.md
Created March 1, 2016 07:54
esnextbin sketch

We're excited to have you attend one of our workshops! Here's a JavaScript (re)fresher to help you get up-to-speed on some features of the language we'll be using.

Let and Const

JavaScript has always had var:

var name = 'Ryan'