Skip to content

Instantly share code, notes, and snippets.

@Narsil
Narsil / pure_torch.py
Created November 10, 2022 15:06
Loading a safetensors file with pure torch only
import mmap
import torch
import json
import os
from huggingface_hub import hf_hub_download
def load_file(filename, device):
with open(filename, mode="r", encoding="utf8") as file_obj:
with mmap.mmap(file_obj.fileno(), length=0, access=mmap.ACCESS_READ) as m:
@Maharshi-Pandya
Maharshi-Pandya / contemplative-llms.txt
Last active January 14, 2025 16:08
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@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() {
@neomantra
neomantra / High_Performance_Redis.md
Last active January 14, 2025 16:07
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@jatinkrmalik
jatinkrmalik / data.md
Last active January 14, 2025 16:07
RSS Feed/Blogs from @0xGlitchbyte
import matplotlib.pyplot as plt
import numpy as np
# Parameters (You can adjust these as needed)
roller_diameter = 5 # mm
rollers_num = 12
cycloid_outer_diameter = 60 # mm (will be ignored if lower then minimum)
input_shaft_diameter = 5 # mm
# Function to plot cycloidal points
@Su-Shee
Su-Shee / gist:5d1a417fa9de19c15477
Last active January 14, 2025 16:06
Falsehoods Programmers Believe About "Women In Tech"

Falsehoods Programmers Believe About "Women In Tech"

  • We have absolutely no idea what we're doing in tech. Please explain the utmost basic things to us.

  • We only do web design. Our whole reason of being in tech is to make things pretty. Consider us the doilies of the industry.

  • We're not laughing about your joke, so we clearly need you explain it to us. In great detail.

  • We're only in tech to find a husband, boyfriend or generally to get laid.

@fernandobarbalho
fernandobarbalho / gist:42606ed603a7f284aef8d117a536c41e
Last active January 14, 2025 16:06
Função para consumo de web-service de despesa do governo do estado de São Paulo
####Aqui a função
processa_ws_sp_chamada<- function(ano,
codOrgao = "Detalhado", #Consolidado/Detalhado/<Código>
CodFonte = "Detalhado", #Consolidado/Detalhado/<Código>
CodFuncao="Detalhado", #Consolidado/Detalhado/<Código>
CodGrupo="Todos", #Todos/<Código>
CodModalidade = "Todos")#Todos/<Código>
{
# Carregar o pacote necessário
@josemarimanio
josemarimanio / install_pyenv_mac_zsh.rst
Created May 13, 2020 12:13
Installing pyenv on macOS for Zsh using Homebrew