| 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: |
| /** | |
| * 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 |
Should have a functioning Rust install already through rustup. This means the Visual Studio 2019 build tools also need to be installed.
With winget installed do:
$ winget install python| typedef long jint; | |
| typedef int64_t jlong; | |
| typedef signed char jbyte; | |
| /* | |
| * JNI Types | |
| */ | |
| typedef unsigned char jboolean; | |
| typedef unsigned short jchar; |
| 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 |
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:
| <? | |
| // | |
| // 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: |
| use std::collections::HashMap; | |
| use std::io; | |
| use std::io::BufRead; | |
| struct Counter { | |
| items: HashMap<String, usize>, | |
| } | |
| impl Counter { | |
| fn new() -> Counter { |