Skip to content

Instantly share code, notes, and snippets.

Mikołaj D. mik01aj

Block or report user

Report or block mik01aj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mik01aj / mochatest.js
Last active Jul 3, 2018
Running integration test for react-styleguidist styleguide
View mochatest.js
/* eslint max-nested-callbacks: 0, no-console: 0 */
console.log('\n\n*** RUNNING TEST ***');
var _ = require('lodash');
var babel = require('babel-core');
var babelConfig = require('../package.json').babel;
var React = require('react');
var TestUtils = require('react-addons-test-utils');
mik01aj /
Last active Nov 28, 2015
Comparison of flying-squirrel and Falcor

The common part

Both flying-squirrel and Falcor:

  • Are data fetching libraries
  • Use virtual JSON tree for data modelling
  • Help a lot in keeping the APIs consistent
  • Have client part and server part
  • Handle references efficiently, avoiding roundtrips to server and duplicated data
  • Have routing on the server side, with routes doing just one simple thing.
mik01aj / SquirrelWrapper.jsx
Created Aug 21, 2015
A wrapper for using flying-squirrel with React
View SquirrelWrapper.jsx
/** @jsx React.DOM */
'use strict';
var React = require('react');
var squirrelClient = require('../squirrelClient');
// FIXME: using lastRender for freezing the component doesn't work. skipping some updates with
// shouldComponentUpdate doesn't as well. The problem is that when the user clicks something, it
// triggers a setState on some descendant component and not on SquirrelWrapper. And this partial
mik01aj /
Last active Apr 21, 2017
How to use Tether with React

Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.

But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body).

That's why I created 2 helpers to use Tether with React.

The first one, TetheredElement is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.

The second one, TetherTarget is a React component and it uses TetheredElement to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:

mik01aj / package.json
Last active Aug 29, 2015
iron-node bug #45
View package.json
"name": "test",
"version": "1.0.0",
"description": "",
"main": "suite.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"author": "",
"license": "ISC",
mik01aj / ModelStore-test.js
Created Mar 17, 2015
ModelStore - A simple tool to gather data requests from frontend to batch queries. See 2nd unit test for usage example.
View ModelStore-test.js
/*jshint jasmine: true */
'use strict';
var ModelStore = require('../ModelStore');
var Promise = require('es6-promise').Promise;
var _ = require('lodash');
describe('ModelStore', function () {
var mockFunctionForTheThingApi, axiosGetSpy, store;
mik01aj /
Created Feb 21, 2015
A script to filter out repeated partial slides in PDF presentations (especially lecture slides made in LaTeX Beamer) and generate a printer-friendly version.
# Autor: Mikołaj Dądela <>
if [ "$inputPdf" == "" ]; then
echo "Usage: $0 input.pdf [output.pdf] [<threshold>]"
mik01aj / gulpfile.js
Created Feb 10, 2015
A hackish way to re-run tests just for the changed file. (Gulp + Jest)
View gulpfile.js
// ... requires, initialization and stuff ...
function runJest(changedFilePath) {
var nodeModules = path.resolve('./node_modules');
var jestConfig = {
scriptPreprocessor: nodeModules + '/gulp-jest/preprocessor.js',
unmockedModulePathPatterns: [nodeModules + '/react'],
moduleFileExtensions: ['js', 'jsx'],
testFileExtensions: ['js', 'jsx'],
# Usage: ./ collected-stacks.txt
./ $1 > $TMPSTACKS
# 1st run - hot: default
mik01aj / gist:6871418
Created Oct 7, 2013
simple routes in js
View gist:6871418
const varRegex = /:([a-zA-Z][a-zA-Z0-9]*)/g;
function Route(template) {
this.pack = function pack(data) {
const varRegexClone = new RegExp(varRegex);
return template.replace(varRegex, function (m) {
const key = varRegexClone.exec(m)[1];
varRegexClone.lastIndex = 0; // resetting regex object
return data[key];
You can’t perform that action at this time.