Skip to content

Instantly share code, notes, and snippets.

Avatar

Michal Mocny mmocny

View GitHub Profile
@mmocny
mmocny / po2it.md
Last active Feb 4, 2021
Performance Observer to Async Iterator
View po2it.md

Performance Observer to Async Iterator

Background: Iterators, Performance Observer, and Async Iterators

function* range() {
   yield 1;
   yield 2;
   yield 3;
}
@mmocny
mmocny / CheckMobileViewport.js
Last active Feb 2, 2021
Re-Implement Chrome conventions for mobile viewport test in JS.
View CheckMobileViewport.js
/*
* Re-implement based on conventions from:
* https://source.chromium.org/chromium/chromium/src/+/master:cc/trees/layer_tree_host_impl.cc;l=160-176
*
* With help from github.com/dontcallmedom and his library:
* https://github.com/dontcallmedom/metaviewport-parser (MIT https://github.com/dontcallmedom/metaviewport-parser/blob/master/LICENSE)
*/
function HasFixedPageScale() {
// Simpler variant:
@mmocny
mmocny / CumulativeLayoutShiftBookmarklet.js
Last active Jan 20, 2021 — forked from anniesullie/CumulativeLayoutShiftBookmarklet.js
Bookmarklet for showing Cumulative Layout Shift
View CumulativeLayoutShiftBookmarklet.js
/**
* A bookmarklet for viewing shifted elements while debugging
* Cumulative Layout Shift (web.dev/cls). Works in Chrome 84+
* Shows the previous position of shifted elements in yellow,
* and the new position in red.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
View gist:3af892ca37ec39fb9a67
Verifying that +mmocny is my blockchain ID. https://onename.com/mmocny
View gist:7e6348a8db201cbc6ef1
var cordova = require('cordova-lib');
var INPUT_WEBAPP = 'path/to/my/project/dist/app';
var CDV_CONFIG = 'path/to/my/project/src/config.xml';
var OUTPUT_CDVROOT = 'path/to/my/project/dist/cordova';
var platforms = [
require(‘cordova-android’),
require(‘cordova-ios’),
// ...
View gist:10996483
function foo() {
  return "bar";
}
View gist:9631323
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Indicates whether an apk should be generated for each density.
View gist:9631256
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
@mmocny
mmocny / gist:7204756
Last active Dec 26, 2015
Motivated by http://ericniebler.com/2013/10/13/out-parameters-vs-move-semantics/ I'm playing with a possible simple solution to the problem of solving optionally useful InOut variables in C++11 given that the interface is ugly, but occasionally really necessary. Below is a seemingly working solution, which I truly suspected of being undefined be…
View gist:7204756
#include <iostream>
#include <string>
#include <algorithm>
/*
* Sample Output: http://ideone.com/EbKsF5
*
* Tested on: g++ 4.7, g++ 4.8, clang 3.3
*
*/
View gist:4667476
#include <iostream>
#include <functional>
#include <chrono>
uint64_t sum1(int n) {
return (n <= 1) ? 1 : n + sum1(n - 1);
}
std::function<uint64_t(int)> sum2 = [&] (int n) {
return (n <= 1) ? 1 : n + sum2(n - 1);