Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active May 7, 2024 19:39
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@wojteklu
wojteklu / clean_code.md
Last active May 7, 2024 19:38
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

@vatsalsaglani
vatsalsaglani / mistral_ctx.py
Last active May 7, 2024 19:38
Token counting and message token management for MistralAI
from typing import List, Dict, Literal, Union
from transformers import AutoTokenizer
class MistralAICtx:
def __init__(self, model_name: str):
assert "mistral" in model_name, "MistralCtx only available for Mistral models"
self.tokenizer = AutoTokenizer.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.2")
@HoughIO
HoughIO / power.js
Created March 1, 2014 02:03
Wowhead JS
if (typeof $WH == "undefined") {
$WH = {
wowheadRemote: true
}
}
$WH.isTouch = function () {
if (!$WH.wowheadRemote && typeof Platform != "undefined") {
$WH.isTouch = function () {
return Platform.isTouch()
}
@timsneath
timsneath / profile.ps1
Last active May 7, 2024 19:37
PowerShell template profile: adds some useful aliases and functions
### PowerShell template profile
### Version 1.03 - Tim Sneath <tim@sneath.org>
### From https://gist.github.com/timsneath/19867b12eee7fd5af2ba
###
### This file should be stored in $PROFILE.CurrentUserAllHosts
### If $PROFILE.CurrentUserAllHosts doesn't exist, you can make one with the following:
### PS> New-Item $PROFILE.CurrentUserAllHosts -ItemType File -Force
### This will create the file and the containing subdirectory if it doesn't already
###
### As a reminder, to enable unsigned script execution of local scripts on client Windows,
@triangletodd
triangletodd / README.md
Last active May 7, 2024 19:35
k3s in LXC on Proxmox

On the host

Ensure these modules are loaded

cat /proc/sys/net/bridge/bridge-nf-call-iptables

Disable swap

sysctl vm.swappiness=0
swapoff -a
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active May 7, 2024 19:33
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@lorenzleutgeb
lorenzleutgeb / rad-worktree.sh
Last active May 7, 2024 19:32
rad-worktree
#! /bin/sh
set -eu
jq -V >/dev/null
if [ $# -lt 1 ]
then
printf 'Usage: %s rad:… [name-of-worktree]\n' "$0"
printf 'The worktree will be created in a new directory within the current working directory.'
exit 1
@AndrewMast
AndrewMast / disable_vanguard.vbs
Last active May 7, 2024 19:32
Commands to disable Riot Vanguard when you aren't playing Valorant
' Disables Vanguard from starting when you boot your computer
Call CreateObject("Shell.Application").ShellExecute("cmd.exe", "/c ""sc config vgc start= disabled & sc config vgk start= disabled""", "", "runas")
@patchthecode
patchthecode / reset_idea_trial.sh
Created June 29, 2021 22:50 — forked from gulrich1/reset_idea_trial.sh
reset intellij trial
#!/bin/sh
#https://github.com/PythonicNinja/jetbrains-reset-trial-mac-osx/blob/master/runme.sh
for product in IntelliJIdea WebStorm DataGrip PhpStorm CLion PyCharm GoLand RubyMine Rider; do
echo "Closing $product"
ps aux | grep -i MacOs/$product | cut -d " " -f 5 | xargs kill -9
echo "Resetting trial period for $product"