Skip to content

Instantly share code, notes, and snippets.

@ptomato
ptomato / reduce.js
Created Feb 11, 2021
reduce() examples
View reduce.js
// reduce()
// ========
// The way everyone starts out learning reduce() is by calculating
// the sum of an array of numbers:
const a = [1, 5, 16, 2, 7, 5, 16, 5];
// If we were going to calculate the sum of an empty array, then
// we'd want the answer to be 0. So that's what we use for the
View getoption.js
// Sample Temporal code using options:
dateTime.toInstant(timeZone, { disambiguation: 'earlier' });
futureDate.difference(today, { largestUnit: 'months' });
// Sample Intl code using options:
date.toLocaleString('en-CA', { weekday: 'long' });
// ECMA-402 unfortunately specifies this:
@ptomato
ptomato / cancellation.md
Created Jun 23, 2020
How I think about Cancellation in Node.js
View cancellation.md
View copy-ostree-progress-get-set.patch
diff --git a/app/flatpak-builtins-build-commit-from.c b/app/flatpak-builtins-build-commit-from.c
index 4b125bc3..fd6aae88 100644
--- a/app/flatpak-builtins-build-commit-from.c
+++ b/app/flatpak-builtins-build-commit-from.c
@@ -391,7 +391,10 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella
glnx_console_lock (&console);
if (console.is_tty)
- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
+ {
@ptomato
ptomato / flatpak.patch
Created Nov 1, 2019
An Untitled Masterwork
View flatpak.patch
diff --git a/common/flatpak-transaction.c b/common/flatpak-transaction.c
index 516ecf0a..bff7c7d6 100644
--- a/common/flatpak-transaction.c
+++ b/common/flatpak-transaction.c
@@ -371,6 +371,8 @@ got_progress_cb (const char *status,
"start-time", "t", &start_time,
NULL);
+ g_message ("==FLATPAK PROGRESS== progress on %p calculated as %u%%", p->ostree_progress, progress);
+
View CMakeCache.txt
# This is the CMakeCache file.
# For build in directory: /run/build/aws-sdk-cpp/_flatpak_build
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
@ptomato
ptomato / devtools.json
Last active Jan 17, 2018
Flapjack configuration
View devtools.json
[
{
"name": "difflint",
"buildsystem": "simple",
"build-commands": ["pip3 install ."],
"sources": [
{
"type": "git",
"url": "https://github.com/endlessm/difflint",
"branch": "master"
View name.ptomato.Sdk.json
{
"build-runtime": true,
"id": "name.ptomato.Sdk",
"id-platform": "name.ptomato.Platform",
"branch": "master",
"runtime": "org.freedesktop.Platform",
"sdk": "org.freedesktop.Sdk",
"runtime-version": "1.6",
"modules": [
{
@ptomato
ptomato / class.js
Created Jul 14, 2017
Inventing GObject ES6 Classes (4)
View class.js
var MyClass = GObject.registerClass({
    GTypeName: 'MyNamespaceMyClass',
    Implements: [Gio.Initable, MyInterface],
    Properties: { 'prop': GObject.ParamSpec.int( /* etc. */ ) },
    Signals: { 'signal': { /* etc. */ } },
}, class MyClass extends GObject.Object {
    constructor(props={}) {
super(props);
// etc.
}
@ptomato
ptomato / decorators.js
Last active Jul 14, 2017
Inventing GObject ES6 Classes (3)
View decorators.js
@GObject.Class('MyNamespaceMyClass')
@GObject.implements([Gio.Initable, MyCustomInterface])
@GObject.signal('signal', { /* etc. */ })
class MyClass extends GObject.Object {
    constructor(props={}) {
super(props);
// etc.
}
 
    @GObject.property.int('Short name', 'Blurb', GObject.ParamFlags.READABLE, 42)