Skip to content

Instantly share code, notes, and snippets.

nikku / TEST_DSL.kt
Last active Sep 21, 2017
Quick hack of a readable DSL for writing assertions in Kotlin
View TEST_DSL.kt
import kotlin.test.assertEquals
fun <T> equal(expected: T) : (T) -> Unit {
return { t ->
assertEquals(t, expected);
infix fun <T> T.should(matcher: (T) -> Unit) {
timdorr /
Created Feb 11, 2017
Tesla App is now React Native!
package com.teslamotors.TeslaApp;
import com.BaiduMaps.BaiduPackage;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;

Parens And Performance

Years ago, some smart folks that worked on JS engines realized that not all JS that's loaded into a page/app initially is needed right away. They implemented JIT to optimize this situation.

JIT means Just-In-Time, which means essentially that the engine can defer processing (parsing, compiling) certain parts of a JS program until a later time, for example when the function in question is actually needed. This deferral means the engine is freer to spend the important cycles right now on the code that's going to run right now. This is a really good thing for JS performance.

Some time later, some JS engine devs realized that they needed to get some hints from the code as to which functions would run right away, and which ones wouldn't. In technical speak, these hints are called heuristics.

So they realized that one very common pattern for knowing that a function was going to run right away is if the first character before the function keyword was a (, because that usually m

rcknr /
Last active Jul 19, 2018
Using Let's Encrypt certificates with Amazon API Gateway

##Using Let's Encrypt certificates with AWS API Gateway

Before starting off with API Gateway set up it's worth mentioning that certificate configuration for this particular service is so far isn't well integrated, therefore different from other AWS services. Despite it using CloudFrount to serve on custom domains it won't let you customize distributions it creates, however all the limitations of CloudFront naturally apply to API Gateway. The most important in this case is the size of the key, which is limited by 2048 bit. Many tutorials provide ready to use terminal commands that have the key size preset at 4096 bit for the sake of better security. This won't work with API Gateway and you'll get an error message about certificate's validity or incorrect chain which won't suggest you the real cause of the issue. Another consideration is that to add a custom domain to API Gateway you have to have a certif

substack / how_i_write_tests_for_node_and_the_browser.markdown
Last active Sep 15, 2021
how I write tests for node and the browser
View how_i_write_tests_for_node_and_the_browser.markdown

In node I use simple test libraries like tap or tape that let you run the test files directly. For code that needs to run in both the browser and node I use tape because tap doesn't run in the browser very well and the APIs are mostly interchangeable.

The simplest kind of test I might write in test/ looks like:

var test = require('tape');
var someModule = require('../');

test('fibwibblers and xyrscawlers', function (t) {