Skip to content

Instantly share code, notes, and snippets.

@joakin
joakin / queue-bulk.test.js
Created December 17, 2018 18:33
Bulk test that fails because JobTimeout doesn't kickstart the queue again
"use strict";
const assert = require("../utils/assert.js");
const { Queue } = require("../../lib/queue");
const errors = require("../../lib/errors");
const { QueueItem } = require("../../lib/queueItem");
const logger = { log: (level, data) => {} };
const BBPromise = require("bluebird");
BBPromise.config({
cancellation: true
@joakin
joakin / CurrentWithPipes.elm
Last active September 15, 2018 16:53
Elm canvas api examples
view ( count, fps ) =
Canvas.toHtml
( w, h )
[ Attributes.style "border" "2px solid red" ]
[ shapes [ rect ( 0, 0 ) w h ] |> fill Color.white
, shapes
[ rect ( -100, -150 ) 40 50
, circle ( 100, 100 ) 80
]
|> lineWidth 5
@joakin
joakin / Architecture and Organizational Design.md
Created August 7, 2018 14:58
SE-Radio Episode 331: Kevin Goldsmith on Architecture and Organizational Design
@joakin
joakin / AnimatedGrid.elm
Created July 29, 2018 11:52
AnimatedGrid.elm
module Examples.AnimatedGrid exposing (main)
{-
Adaptation from @mattdesl's gist
https://gist.github.com/mattdesl/cb27d1285d4ceaa091094bad92ebd7fb
-}
import AnimationFrame exposing (times)
import Html exposing (Html)
import Html.Events exposing (onClick)
@joakin
joakin / common-friends-coding-exercise.md
Last active June 1, 2018 12:33
Common friends - coding exercise

Common friends - coding exercise

Imagine we have data for users of a social network. Users can befriend other users of the network.

We want to implement a feature where a user Alice visiting another user Bob, would see which friends Alice and Bob have in common.

Write a script/function/program in your preferred programming language that takes two user names and gives back a list of the common friends between those users.

@joakin
joakin / users.json
Last active May 30, 2018 18:30
JSON users with friends
This file has been truncated, but you can view the full file.
[
{
"id": 847,
"name": "Summer Donnelly",
"friends": [
780,
671,
516,
50,
859,
@joakin
joakin / generate-profiles.js
Last active May 30, 2018 17:59
Faker.js user profiles
const profiles = 1000;
Array(profiles).fill(null).map((_, i) => {
const id = i
const name = faker.name.findName()
let friends = []
while (friends.length < 200) {
const friendId = Math.floor(Math.random()*profiles)
if (friendId !== id && !friends.includes(friendId)) friends.push(friendId)
}
@joakin
joakin / qunit-test.txt
Created May 8, 2018 09:21
Running a qunit test that requires a non-existent file
qunit-cli-bug => ls
node_modules package.json test.js yarn.lock
qunit-cli-bug => jq .scripts package.json
{
"test": "qunit test.js"
}
qunit-cli-bug => cat test.js
const test = require("./index.js");
QUnit.module("Test");
@joakin
joakin / test.js
Created May 7, 2018 16:22
QUnit test with promise
QUnit.test( 'checking bad reference', function ( assert ) {
assert.expect(1);
return this.referencesGateway.getReference( '#cite_note-bad', this.page ).catch( function ( err ) {
assert.ok( err === ReferencesGateway.ERROR_NOT_EXIST, 'When bad id given false returned.' );
return null;
} );
} );
@joakin
joakin / setting-up-an-ab-test.md
Last active June 7, 2018 08:30
Things we currently do to set up an A/B test as an engineer

Things we currently do to set up an A/B test as an engineer

Planning

  • Review the tasks
    • Understand what is being asked to be tracked and why
      • Analyze feasibility of implementation provide feedback and ask questions with Product and Analysts
  • Flesh out the technical information (see Development) of such tasks
  • Ensure there are separate tasks created for implementation of tracking, and