Skip to content

Instantly share code, notes, and snippets.

View bassmanitram's full-sized avatar

Martin Bartlett bassmanitram

  • DXC
  • Paris, France
View GitHub Profile
@bassmanitram
bassmanitram / HOWTO.md
Created September 17, 2024 09:56
cross-rs and git - how to make a local ~/.gitconfig and ~/.git-credentials available to a cross-rs container for cross compiling

Move the files to ~/.config/git

mkdir -p ~/.config/git
mv ~/.gitconfig ~/.config/git/config
mv ~/.git-credentials ~/.config/git/credentials
ln -s ~/.config/git/config ~/.gitconfig
ln -s ~/.config/git/credentials ~/.git-credentials

That keeps your current config in place and working while placing your files in a logical place for access (in fact, if you set

@bassmanitram
bassmanitram / Cargo.toml
Created January 24, 2024 15:06
Lambda HTTP Request Deserialization by Serde Json and SIMD JSON
[package]
name = "test-serde-simd-json"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bytes = "1.5"
simd-json = "0.13"
@bassmanitram
bassmanitram / cargo.toml
Last active December 8, 2023 15:04
Infantile comparison between http::HeaderMap and stde::collections::HashMap
[package]
name = "test-map"
version = "0.1.0"
edition = "2021"
[features]
headermap = []
[dependencies]
ahash = "0.8.6"
@bassmanitram
bassmanitram / request_serializer.js
Created November 3, 2023 13:14
Serialize a Rust AWS API Gateway V1 Request back into its JSON representation, with no cloning
//
// A JSON-serializeable representation of the V1 API Gateway event.
//
// While it is SUPER convenient to use the http::Request to handle the event in
// most of the Lambda code, when calling a Lambda function we need a JSON view of the
// event - i.e. we need to be able to recreate the JSON structure from the Request.
// aws_lambda_events::event::apigw::ApiGatewayProxyRequest already provides the structure
// and Serialize implementation to do this, BUT it requires an AWFUL lot of cloning to
// get the values in place. THIS approach uses references to the various parts from the
// Request and its extensions, so avoiding cloning where possible.
function doGet() {
try {
const savedConfig = PropertiesService.getUserProperties();
const triggerId = savedConfig.getProperty('TriggerId');
if (triggerId) {
Logger.log("Looking for triger", triggerId)
let t = ScriptApp.getProjectTriggers();
for (let trigger of t) {
if (trigger.getUniqueId() == triggerId) {
Logger.log("Removing trigger", triggerId, trigger);
@bassmanitram
bassmanitram / 99-prevent-volume-adjustment.lua
Created March 11, 2023 12:02
How to make PipeWire prevent an application from adjusting sound settings
--
-- Prerequisites: you are using PipeWire, WirePlumber is your session manager, and you
-- are using a per-user configuration. These preconditions are fulfilled in Pop!OS 22_04.
--
-- It does not matter what API the PipeWire client is using to interact with PipeWire - Pulse,
-- Jack, ALSA, Native - this works in all cases.
--
-- Put this file in $HOME/.config/wireplumber/main.lua.d, then restart the services related
-- to PipeWire - "systemctl --user restart wireplumber pipewire pipewire-pulse"
--
@bassmanitram
bassmanitram / hack-selections.js
Created November 11, 2022 12:56
How to make Terraform 0.13 properly update a Terraform 0.12 state
/*
* Put this in a place where node can find it (referenced by $SCRIPT_HOME in the driver script)
* or figure out how to do this with JQ :)
*
* Basically, for every key that starts with "registry.terraform.io/hashicorp/" duplicate its value to
* that same key with "hashicorp" translated to "-" (keep the original property too)
*/
const fs = require("fs")
const output ={};
Object.entries(JSON.parse(fs.readFileSync( "/dev/stdin" ))).forEach(([key,value]) => {
@bassmanitram
bassmanitram / json-editor-categories-example-with-basic-tab-grid-workaround.html
Created September 8, 2022 12:52
JSON-Editor Categories example with Basic tab grid workaround
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>JSON-Editor Categories example with Basic tab grid workaround</title>
<link rel='stylesheet' type='text/css' media='screen'
href='https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/css/jsoneditor.min.css'>
<link rel='stylesheet' type='text/css' media='screen'
@bassmanitram
bassmanitram / json-editor-categories-example-with-normal-basic-tab.html
Created September 8, 2022 12:51
JSON-Editor Categories example with normal Basic tab
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>JSON-Editor Categories example with normal Basic tab</title>
<link rel='stylesheet' type='text/css' media='screen'
href='https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/css/jsoneditor.min.css'>
<link rel='stylesheet' type='text/css' media='screen'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JSON Schema Editor Extreme Example</title>
<script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>