Skip to content

Instantly share code, notes, and snippets.

View mfolnovic's full-sized avatar

Matija Folnovic mfolnovic

  • Zagreb, Croatia
View GitHub Profile
{
"stats": {
"suites": 1,
"tests": 2,
"passes": 2,
"pending": 0,
"failures": 0,
"start": "2020-03-06T11:14:34.072Z",
"end": "2020-03-06T11:14:36.563Z",
"duration": 2491,
@mfolnovic
mfolnovic / describeStories.tsx
Created October 18, 2019 09:40
Storybook + Jest (React specific)
import React from 'react';
import { storiesOf, getStorybook } from '@storybook/react';
import { startCase } from 'lodash';
import { render } from '@testing-library/react';
// from storybook/lib/core/src/client/preview/start.js
function matches(storyKey: string, arrayOrRegex: any) {
if (Array.isArray(arrayOrRegex)) {
@mfolnovic
mfolnovic / describeStories.tsx
Created October 18, 2019 09:40
Storybook + Jest (React specific)
import React from 'react';
import { storiesOf, getStorybook } from '@storybook/react';
import { startCase } from 'lodash';
import { render } from '@testing-library/react';
// from storybook/lib/core/src/client/preview/start.js
function matches(storyKey: string, arrayOrRegex: any) {
if (Array.isArray(arrayOrRegex)) {
@mfolnovic
mfolnovic / README.md
Last active January 1, 2016 19:59 — forked from mbostock/.block
Add blocking work in background.

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

Compare this display to a force layout with curved links, a force layout with fisheye distortion and a matrix diagram.

@mfolnovic
mfolnovic / index.html
Last active December 21, 2015 07:09 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Mobile Patent Suits</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<style type="text/css">
path.link {
fill: none;
@mfolnovic
mfolnovic / gist:729496
Created December 5, 2010 21:41
PHP Controllers with Filters (Rails-like)
<?php
/* This example shows how usage of rails filters could look like in php */
class NewsController {
/**
* @before_filter online
* @cache (ttl: 3600)
*/
public function show() {
I was searching for a best way to define a javascript class, and then, I found this:
http://www.phpied.com/3-ways-to-define-a-javascript-class/
So, it describes three ways:
1. using a function
2. using JSON
3. singleton (combination of 1. and 2.)
I couldn't find any article which describes what is the best way, in matter of compression, so I decided to test it by myself.
So I made three versions of my navigation system (I already had it in 2. way before I read that article), and I compressed them using google closure compiler, and these are result: