Skip to content

Instantly share code, notes, and snippets.

@justjake
justjake / server-preload.js
Last active January 23, 2025 07:20
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
// @ts-check
"use strict"
/**
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
*/
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active January 23, 2025 07:19
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/rfc9562/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@0xdevalias
0xdevalias / _accessing-apple-reminders-data-macos.md
Last active January 23, 2025 07:19
Some notes on accessing / exporting Apple's Reminders data on macOS
.
├── cmd
│   ├── cli
│   └── web
├── internal
│   ├── database
│   ├── request
│   ├── response
│   ├── templatefuncs
│   ├── validator
import React, { useState } from 'react';
import { Pressable, View } from 'react-native';
import Animated, { css } from 'react-native-reanimated';
export default function Wave() {
const [clickLocation, setClickLocation] = useState({ x: -1, y: -1 });
const dots = Array.from({ length: 323 });
const size = 19;
const color = `rgb(${Math.random() * 255}, ${Math.random() * 255}, ${Math.random() * 255})`
@wojteklu
wojteklu / clean_code.md
Last active January 23, 2025 07:15
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active January 23, 2025 07:15
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@philipstanislaus
philipstanislaus / gist:c7de1f43b52531001412
Last active January 23, 2025 07:14
JavaScript: Save a blob to disc
var saveBlob = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (blob, fileName) {
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
@NorkzYT
NorkzYT / proxmox-lxc-cifs-share.sh
Last active January 23, 2025 07:11
Proxmox CIFS Share Mount Wizard Script
#!/bin/bash
# This script is designed to assist in mounting CIFS/SMB shares to a Proxmox LXC container.
# It automates the process of creating a mount point on the Proxmox VE (PVE) host, adding the
# CIFS share to the /etc/fstab for persistent mounts, and configuring the LXC container to
# recognize the share. This script is intended for use on a Proxmox Virtual Environment and
# requires an LXC container to be specified that will access the mounted share.
#
# Prerequisites:
# - Proxmox Virtual Environment setup.