Skip to content

Instantly share code, notes, and snippets.

@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
@tommie
tommie / router.options.ts
Created October 13, 2023 18:05
Nuxt #23595 WiP workaround
import type { RouteRecordRaw } from "vue-router";
import type { RouterOptions } from '@nuxt/schema';
export default {
routes(routes) {
if (hasChildren(routes)) {
console.warn('The pages had children, which means the fix-pagehierarchy module can be removed!');
return routes;
}
@tommie
tommie / postcsslocal.ts
Last active September 1, 2023 13:37
A postcss plugin for Vue that adds a :local() pseudo-selector
// A postcss plugin that allows partial-global Vue SFC scoped CSS selectors.
//
// It introduces the :scoped() pseudo-selector. Use this inside Vue's
// :global() to once again make something scoped. This is useful
// e.g. if you have an attribute/class on the html element to select
// theme or locale.
//
// ## Status
//
// This works with (at least) Nuxt 3 on Vue 3.3.4. It has not received much
@tommie
tommie / get_bottlerocket_url.sh
Created April 26, 2023 14:16
Downloading Bottlerocket OS image files without tuftool
bkadm_metadata_url=https://updates.bottlerocket.aws/2020-07-07
bkadm_targets_url=https://updates.bottlerocket.aws/targets
# E.g. get_bottlerocket_url 1.26 x86_64 '1\.13\..*'
get_bottlerocket_url() {
local kubernetes_ver=$1 arch=$2 ver_regex=$3
shift 3
local variant="metal-k8s-$kubernetes_ver"
local metadata_url="$bkadm_metadata_url/$variant/$arch"
@tommie
tommie / install.yaml
Last active May 30, 2023 12:14
githubtommie/envoy-gateway manifest
---
# Source: crds/gatewayapi-crds.yaml
# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#