Skip to content

Instantly share code, notes, and snippets.

@joseluisq
joseluisq / terminal-git-branch-name.md
Last active April 20, 2024 02:26
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@llzes
llzes / byteToHex.js
Created February 11, 2020 19:16
Byte to Hex and Hex to Byte in JavaScript.
const byteToHex = (byte) => {
const key = '0123456789abcdef'
let bytes = new Uint8Array(byte)
let newHex = ''
let currentChar = 0
for (let i=0; i<bytes.length; i++) { // Go over each 8-bit byte
currentChar = (bytes[i] >> 4) // First 4-bits for first hex char
newHex += key[currentChar] // Add first hex char to string
currentChar = (bytes[i] & 15) // Erase first 4-bits, get last 4-bits for second hex char
newHex += key[currentChar] // Add second hex char to string
@mincrmatt12
mincrmatt12 / craptype.py
Created November 27, 2022 21:49
craptype
import evdev
import curses
import string
import random
import math
import sys
import copy
import time
from selectors import DefaultSelector, EVENT_READ
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active April 20, 2024 02:24
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@padeoe
padeoe / README_hfd.md
Last active April 20, 2024 02:20
CLI-Tool for download Huggingface models and datasets with aria2/wget+git

🤗Huggingface Model Downloader

Considering the lack of multi-threaded download support in the official huggingface-cli, and the inadequate error handling in hf_transfer, this command-line tool smartly utilizes wget or aria2 for LFS files and git clone for the rest.

Features

  • ⏯️ Resume from breakpoint: You can re-run it or Ctrl+C anytime.
  • 🚀 Multi-threaded Download: Utilize multiple threads to speed up the download process.
  • 🚫 File Exclusion: Use --exclude or --include to skip or specify files, save time for models with duplicate formats (e.g., *.bin or *.safetensors).
  • 🔐 Auth Support: For gated models that require Huggingface login, use --hf_username and --hf_token to authenticate.
  • 🪞 Mirror Site Support: Set up with HF_ENDPOINT environment variable.
@DraTeots
DraTeots / ComPort over Network.md
Last active April 20, 2024 02:17
ComPort over Network
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 20, 2024 02:15
set -e, -u, -o, -x pipefail explanation
@arkatsy
arkatsy / zustand-internals.jsx
Last active April 20, 2024 02:12
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) {
@uncenter
uncenter / macos-app-icon-template.md
Last active April 20, 2024 02:11
SVG template for creating macOS app icons.

macOS App Icon Template

Pretty simple to use - download the attached template.svg file, bring in your logo or icon, resize it to the dimensions of the red square (and delete the red square).