Skip to content

Instantly share code, notes, and snippets.

@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@RuizuKun-Dev
RuizuKun-Dev / GistUtil.lua
Created June 7, 2023 08:00
A Module for Interacting with GitHub's Gist API from within Roblox!
local HttpService = game:GetService("HttpService")
local API = "https://api.github.com/gists"
export type JSONString = string
-- Function to encode data into JSON format
-- @param data The data to be encoded
-- @return The encoded data
local function encode(data: table?): JSONString?
@leocomelli
leocomelli / git.md
Last active May 14, 2024 23:01
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@wojteklu
wojteklu / clean_code.md
Last active May 14, 2024 23:00
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

@morgangiraud
morgangiraud / tinygrad-p2p-patched-driver.sh
Created May 2, 2024 11:56
tinygrad-p2p-patched-driver.sh
# this GIST is a follow-up to this previous GIST: https://gist.github.com/morgangiraud/ffa45e76b6891cd4e37e90d75b8be37b
# See the article here: https://morgangiraud.medium.com/multi-gpu-nvidia-p2p-capabilities-and-debugging-tips-fb7597b4e2b5
# It provides some tips and tricks to install Tinygrad patched nvidia open kernel to give P2P capabilities
# to the 40** series!
### Transitioning into complex operations, our aim is to minimize potential issues.
### Important: Verify that the version from nvidia-smi matches exactly what we intend to use.
### At the time of this writing, the reported version is 550.78.
@d4vsanchez
d4vsanchez / leetcode_9_palindrome_number.rs
Created May 11, 2024 14:38
Solution for the "9. Palindrome Number" problem from LeetCode
impl Solution {
pub fn is_palindrome(x: i32) -> bool {
if x < 0 {
return false;
}
let mut x_copy = x;
let mut reverse: i32 = 0;
while x_copy > 0 {
reverse = (reverse * 10) + (x_copy % 10);
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 14, 2024 22:57
set -e, -u, -o, -x pipefail explanation
@morgangiraud
morgangiraud / multi-gpu.sh
Last active May 14, 2024 22:57
Script for Ubuntu: Nvidia Multi-GPU Installation and Testing
# Script for Ubuntu: Nvidia Multi-GPU Installation and Testing (Adaptable for other distros)
# Step 0: Clean Nvidia Installation
# If you need to completely remove a previous Nvidia installation, use these commands.
# This ensures that you start with a clean slate for a new installation.
sudo apt-get --purge remove "*nvidia*"
sudo apt-get --purge remove "*cuda*" "*cudnn*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*" "*libnccl*"
# Verify that the removal is complete by checking if any Nvidia, CUDA, or cuDNN packages are still installed.
apt list --installed | grep cuda
@JamesMenetrey
JamesMenetrey / copy-and-swap-idiom.cpp
Created May 8, 2016 22:05
C/C++ - The perfect Copy-And-Swap idiom usage
// Source: http://codereview.stackexchange.com/questions/95464/is-the-copy-swap-idiom-implemented-here-correctly
class Array
{
int size;
int* data;
public:
Array(Array const& copy)
: size(copy.size)
, data(new int[size])
# setup dbus
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval $(dbus-launch --exit-with-session --sh-syntax)
fi
systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY
fi