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:
@HardenedArray
HardenedArray / Efficient UEFI Encrypted Root and Swap Arch Linux Installation Procedure with an ENCRYPTED BOOT
Last active May 14, 2024 13:45
Efficient UEFI Encrypted Root and Swap Arch Linux Installation with an ENCRYPTED BOOT
# OBJECTIVE: Install Arch Linux with encrypted root and swap filesystems with an ENCRYPTED BOOT and boot from UEFI. We will
also decrypt and mount our entire encrypted system using a single LUKS passphrase entry.
# Note: This method supports both dedicated Arch installs and those who wish to install Arch on a multi-OS-UEFI booting system.
# External USB HDD/SSD Installers Notes: Encrypted Arch installs can be booted and run from an external USB HDD or SSD, but
# only when the installation is correctly set up. There are several necessary changes to my standard procedure you'll want
# to make during the install process. Read my External USB HDD/SSD Installation section below before proceeding.
@julianbonilla
julianbonilla / GsonTest.java
Created May 24, 2012 21:18
Read json from file into Gson
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import com.google.gson.Gson;
public class GsonTest {
public static void main(String[] args) throws FileNotFoundException {
@rohgoyal
rohgoyal / gist-with-vscode.md
Last active May 14, 2024 13:42
Manage Github Gist with VSCode

Visual Studio Code to manage Github Gist

Install Github Gist Extension

Search and install Gist (kenhowardpdx.vscode-gist) extension from Marketplace.

Setting up Github Connection

  1. From your Github profile, go to Settings and Develpoper Setttings
@paulirish
paulirish / what-forces-layout.md
Last active May 14, 2024 13:40
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@JoachimGoedhart
JoachimGoedhart / Read-all-csv-files-into-dataframe.R
Last active May 14, 2024 13:45
Reads all *.csv files from working directory and moves the data into a single dataframe
require(data.table)
require(dplyr)
#Get a list with all csv files from the directory that is set as 'working directory'
filelist = list.files(pattern="*.csv$")
#read all csv files with data.table::fread() and put in df_input_list
df_input_list <- lapply(filelist, fread)
#reading in csv files can also be done using the base R function read.csv(), without needing to load package "data.table":
@jen6
jen6 / house_finder.ipynb
Last active May 14, 2024 13:39
직방을 크롤링해 전세자금 대출이 가능한 집 알아보기
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<style>
body { margin: 0; }
.vimeo-container {
padding: 0;
width: 100%;
height: 100vh;
overflow: hidden;
position: relative;
}
iframe {
@dehsilvadeveloper
dehsilvadeveloper / 1_strings.md
Created May 13, 2024 20:33
Redis - Estrutura de dados (Strings, Hashes, Lists e Sets)

Strings

O tipo de estrutura de dado mais básico.

Strings são de propósito múltiplo. Elas podem armazenar dados tão simples quanto um número inteiro ou tão complexos quanto um arquivo de imagem JPEG.

Criando nova chave

// Setting new key