Skip to content

Instantly share code, notes, and snippets.

View vaclavbohac's full-sized avatar

Vaclav Bohac vaclavbohac

View GitHub Profile
@vaclavbohac
vaclavbohac / example.js
Created January 18, 2018 13:37
Getting visualization object type
// Assuming ES6
import * as GoodData from 'goodddata';
const uri = '/gdc/md/la84vcyhrq8jwbu4wpipw66q2sqeb923/obj/349238';
GoodData.xhr.get(uri).then((object) => {
console.log(object.visualization.content.type);
});
@vaclavbohac
vaclavbohac / snapshot-testing-experience.md
Last active October 25, 2017 06:31
Snapshot testing experience

Pros

  • helps very fast to cover complex test cases
  • saves a lot of typing (generally worth to test generated structures)

Cons

  • renaming of files, functions or describes leads to changes that are hard to verify
    • snapshots with old names are deprecated
    • snapshots with new names are generated
    • you don't have a diff between the two
  • first run of the tests generates snapshot, so it's impossible to do red-green-refactor properly
  • you can fake it out by saving first snapshot empty, but you have to think about it
@vaclavbohac
vaclavbohac / double-clap.ts
Created April 16, 2017 09:11
Double Clap Lights
import { Board, Sensor } from 'johnny-five';
import { Observable, Observer } from 'rxjs/Rx';
// The pin that's microphone connected to
const SENSOR_PORT: number = 3;
// Delay between the two claps
const DCLAP_DELAY: number = 500;
const board = new Board();
@vaclavbohac
vaclavbohac / launch.json
Created March 14, 2017 07:44
Visual Studio Code debug configuration for jest with TypeScript
{
"version": "0.2.0",
"configurations": [
{
"name": "TS Tests",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false,
"args": ["--runInBand"],
@vaclavbohac
vaclavbohac / Gemfile
Last active July 16, 2016 12:51
Temperature measurement with arduino and TMP36
source "https://rubygems.org"
gem "dino", github: 'vaclavbohac/dino'
@vaclavbohac
vaclavbohac / package.json
Last active August 29, 2015 14:10
Cyclic Reference Example
{
"name": "cyclic-reference-example",
"version": "1.0.0",
"description": "Example of the cyclic reference example",
"main": "index.js",
"scripts": {
"test": "mocha test"
},
"author": "[email protected]",
"license": "MIT",
@vaclavbohac
vaclavbohac / helper.latte
Last active August 29, 2015 14:08
Inline helper usage
<label>{!_messages.form.labels.foo, ['%price%' => $template->formatPrice($price)]}</label>
It works!
@vaclavbohac
vaclavbohac / optional-groups-select.hbs
Last active August 29, 2015 14:04
Select \w Optional Groups
{{#if view.prompt}}
<option value="">{{view.prompt}}</option>
{{/if}}
{{#if view.optionGroupPath}}
{{#each view.groupedContent}}
{{#if content}}
{{view view.groupView content=content label=label}}
{{else}}
{{view view.optionView content=this}}
@vaclavbohac
vaclavbohac / github-notifications.rb
Created June 26, 2013 19:33
First raw version of desktop GitHub notifications
require "octokit"
require "libnotify"
def get_notification_type type
if type == "PullRequest"
"Pull Request"
else
type
end
end
@vaclavbohac
vaclavbohac / DomQuery.php
Created May 1, 2013 15:39
Testing whether there is element with specified text in current selection.
<?php
namespace Analyzer\Tests;
use Tester;
class DomQuery extends Tester\DomQuery
{
/**
* @return DomQuery