Skip to content

Instantly share code, notes, and snippets.

@ptomato
ptomato / floatmath.mjs
Created November 28, 2023 23:55
fma() and extra-precise remquo() implemented using JS Numbers
// The following are line-by-line ports of the fma() and remquo()
// implementations from Openlibm, the math implementation of the Julia language.
// fma()
// Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG>
// 2-clause BSD license.
// remquo()
// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
// Developed at SunSoft, a Sun Microsystems, Inc. business. Permission to use,
@ptomato
ptomato / softfloat.cpp
Last active October 20, 2021 22:57
Converting float -> int128 with code adapted from compiler_rt
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <limits>
static inline uint64_t toRep(double x) {
const union {
double f;
@ptomato
ptomato / reduce.js
Created February 11, 2021 06:29
reduce() examples
// 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
@ptomato
ptomato / getoption.js
Last active September 22, 2020 00:22
GetOption
// 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 June 23, 2020 23:52
How I think about Cancellation in Node.js
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 November 1, 2019 19:43
An Untitled Masterwork
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);
+
# 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 January 17, 2018 21:52
Flapjack configuration
[
{
"name": "difflint",
"buildsystem": "simple",
"build-commands": ["pip3 install ."],
"sources": [
{
"type": "git",
"url": "https://github.com/endlessm/difflint",
"branch": "master"
{
"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": [
{