Skip to content

Instantly share code, notes, and snippets.

@eytanhanig
eytanhanig / home_row_modifiers-to_alone.json.rb
Last active November 13, 2023 22:52
Karabiner Home Row Modifiers
#!/usr/bin/env ruby
require 'json'
def main
puts JSON.pretty_generate(
"title" => "@ Home Home Row Keys for Modifiers (using if_alone)",
"maintainers" => ["eytanhanig"],
# # Uncomment conditions to only apply modifications to internal apple keboards
# "conditions" => [
@shicks
shicks / index.md
Last active August 14, 2023 03:41
My TypeScript generics wishlist

Background: TypeScript Generics Wishlist

There are a handful of issues that are both separate features, but are also loosely related in that they speak to certain problematic aspects of generics today. In particular,

  • [#7061] (specifically later in the thread) asks for a way to assign a private alias to a complex typed derived from the actual type parameters, usable from within the class/function signature. There are suggestions to use namespaces and other hacks, along with explanations of why <T, U extends Foo<T> = Foo<T>> is insufficient.
  • [#26242] and [#16597] both pertain to partial inference of type parameters. The rough summary is that you can write ``, but there's no way to explicitly specify T and still get inference on `U`. If you
export const chaosTestStrings = (): void => {
const textNodes = getAllTextNodes(document.body);
for (const node of textNodes) {
const textNodeLength = node.textContent ? node.textContent.length : 0;
if (node.textContent === null) {
return;
}
if (node.parentElement instanceof Element) {
if (node.parentElement.dataset.originalText === undefined) {
@sastan
sastan / $layout.svelte
Last active January 15, 2023 00:15
sveltekit + urql (extended version)
<script context="module">
import { get, readable } from 'svelte/store'
import { createClient, operationStore } from '@urql/svelte'
import { browser, dev } from '$app/env'
/**
* @type {import('@sveltejs/kit').Load}
*/
@sindresorhus
sindresorhus / esm-package.md
Last active July 5, 2024 07:58
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@jessarcher
jessarcher / dslr-webcam.md
Last active March 10, 2024 17:25
Using my Canon 70D DSLR camera as a web cam on Linux

You'll need:

  1. Video 4 Linux loopback device kernel module (v4l2loopback) - Source: https://github.com/umlaeute/v4l2loopback (You might find builds in your distro's repos - I'm using Fedora so had to build it myself using https://github.com/danielkza/v4l2loopback-fedora/)
  2. gPhoto2 - this is what allows you to access your cameras live feed over USB - this was available in Fedora's repos.
  3. GStreamer or ffmpeg - this is what lets you stream the output from gPhoto2 into the loopback device.

It's been a little while since I set it all up so I can't remember all of the installation details, which will probably be different for your distro anyway unless you're using Fedora. Apologies if I have forgotten something as wel.

Running the stream

@brutella
brutella / rpi-enable-camera-module.md
Last active February 9, 2024 09:48
How to enable the camera module on a Raspberry Pi

Enable camera module

Edit your /boot/config.txt file and make sure the following lines look like this:

start_x=1             # essential
gpu_mem=128           # at least, or maybe more if you wish
disable_camera_led=1  # optional, if you don't want the led to glow

Load bcm2835-v4l2 module

@TheCodeArtist
TheCodeArtist / git-prevision
Last active February 3, 2023 21:05
git checkout a previous revision of a specific file
Start by adding the following alias to your gitconfig.
[alias]
prevision = "!f() { git checkout `git log --oneline $2 | awk -v commit="$1" 'FNR == -commit+1 {print $1}'` $2;} ;f"
Usage:
$ git prevision <N> <filename>
will checkout the <N>th revision (counting backwards from HEAD) into the history of the file <filename>.
For example to checkout the immediate previous version of a file x/y/z.c use
@Starefossen
Starefossen / vim-cheats.md
Last active June 18, 2024 15:11
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab