Skip to content

Instantly share code, notes, and snippets.

@blocka
blocka / machine.js
Last active August 12, 2019 04:48
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@blocka
blocka / wait-for-subscription.ts
Last active November 24, 2020 18:08
waitForSubscription helper function for testing graphql subscriptions
export function waitForSubscription<TResult, TContext>(schema: GraphQLSchema, subscription: DocumentNode, context: TContext) {
return new Promise<TResult | ReadonlyArray<GraphQLError>>(async resolve => {
const iterator = await subscribe(schema, subscription, {}, context)
if (isAsyncIterable(iterator)) {
for await (const next of iterator) {
const val: ExecutionResult<TResult> = next
if (val.errors) resolve(val.errors)
@blocka
blocka / TabNav.js
Created November 13, 2017 09:33
Simple, flexible tabs
import set from 'lodash/set';
export default {
props: ['tabId'],
inject: ['tabs'],
render (h) {
const vnodes = this.$scopedSlots.default({
active: this.tabs.tabData.activeTab === this.tabId
});
@blocka
blocka / Modal.vue
Created November 8, 2017 16:49
Example modal
<template>
<div>
<div class="modal-mask" v-if="show" @click="requestClose && requestClose()">
<div class="modal-wrapper">
<div class="modal-container" @click.stop :style="{width: width + 'px'}">
<slot></slot>
</div>
</div>
</div>
</div>
@blocka
blocka / index.html
Last active October 2, 2017 16:39 — forked from adgelbfish/index.html
Array() vs new Array() (https://jsbench.github.io/#ff25ca136871d7d6af01c40381aabd52) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Array() vs new Array()</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@blocka
blocka / .babelrc
Last active September 14, 2016 15:13
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime", "es6-promise", "transform-vue-jsx", "transform-flow-strip-types"],
"comments": false
}
var i = 0;
var router = new (Backbone.Router.extend({
before: {
'someotherroute': function() {
},
'': function(fragment,args,next) {
setTimeout(function() {
@blocka
blocka / yomis.json
Last active December 15, 2015 16:49
JSON for daf and mishna yomi stuff
{
"Berachos":{
"dappim":"64",
"perakim":"9",
"mishnayot":[
9,
8,
6,
7,
5,