Skip to content

Instantly share code, notes, and snippets.

@philipp-classen
philipp-classen / find-prime-triple.rb
Created August 21, 2023 09:03
Find prime triples whose sum approximates the given value
# Given a sum, it returns prime numbers that approximately add up to the sum.
# Example: 100 -> [29, 31, 37] (sums to 97)
require 'prime'
def find_prime_triple(target)
return [2, 3, 5] if target <= 4
middle_prime = nil
i = 0
while !middle_prime do
@philipp-classen
philipp-classen / simulate-connectivity-issues.sh
Last active July 21, 2023 10:25
Simulate lacking internet connections
#!/bin/bash
#
# Needs to be run as root!
# between 0 (never flakey) and 100 (regularly flaky)
flakiness=20
# max delay in seconds
max_delay_normal=8
max_delay_flakey=300
@philipp-classen
philipp-classen / dump-indexedb.js
Last active April 3, 2023 10:35
IndexedDB import and export snippets for local debugging
/**
* Snippet for exporting and importing IndexedDB databases.
* Intended to be used only for testing.
*
* It uses only the native IndexedDB API, so it should work by copy-pasting the code
* into the browser devtools.
*
* Exporting:
* const json = await exportToJson('foo-db');
* // ("json" is a string and can be copied around)
@philipp-classen
philipp-classen / PKGBUILD
Created November 15, 2018 02:11
possible zapcc fix
pkgname=zapcc-git
pkgver=r57.9bd04e761
pkgrel=1
pkgdesc="caching C++ compiler based on clang, designed to perform faster compilations"
arch=('x86_64')
license=('custom:University of Illinois/NCSA Open Source License')
url="https://www.zapcc.com/"
provides=('zapcc')
conflicts=('zapcc')
depends=('ncurses' 'zlib')
# To build:
# $ docker build -t aur-cliqz .
#
# To run (experimental):
# $ xhost +local:
# $ export XSOCK=/tmp/.X11-unix/X0
# $ docker run --rm -v $XSOCK:$XSOCK aur-cliqz cliqz
#
# To remove local X11 permissions again:
# $ xhost -
# Maintainer: Anatol Pomozov <anatol dot pomozov at gmail>
# Contributor: Jose Neder <jlneder(at)gmail(dot)com>
pkgname=libhugetlbfs
pkgver=2.20
pkgrel=1
pkgdesc='interacts with the Linux hugetlbfs to make large pages available to applications in a transparent manner.'
url='https://github.com/libhugetlbfs/libhugetlbfs'
arch=(i686 x86_64)
depends=(perl)
@philipp-classen
philipp-classen / Dockerfile
Last active June 1, 2017 20:16
compare release against Ubuntu
# Run with:
#
# sudo docker build . -t latest-cliqz-release && sudo docker run --rm -it latest-cliqz-release
#
# In the end, you should see output like this:
#
# Searching for latest CLIQZ release on Ubuntu (this can take a while...)
# http://repository.cliqz.com/dist/debian-release/pool/main/c/cliqz/CLIQZ-1.13.2-release.20170508130652.x86_64.deb
# SHA256: 73f63d37c786e795ef0387095d80d2aaf10bb273916e2a262968306e3f6161cb
#