Skip to content

Instantly share code, notes, and snippets.

@ptomato
ptomato / css.md
Created August 12, 2015 04:27
GTK CSS properties
@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 / simulation.py
Created March 28, 2013 11:29
# Waveguide model for a subwavelength slit as a quarter-wave retarder # (Chapter 2 of my PhD dissertation, "Two-dimensional optics") Main file: simulation.py
import warnings
import numpy as N
import numpy.fft as FT
from scipy import integrate
from spp_generation import interface_calculation
class SlitSystem:
"""Simulation of a subwavelength slit in metal"""
def __init__(self, slit_widths, wavelength, metal_epsilon, metal_thickness,
@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);
+
@ptomato
ptomato / setup.sh
Last active October 5, 2018 12:52
Configure DevDocs on EC2
sudo yum update
sudo yum install gobject-introspection-devel gtk3-devel gstreamer1-devel \
libsoup-devel json-glib-devel gcc-c++ patch readline-devel openssl-devel \
bison bzip2 sqlite-devel git flex intltool python2-devel libxslt-devel \
docbook-xsl python-markdown
curl -O ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7rolling/x86_64/os/Packages/libyaml-devel-0.1.4-11.el7_0.x86_64.rpm
curl -O ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/TheIndifferent:/rhel7-icewm/rhel7-shared/noarch/itstool-2.0.2-2.1.noarch.rpm
sudo rpm -ivh libyaml-devel-0.1.4-11.el7_0.x86_64.rpm itstool-2.0.2-2.1.noarch.rpm
sudo su - root # otherwise repos can't be reached?? http://stackoverflow.com/questions/28802298