Skip to content

Instantly share code, notes, and snippets.

@arkatsy
arkatsy / zustand-internals.jsx
Last active April 28, 2024 18:44
How zustand works internally
import { useSyncExternalStore } from "react";
// For more on the useSyncExternalStore hook, see https://react.dev/reference/react/useSyncExternalStore
// The code is almost identical to the source code of zustand, without types and some features stripped out.
// Check the links to see the references in the source code.
// The links are referencing the v5 of the library. If you plan on reading the source code yourself v5 is the best way to start.
// The current v4 version contains lot of deprecated code and extra stuff that makes it hard to reason about if you're new to this.
// https://github.com/pmndrs/zustand/blob/fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6/src/vanilla.ts#L57-L94
function createStore(createState) {
@ttwizz
ttwizz / RagdollService.lua
Created April 28, 2024 18:40
Ragdoll Service for Roblox Studio
--!nocheck
local RagdollService = {}
export type ConstraintsInfo = {
[string]: {
[string]: boolean | string | number
}
@jumbojets
jumbojets / autograd.ml
Last active April 28, 2024 18:42
proof of concept autograd implementation in ocaml
(* TODO: multicore and/or gpu computation would be fun *)
(* TODO: mnist sample *)
module Matrix = struct
module FA = Float.Array
type t = { data : FA.t; cols : int }
let make m n value =
let data = FA.make (m * n) value in
@rain-1
rain-1 / llama-home.md
Last active April 28, 2024 18:42
How to run Llama 13B with a 6GB graphics card

This worked on 14/May/23. The instructions will probably require updating in the future.

llama is a text prediction model similar to GPT-2, and the version of GPT-3 that has not been fine tuned yet. It is also possible to run fine tuned versions (like alpaca or vicuna with this. I think. Those versions are more focused on answering questions)

Note: I have been told that this does not support multiple GPUs. It can only use a single GPU.

It is possible to run LLama 13B with a 6GB graphics card now! (e.g. a RTX 2060). Thanks to the amazing work involved in llama.cpp. The latest change is CUDA/cuBLAS which allows you pick an arbitrary number of the transformer layers to be run on the GPU. This is perfect for low VRAM.

  • Clone llama.cpp from git, I am on commit 08737ef720f0510c7ec2aa84d7f70c691073c35d.
@ntfnd404
ntfnd404 / custom_snack_bar.dart
Created April 28, 2024 11:49
Sometimes you want a SnackBar with behavior property set to SnackBarBehavior.fixed to be set with margin != null. But the standard SnackBar does not allow to set behavior property in SnackBarBehavior.fixed with margin != null. In such cases, you can use this approach.
import 'package:flutter/material.dart';
ScaffoldMessenger.of(context)
..removeCurrentSnackBar()
..showSnackBar(
CustomSnackBar(
content: Text(message),
behavior: SnackBarBehavior.fixed,
),
);
@s1061123
s1061123 / kind-multus-test.log
Last active April 28, 2024 18:41
Kind with Multus log
## Create 3-node environment config
[tohayash@tohayash-lab tmp]$ cat << EOF > config-3node.yml
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
- role: worker
- role: worker
# Note: uncomment if you install cni plugin by yourself
#networking:
@zmts
zmts / tokens.md
Last active April 28, 2024 18:40
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@primaryobjects
primaryobjects / tplink-archer-t4u.md
Last active April 28, 2024 18:40
Steps to Install the TP-Link Archer T4U Plus AC1300 USB WiFi Adapter on Linux Mint