Skip to content

Instantly share code, notes, and snippets.

View V0XNIHILI's full-sized avatar
🎯
Focusing

Douwe den Blanken V0XNIHILI

🎯
Focusing
View GitHub Profile
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output.
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure.
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS!
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed.
- Conclusion, classifications, or results should ALWAYS appear last.
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements.
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p
@karpathy
karpathy / add_to_zshrc.sh
Created August 25, 2024 20:43
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@fayalalebrun
fayalalebrun / quantize_posit.py
Created March 2, 2024 07:13
Simulate posit quantization using JAX
import unittest
import jax
import jax.numpy as jnp
from functools import partial
def decompose(x: jnp.float32) -> tuple[jnp.int32, jnp.int32, jnp.int32]:
"""decomposes a float32 into negative, exponent, and significand"""
negative = x < 0
n = jnp.abs(x).view(jnp.int32)
exponent = (n >> 23) - 127
@fgolemo
fgolemo / autobot_omniglot.ipynb
Created March 1, 2022 22:28
Omniglot toy example for Autobots: Latent Variable Sequential Set Transformers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@urbanij
urbanij / gtkwave_macOS_cli_instructions.md
Created November 26, 2021 21:05
Invoke gtkwave from CLI on macOS (Catalina)

GTKWave from CLI on macOS (Catalina)

based on this article https://ughe.github.io/2018/11/06/gtkwave-osx (which does not work for me, as is)

  • Motivation

While installing and running GTKWave is straightforward on macOS, it is slightly more difficult to get the command line tool running properly:

$ /Applications/gtkwave.app/Contents/Resources/bin/gtkwave
Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /Applications/gtkwave.app/Contents/Resources/bin/gtkwave line 2.
@jonatasrenan
jonatasrenan / python-json-types.py
Created June 12, 2021 01:43
A comparison between python's dict libraries to read and write naturally as a JSON parsing.
"""
A comparison between python's dict libraries to read and write naturally as a JSON parsing.
Based on: https://gist.github.com/NelsonMinar/28c5928adbe1f4502af8
Installation:
pip install pypi-search addict easydict attrdict dotted-dict dotmap munch python-box
"""
from typing import Any
@vadimkantorov
vadimkantorov / sincconv.py
Last active September 26, 2023 21:49
Sinc convolution module in PyTorch (adapted and simplified from the original SincNet codebase)
# Sinc learned filter banks were proposed in "Speaker Recognition from raw waveform with SincNet", Ravanelli and Bengio, http://arxiv.org/abs/1808.00158
# Code is simplified and adapted from https://github.com/mravanelli/SincNet/blob/master/dnn_models.py
import math
import torch
class SincConv1d(torch.nn.Conv1d):
def __init__(self, in_channels, out_channels, kernel_size, stride = 1, padding = 0, dilation = 1, groups = 1, bias = False, padding_mode = 'zeros', sample_rate = 16_000, min_low_hz = 50, min_band_hz = 50, low_hz = 30):
assert in_channels == 1 and kernel_size % 2 == 1 and bias is False and groups == 1
super().__init__(in_channels, out_channels, kernel_size, stride = stride, padding = padding, dilation = dilation, groups = groups, bias = bias, padding_mode = padding_mode)
/* ESP32-S2 (beta) "dedicated GPIO" peripheral example */
#include <stdio.h>
#include "sdkconfig.h"
#include "soc/system_reg.h"
#include "esp32s2beta/rom/gpio.h"
#include "soc/gpio_sig_map.h"
#include "driver/gpio.h"
/* The header file is not yet in IDF; however this is the only register we need. */
@ayyybe
ayyybe / ccdl.command
Last active September 12, 2024 02:13
Adobe Offline Package Builder v0.1.2 (macOS only) --- No longer being maintained.
#!/bin/bash
CYAN="$(tput bold; tput setaf 6)"
RESET="$(tput sgr0)"
clear
if command -v python3 > /dev/null 2>&1; then
if [ $(python3 -c "print('ye')") = "ye" ]; then
clear
@slikts
slikts / advanced-memo.md
Last active September 12, 2024 18:33
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