Skip to content

Instantly share code, notes, and snippets.

@quad
quad / 0-modular-errors-with-rusts-thiserror.md
Last active May 13, 2024 11:05
Modular Errors with Rust's thiserror

I've been writing Rust full-time with a small team for over a year now. Throughout, I've lamented the lack of clear best practices around defining error types. One day, I'd love to write up my journey and enumerate the various strategies I've both seen and tried. Today is not that day.

Today, I want to reply to a blog post that almost perfectly summarised my current practice.

Go read it; I'll wait!


@yasirkula
yasirkula / SlicedFilledImage.cs
Last active May 13, 2024 11:00
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@LuisEGR
LuisEGR / apis.txt
Last active May 13, 2024 10:58
GCP List of API Services - Updated to Feb 2023
NAME TITLE
abusiveexperiencereport.googleapis.com Abusive Experience Report API
acceleratedmobilepageurl.googleapis.com Accelerated Mobile Pages (AMP) URL API
accessapproval.googleapis.com Access Approval API
accesscontextmanager.googleapis.com Access Context Manager API
actions.googleapis.com Actions API
addressvalidation.googleapis.com Address Validation API
adexchangebuyer-json.googleapis.com Ad Exchange Buyer API
adexchangebuyer.googleapis.com Ad Exchange Buyer API II
@ryanburnette
ryanburnette / Caddyfile
Last active May 13, 2024 10:55
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@KalebNyquist
KalebNyquist / lookupZoteroCollections.js
Created August 8, 2021 21:44
One of my frustrations with Zotero is that there is no easy way to list all the collections in which a file is stored. This is my band-aid of a solution. The code can be run under Tools > Developer > Run Javascript using "Sync" mode.
// Instructions:
// (1) Highlight file of interest.
// (2) Run code in Zotero's JavaScript console (found under Tools > Developer > Run Javascript) in sync mode.
function collections_output() {
zp = Zotero.getActiveZoteroPane()
items = zp.getSelectedItems()
collection_ids = items[0]["_collections"]
collections_cache = Zotero.Collections._objectCache
@slimlime
slimlime / uupdump ConvertConfig.ini explained.md
Created October 8, 2022 22:45
uupdump ConvertConfig.ini explained (convert-UUP, AutoStart, AddUpdates, Cleanup, ResetBase, NetFx3, StartVirtual, wim2esd, wim2swm, SkipISO, SkipWinRE, LCUwinre, UpdtBootFiles, ForceDism, RefESD, SkipEdge, AutoExit, Store_Apps, SkipApps, AppsLevel, CustomList, create_virtual_editions, vAutoStart, vDeleteSource, vPreserve, vwim2esd, vwim2swm, vS…

note: some of the information is posted in comments,
if you'll fork this gist, you'll loose that information,
it is best to just bookmark this one..

WIM

WIM (ESD,SWM) is an image of an OS file system,
it can be mounted, and modified (to some degree) .
there are two possible ways, through DISM or through mounting it directly through an older way, using a driver named imagex (Windows Imaging Utility).
regardless,

terminology

@ckandoth
ckandoth / install_nextflow_singularity.md
Last active May 13, 2024 10:51
Install conda and use it to install nextflow and singularity

This guide will show you how to install conda and then use it to install nextflow and singularity for executing popular bioinformatics workflows. Unfortunately, singularity is not available on Windows or macOS. So, this guide will only target Linux environments. If you have to use Windows 10, then try WSL2. If you have to use macOS, then try a Virtual Machine.

Download the Miniconda3 installer for Linux environments:

curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh

Install into a folder named miniconda3 under your home directory, and delete the installer:

bash miniconda.sh -bup $HOME/miniconda3 && rm -f miniconda.sh
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@dev-niiaddy
dev-niiaddy / QRPainter.kt
Last active May 13, 2024 10:47
A function to encode text as a QR code using BitmapPainter and zxing-core for use in jetpack compose with Image composable.
@Composable
fun rememberQrBitmapPainter(
content: String,
size: Dp = 150.dp,
padding: Dp = 0.dp
): BitmapPainter {
val density = LocalDensity.current
val sizePx = with(density) { size.roundToPx() }
val paddingPx = with(density) { padding.roundToPx() }