Skip to content

Instantly share code, notes, and snippets.

View vojtech-dobes's full-sized avatar

Vojtěch Dobeš vojtech-dobes

View GitHub Profile
@jimbolla
jimbolla / protectFromUnmount.js
Created November 16, 2015 19:38
protectFromUnmount
function protectFromUnmount() {
let callbacks = {};
let count = 0;
const noop = value => value;
const wrapCallback = id => function(...params) {
const raceSafeCallbacks = callbacks;
if (!raceSafeCallbacks)
@paulirish
paulirish / what-forces-layout.md
Last active November 19, 2024 01:01
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
<?php
namespace Metis\Tester;
use Nette\Object;
use Tracy\Dumper;
class TestingServer extends Object {
public $onOutput;

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@vojtech-dobes
vojtech-dobes / format-pre.js
Created January 22, 2015 10:00
Make <pre> readable
[].slice.call(document.querySelectorAll('pre'), 0).forEach(function (el) {
el.innerHTML = el.innerHTML.split("\n").join('<br>');
});
var style = document.createElement("style");
style.appendChild(document.createTextNode(""));
document.head.appendChild(style);
style.sheet.insertRule("pre { white-space: normal }", 0);
@milo
milo / github-webhook-handler.php
Last active October 29, 2024 15:45
GitHub Webhook Handler
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check
@hrach
hrach / solution.sql
Last active August 29, 2015 14:02
@hrachcz: #anketa. model: author 1:n books m:n tags. zajima me sql, ktere vybere autory, kteri nenapsali zadnou knihu o PHP (tj. bez tagu PHP).
select *
from authors
where not exists (
select *
from books
left join books_x_tags on (books_x_tags.book_id = books.id)
left join tags on (tags.id = books_x_tags.tag_id)
where
books.author_id = authors.id
and tags.name = 'PHP'
@kaja47
kaja47 / csfd-crawler.php
Created March 12, 2014 01:06
Example crawler using Matcher and AsyncCurl
<?php
use Atrox\Matcher;
use Atrox\Curl;
use Atrox\Async;
$userListMatcher = Matcher::multi('//table[@class="ui-table-list"]//tr', (object) [
'url' => Matcher::single('td/a/@href')->map(function ($x) { return "http://www.csfd.cz$x"; }),
'points' => Matcher::single('td[3]')->asInt(),
'ratings' => Matcher::single('td[4]')->asInt(),
@JakubTesarek
JakubTesarek / .bashrc
Last active October 27, 2021 19:59
.bashrc file with useful shortcuts. The file can update itself using `updaterc`. Also contains detection of platform it's running on
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
# Detect platform
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'FreeBSD' ]]; then
platform='freebsd'
@mislav
mislav / backfill-releases.sh
Created February 5, 2014 17:37
Script to migrate releases from CHANGELOG.md to GitHub Releases
#!/bin/bash
# Usage: OAUTH_TOKEN="..." backfill-releases CHANGELOG.md [<project-title>]
set -e
log="${1?}"
project_name="${2}"
repo="$(git config remote.origin.url | grep -oE 'github\.com[/:][^/]+/[^/]+' | sed 's/\.git$//' | cut -d/ -f2-3)"
[ -n "${project_name}" ] || project_name="${repo#*/}"