Skip to content

Instantly share code, notes, and snippets.


Koen van Gilst vnglst

View GitHub Profile
View tweet-understandable-regexes.js
async function validatePassword(password: string): string[] {
let errors = []
// 1. Don't regex for things you can trivially express in code
// -----------------------------------------------------------
// For example, we could have written this as `/^.{0,7}$/` but that's not
// nearly as clear as checking the length of the string.
if (password.length < 8) {
errors.push("Password must be at least 8 characters long")
antony /
Last active Aug 30, 2020
Auth0 SSR Compatible Integration with Sapper
npm install --save express express-openid-connect
View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
mayel / up
Last active Mar 9, 2020
up: script to keep your Mac up-to-date (both OS and Homebrew updates) via the command line
View up
# up - script to keep your Mac up-to-date (both OS and Homebrew updates) via the command line
# run thus to to install: cd /usr/local/bin && curl -s -O && chmod 755 /usr/local/bin/up
# and then run it anytime by simply entering the command: up
# By based on a script by
# homebrew
thevangelist / my-component.spec.js
Created Aug 4, 2016
The only React.js component test you'll ever need (Enzyme + Chai)
View my-component.spec.js
import React from 'react';
import { shallow } from 'enzyme';
import MyComponent from '../src/my-component';
const wrapper = shallow(<MyComponent/>);
describe('(Component) MyComponent', () => {
it('renders without exploding', () => {
thomasbandit / countries.json
Last active Dec 31, 2019
ISO 3166-1 Country List in Dutch / ISO 3166-1 Landen lijst in Nederlands JSON
View countries.json
"name": "Afghanistan",
"short_name": "AF",
"calling_code": "93"
"name": "Åland",
"short_name": "AX",
"calling_code": "358"
mjackson / createBinding.js
Last active Apr 29, 2016
A workaround for the lack of a promise cancelation API
View createBinding.js
* Registers the given callback to be called in the node.js callback
* style, with error as the first argument, when the promise resolves.
* Also, returns a function that may be used to prevent the callback
* from ever being called. Calling the returned function is synonymous
* with saying "I no longer care about the resolution of this promise,
* even if it fails."
* Since there is no provision in the promise spec for cancel/abort
View tape-template.js
// A Unit test template for Tape
// See 5 Questions every unit test must answer:
import test from 'tape';
test('What are you testing?', assert => {
const msg = 'what should it do?'
const actual = 'what was the output?';
View sam-questions.js
this.ycQuestions = [
"So what are you working on?",
"Have you raised funding?",
"What makes new users try you?",
"What competition do you fear most?",
"What’s the worst thing that has happened?",
"Will you reincorporate as a US company?",
"What’s an impressive thing you have done?",
"Where is the rocket science here?",
"Why did you pick this idea to work on?",
brandondurham / styles.less
Last active Aug 1, 2020
Using Operator Mono in Atom
View styles.less
* Using Operator Mono in Atom
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
* Theme from the screenshot (