Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@rougier
rougier / nano.el
Created February 4, 2025 18:48
NANO Emacs (minimal version: 256 lines)
;; nano-emacs.el --- NANO Emacs (minimal version) -*- lexical-binding: t -*-
;; Copyright (c) 2025 Nicolas P. Rougier
;; Released under the GNU General Public License 3.0
;; Author: Nicolas P. Rougier <[email protected]>
;; URL: https://github.com/rougier/nano-emacs
;; This is NANO Emacs in 256 lines, without any dependency
;; Usage (command line): emacs -Q -l nano.el -[light|dark]
@sukhbinder
sukhbinder / duckchat.py
Last active March 14, 2025 08:09
Chat with DuckDuckGo AI Chat CLI with Python
# /// script
# dependencies = [
# "requests",
# ]
# ///
import requests
import json
import sys
from threading import Thread
@3outeille
3outeille / pipeline_parallel.py
Last active March 23, 2025 13:30
Self contained example of how pipeline parallel works (AFAB and 1F1B) in 200 LOC
#VERBOSE=0 torchrun --nproc_per_node 3 self_contained_pp_LOC.py
import os, random, numpy as np, torch, torch.nn as nn, torch.distributed as dist, torch.nn.functional as F
from torch.optim import AdamW
from torch.utils.data import DataLoader, DistributedSampler
from datasets import load_dataset
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
STEP, local_rank, world_size, verbose = 0, int(os.environ["LOCAL_RANK"]), int(os.environ["WORLD_SIZE"]), os.environ.get("VERBOSE", "0") == "1"
def set_all_seed(seed):
@ITotalJustice
ITotalJustice / gci.cpp
Last active November 29, 2024 08:10
test code to ensure proper xci installs work :)
#include <switch.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cstdarg>
#include <vector>
#include <memory>
#include <bit>
#include <experimental/scope>
@benjcal
benjcal / sdlsimple.h
Last active August 13, 2023 04:23
sdlsimple.h
#ifndef H_SDLSIMPLE
#define H_SDLSIMPLE
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdio.h>
// defines
typedef struct sdlsimple_events_t {
bool quit;
@jam1garner
jam1garner / switch-gdb-cheatsheet.md
Last active March 16, 2025 17:27
GDB for Switch Modding Cheatsheet/Tutorial

This is a mini-tutorial of sorts for getting started with gdb on the Switch, with the target audience being people who want to mod and/or reverse games, with no prerequisite knowledge of gdb. The goal will be to walk you through some of the basic workflows needed to use a debugger on the Switch, while being brief enough for skimming for when you forget things.

If some part is unclear, your OS doesn't have install instructions, or you feel part of your workflow should be added here, feel free to comment any additions.

(If you only need a quick reference Jump to the Appendix)

Installing GDB

First off you'll need a version of GDB compatible with aarch64. This can be obtained via either a distribution of

@vi
vi / interesting_crates.md
Last active February 3, 2025 20:05
List of crates that improves or experiments with Rust, but may be hard to find

Let's list here crates that enhance Rust as a language.

It not "batteries" like in stdx, but Rust-specific crates for workarounds for various missing features and experimental ideals from non-accepted/postponed RFCs, or just hacky tricks.

The list is supposed to contain (mostly) crates that are internal to Rust, not ones for making Rust deal with "external world" like other languages bindings, file formats, protocols and so on.

Primary focus should be on crates that are not easy to find by conventional means (e.g. no algorithm name, format or protocol to search for).

Note that quality of the listed crates may vary from proof-of-concept to stable-and-widely-used.

@snoyberg
snoyberg / abonimable-snoyman.rs
Created December 2, 2020 15:05
Playing with GATs, transformers, and more
#![feature(generic_associated_types)]
#[allow(dead_code)]
trait Functor {
type Unwrapped;
type Wrapped<B>: Functor;
fn map<F, B>(self, f: F) -> Self::Wrapped<B>
where
F: FnMut(Self::Unwrapped) -> B;
@1a57danc3
1a57danc3 / FUCK APPLE OCSP
Last active January 8, 2025 13:27
FUCK APPLE OCSP
127.0.0.1 ocsp-lb.apple.com.akadns.net
127.0.0.1 ocsp-cn-lb.apple.com.akadns.net
127.0.0.1 ocsp.apple.com.download.ks-cdn.com
127.0.0.1 k128-mzstatic.gslb.ksyuncdn.com
127.0.0.1 ocsp.apple.com.cdn20.com
127.0.0.1 ocsp.g.aaplimg.com
127.0.0.1 ocsp.apple.com
127.0.0.1 ocsp.digicert.com
@folke
folke / apropos.fish
Created October 1, 2020 12:34
Using `apropos` on macos rebuilds the whatis database every time. Fish shell uses apropos for command completion.
# Fixes extremely slow apropos command on macos
# Using `apropos` on macos rebuilds the whatis database every time.
# Fish shell uses apropos for command completion.
# Simply add the file below to `~/.config/fish/conf.d` to fix the issue
set db ~/.whatis.db
function apropos_update
echo "Updating apropos / whatis database at $db"
man --path | tr ":" " " | xargs /usr/libexec/makewhatis -o $db