Skip to content

Instantly share code, notes, and snippets.

@slikts
slikts / advanced-memo.md
Last active April 27, 2024 02:40
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@shawwwn
shawwwn / uping.py
Last active April 27, 2024 02:37
µPing: Ping library for MicroPython
# µPing (MicroPing) for MicroPython
# copyright (c) 2018 Shawwwn <shawwwn1@gmail.com>
# License: MIT
# Internet Checksum Algorithm
# Author: Olav Morken
# https://github.com/olavmrk/python-ping/blob/master/ping.py
# @data: bytes
def checksum(data):
if len(data) & 0x1: # Odd number of bytes
@Oppodelldog
Oppodelldog / inner.sh
Created November 27, 2019 20:29
shell - nested traps
#!/bin/bash
err_report() {
echo "error in inner script: $(caller):$1"
}
trap 'err_report $LINENO' ERR
echo "INNER SCRIPT"
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 27, 2024 02:34
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
@wojukasz
wojukasz / keybindings.json
Created March 31, 2023 11:43
VsCode + Vim keybindings and settings - best of both worlds
[
//
// VIM NAVIGATION SHORTCUTS
//
{
// "ctrl+h": Focuses on the left editor group when the text editor is focused, Vim extension is active, and Vim is not in Insert mode.
"key": "ctrl+h",
"command": "workbench.action.focusLeftGroup",
"when": "editorTextFocus && vim.active && vim.mode != 'Insert'"
@dhh
dhh / linux-setup.sh
Last active April 27, 2024 02:21
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl docker.io \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@disler
disler / standards_for_true_ai_coding_assistants.md
Created January 21, 2024 16:30
Standards For True AI Coding Assistants

What is an AI Coding Assistant?

If the coding assistant can't run ITERATIVE CRUD on ALL of your code, it's not a True AI Coding Assistant (TACA)

Standards for TRUE AI Coding Assistants

  1. Must work on existing codebases
  2. Must have a file context mechanism
  3. Must be iteratively controllable
@bohblue2
bohblue2 / README.md
Last active April 27, 2024 02:18
알고리즘 공부하는법

Algorithm, Structure 자료 모음

서론 소개.

  • 이 문서는 출처, References 항목에 있는 사이트들에서 핵심적인 것들만 간추려 요약된 문서입니다.

  • 대부분 한국어를 주로 사용하는 기술문서, 강의, 사이트들을 모아두었습니다.

  • 알고리즘, 자료구조 관련 능력을 빠르고 깊게 키우는 것을 목적으로 두고 작성한 문서입니다.

출처, References

@juanmc2005
juanmc2005 / diart_whisper.py
Last active April 27, 2024 02:15
Code for my tutorial "Color Your Captions: Streamlining Live Transcriptions with Diart and OpenAI's Whisper". Available at https://medium.com/@juanmc2005/color-your-captions-streamlining-live-transcriptions-with-diart-and-openais-whisper-6203350234ef
import logging
import os
import sys
import traceback
from contextlib import contextmanager
import diart.operators as dops
import numpy as np
import rich
import rx.operators as ops