Skip to content

Instantly share code, notes, and snippets.

import * as THREE from "three";
function isLineBasicMaterial(mat: THREE.Material & { isLineBasicMaterial?: boolean }): mat is THREE.LineBasicMaterial {
return Boolean(mat.isLineBasicMaterial);
}
function isOrthographicCamera(camera: THREE.Camera & { isOrthographicCamera?: boolean }): camera is THREE.OrthographicCamera {
return Boolean(camera.isOrthographicCamera);
}
(module
(func $func132 (param i32 i32 i32 i32))
(func $main
i32.const 0
i32.const 0
i32.const 0
i32.const 0
call $func132)
(module
(func $func15 (result i32)
call $func130
i32.const 0
drop
i32.const 0
drop
i32.const 0)
(func $func63
(module
(func $main
loop
loop
loop
loop
loop
loop
loop
loop
@tommie
tommie / Dockerfile
Created May 17, 2024 11:53
protobuf-javascript Dockerfile for Alpine Linux.
# https://github.com/protocolbuffers/protobuf-javascript/issues/105
# https://github.com/protocolbuffers/protobuf/pull/9874
FROM alpine
RUN apk --no-cache add gcompat
ARG protoc_js_ver=3.21.2
RUN cd /usr/local &&\
wget -Oprotojs.tar.gz "https://github.com/protocolbuffers/protobuf-javascript/releases/download/v$protoc_js_ver/protobuf-javascript-$protoc_js_ver-linux-$(uname -m).tar.gz" &&\
@tommie
tommie / emulator
Last active May 7, 2024 07:34
Wrapper script to add command line options to the AVD emulator.
#! /bin/bash
#
# Wrapper script to add command line options to the AVD emulator.
#
# avdmanager should support the studio.emu.params environment variable, but it doesn't handle commas well.
#
# ## Installation
#
# 1. Find your AVD home directory. It should have an `emulator` subdirectory.
# 2. Move the `emulator/emulator` file to `emulator/emulator-orig`.
@tommie
tommie / android app src main AndroidManifest.xml
Last active May 6, 2024 10:02
Example usb_serial intent configuration
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
@tommie
tommie / repro.asm
Last active February 8, 2024 16:23
MPASM (gpasm?) macro text substitution flaw
;; gpasm --mpasm-compatible -p p16f887 repro.asm
;;
;; Should produce four nop, but produces none, because the m2 i
;; binding leaks into the m1 i via the n parameter.
;;
;; See also https://forum.microchip.com/s/topic/a5C3l000000LzjcEAC/t229040
m1 macro n
local i
i set 0
@tommie
tommie / colorpicker.frag
Last active January 12, 2024 22:55
Shader for color picker
// Shader to display a full rainbow and grayscales.
// A 2D color picker in a single pane.
//
// adapted from https://github.com/wsmind/js-pride/blob/master/shaders/rainbow.glsl
#define SMOOTH 1
// level is [0,5], assumed to be a whole number
vec3 rainbow(float level)
{
class Node:
def __init__(self, value):
self.value = value
self.visited = False
self.prev = None
self.next = None
class SieveCache:
def __init__(self, capacity):
self.capacity = capacity