Skip to content

Instantly share code, notes, and snippets.

View binaryoung's full-sized avatar
🌊

young binaryoung

🌊
View GitHub Profile
@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:
@matinrco
matinrco / ubuntuBBR.md
Created December 7, 2022 11:27
Enable bbr in ubuntu 22.04/20.04

Enable bbr in ubuntu 22.04/20.04

Requirements:

  • Linux kernel version must be greater than 4.19

    to check kernel version, run uname -r. sample output:

    5.4.0-132-generic
    
  • Have the CONFIG_TCP_CONG_BBR and CONFIG_NET_SCH_FQ options compiled and added to the kernel.

@hizkifw
hizkifw / cloudflare-worker-youtube-dl.js
Last active February 22, 2025 10:21
Download YouTube videos with Cloudflare Worker
/**
* cloudflare-worker-youtube-dl.js
* Get direct links to YouTube videos using Cloudflare Workers.
*
* Usage:
* GET /?v=dQw4w9WgXcQ
* -> Returns a JSON list of supported formats
*
* GET /?v=dQw4w9WgXcQ&f=251
* -> Returns a stream of the specified format ID

Pre-requisites

Should have a functioning Rust install already through rustup. This means the Visual Studio 2019 build tools also need to be installed.

Install deps

With winget installed do:

$ winget install python
@Ayrx
Ayrx / jni_binja.h
Created May 16, 2020 12:32
JNI header with tweaks for Binary Ninja parser
typedef long jint;
typedef int64_t jlong;
typedef signed char jbyte;
/*
* JNI Types
*/
typedef unsigned char jboolean;
typedef unsigned short jchar;
@kendru
kendru / visitor.rs
Created July 15, 2019 03:55
Example implementation of the visitor pattern in Rust
pub trait Visitable {
fn accept<V: Visitor>(&self, visitor: &mut V) -> V::Result;
}
pub trait Visitor {
type Result;
fn visit_num(&mut self, num: &Num) -> Self::Result;
fn visit_add<T, U>(&mut self, add: &Add<T, U>) -> Self::Result
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

@levelsio
levelsio / blunble.php
Last active September 9, 2024 01:58
Blunble Bot for Twitter
<?
//
// BLUNBLE BOT (by @levelsio)
//
// "Blunble" is Korean internet slang for [BL]ock [UNBL]ock
// If you block and unblock somebody on Twitter, they stop following you.
// It's a polite way of getting rid of trolls without permanently blocking
// because blocking usually results in more anger and more trolling.
//
// WHAT THIS SCRIPT DOES:
@djhworld
djhworld / count.rs
Created December 30, 2018 10:55
improved version
use std::collections::HashMap;
use std::io;
use std::io::BufRead;
struct Counter {
items: HashMap<String, usize>,
}
impl Counter {
fn new() -> Counter {