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:
@jedavidson
jedavidson / 2521_exercises.md
Last active May 14, 2024 05:32
A curated list of some good revision and exam preparation programming problems for UNSW's COMP2521. Personal opinion.

These exercises are some I did while studying for COMP2521, as well as some others which I've found afterwards which I think will be relevant. I've collected these problems mostly from LeetCode and HackerRank, which are excellent sites for practicing your coding abilities. Accounts on both sites will be necessary to do the problems listed.

The difficulty ranking is obviously my opinion, but generally speaking here is what they mean:

  • Easy: Problems that you should be able to do without too much difficulty.
  • Intermediate: Problems that are a bit harder, but should be doable with a little bit of thought and intuition.
  • Challenges: Problems that I think are difficult and/or interesting, if you're up for it. There are almost all harder than what's within the scope of 2521.

If you're able to solve the easy and intermediate problems without much difficulty, you're probably very well prepared for any programming questions you'll receive in the ex

@GuyPaddock
GuyPaddock / concave_object_to_convex_objects_by_face.py
Last active May 14, 2024 05:31
Blender 2.91 Script for Convex Hull Decomposition into Separate Shapes Using Blender's Convex using "Split Concave Faces"
##
# A script to split simple, architectural geometry into convex pieces.
#
# This script makes use of Blender's built-in "Split Concave Faces" clean-up
# algorithm to break-up the faces of an object into convex pieces. The script
# attempts to identify all the edges that represent convex boundaries, and then
# it splits objects up along those edges. Each resulting piece is then made into
# a closed object by converting it into a convex hull.
#
# Be sure to select the object you wish the split into convex pieces before
@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@ryanorsinger
ryanorsinger / installing_anaconda_on_mac.md
Last active May 14, 2024 05:29
Installing Homebrew and Anaconda

Installing Homebrew and Anaconda on a Mac

Install Homebrew

Run the following command on your terminal to install Homebrew. Homebrew is a package manager for Macs and is used to install useful development tools and software.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Anaconda through Homebrew

  1. Run brew install --cask anaconda to install Anaconda
@LukeZGD
LukeZGD / ios-downgrade-dualboot.md
Last active May 14, 2024 05:27
Downgrade and dualboot status of almost all iOS devices

Downgrade and dualboot status of almost all iOS devices

UPDATED: 2024-05-02

@yorickdowne
yorickdowne / README.md
Last active May 14, 2024 05:27
Ubuntu Desktop 20.04 with mirrored ZFS boot drive

Overview

Ubuntu Desktop 20.04 supports a single ZFS boot drive out of the box. I wanted a ZFS mirror, without going through an entirely manual setup of Ubuntu as described by OpenZFS in their instructions for Ubuntu 20.04 and instructions for Ubuntu 22.04

This adds a mirror to an existing Ubuntu ZFS boot drive after the fact. It's been tested on Ubuntu 20.04 by me and all the way up to Ubuntu 22.10 by users in comments.

ZFS requires native encryption to be added at pool / dataset creation. Ubuntu 22.04 supports this during installation. Whether these instructions are suitable for mirroring such a setup has not been tested. For Ubuntu 20.04, these instructions are not suitable for creating an encrypted ZFS boot disk, please use the full instructions linked above for that. You can, however, add an en

// ==UserScript==
// @name animelon-subtitle-downloader
// @namespace http://tampermonkey.net/
// @version 0.1
// @description download animelon subtitles
// @author mescyn#5794
// @match https://animelon.com/video/*
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// @require https://cdn.jsdelivr.net/npm/file-saver-es@2.0.5/dist/FileSaver.min.js
@robinpokorny
robinpokorny / .bash_profile
Created March 4, 2020 13:10
In case of fire
function fire() {
local BRANCH=emergency-`date +%s`-`git config user.email`
git checkout -b $BRANCH
git add -A
git commit -m 'EMERGENCY!'
git push -f origin $BRANCH
}
# Inspired by https://www.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvn1k27/
@benitogf
benitogf / mirror.sh
Last active May 14, 2024 05:25
ZFS mirror ubuntu boot drive
#!/bin/sh
# Assumptions and requirements
# - All drives will be formatted. These instructions are not suitable for dual-boot
# - No hardware or software RAID is to be used, these would keep ZFS from detecting disk errors and correcting them. In UEFI settings, set controller mode to AHCI, not RAID
# - These instructions are specific to UEFI systems and GPT. If you have an older BIOS/MBR system, please use https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html
# change the these disks variables to your disks paths (check with lsblk)
DISK1="/dev/nvme0n1"
DISK2="/dev/nvme1n1"