Skip to content

Instantly share code, notes, and snippets.

View mmocny's full-sized avatar

Michal Mocny mmocny

View GitHub Profile
@mmocny
mmocny / gist:4667476
Created January 29, 2013 20:27
Benchmarking recursive lambda solution using std::function. See http://stackoverflow.com/questions/2067988/recursive-lambda-functions-in-c0x
#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);
@mmocny
mmocny / gist:7204756
Last active December 26, 2015 19:58
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…
#include <iostream>
#include <string>
#include <algorithm>
/*
* Sample Output: http://ideone.com/EbKsF5
*
* Tested on: g++ 4.7, g++ 4.8, clang 3.3
*
*/
# 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):
# 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.
function foo() {
  return "bar";
}
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’),
// ...
Verifying that +mmocny is my blockchain ID. https://onename.com/mmocny
@mmocny
mmocny / CumulativeLayoutShiftBookmarklet.js
Last active January 20, 2021 20:23 — forked from anniesullie/CumulativeLayoutShiftBookmarklet.js
Bookmarklet for showing Cumulative Layout Shift
/**
* 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.
**/
@mmocny
mmocny / CheckMobileViewport.js
Last active February 2, 2021 17:08
Re-Implement Chrome conventions for mobile viewport test in 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 / po2it.md
Last active February 4, 2021 16:10
Performance Observer to Async Iterator

Performance Observer to Async Iterator

Background: Iterators, Performance Observer, and Async Iterators

function* range() {
   yield 1;
   yield 2;
   yield 3;
}