type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
type Fn = (...args: JSONValue[]) => void
function cancellable(fn: Fn, args: JSONValue[], t: number): Function {
let id = setTimeout(() => fn(...args), t);
// cancel delay
Discover gists
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: |
# Luke's config for the Zoomer Shell | |
# Enable colors and change prompt: | |
autoload -U colors && colors | |
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b " | |
# History in cache directory: | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
HISTFILE=~/.cache/zsh/history |
# Create user deployer with root account | |
adduser deployer | |
# Append (-a) a secondary group (-G) "www-data" to user "deployer" | |
usermod -a -G www-data deployer | |
# See groups assigned to user "deployer" | |
groups deployer | |
# Add ACL permission in /var/www |
import numpy as np | |
def gs_cofficient(v1, v2): | |
return np.dot(v2, v1) / np.dot(v1, v1) | |
def multiply(cofficient, v): | |
return map((lambda x : x * cofficient), v) | |
def proj(v1, v2): | |
return multiply(gs_cofficient(v1, v2) , v1) |
package main | |
import ( | |
"fmt" | |
"log" | |
"golang.org/x/sys/unix" | |
) | |
// https://www.gnu.org/software/libc/manual/html_node/Sockets.html#Sockets |
del v7.0.0 moved to pure ESM (no dual support), which forced me to move my gulpfile to ESM to be able to continue to use del
.
The author sindresorhus maintains a lot of npm packages and does not want to provides an upgrade guide for each package so he provided a generic guide. But this guide is a bit vague because it's generic and not helping for gulp, hence this guide.
Ring handler a function which accepts a request (map) and returns a response (map).
Ring middleware
function (handler, &args -> function(request -> response) because it is a closure handler and &args are in scope within the returned handler function.
a function which accepts a "next handler" (the next handler in the chain) + any extra arguments and returns a handler (function), which will accept a request and return a response.
O macOs roda sobre Darwin OS (kernel XNU), que é um sistema UNIX-like. Então, todos os comandos abaixo também funcionam normalmente no MacOS. Recomendo utilizar o gerenciador de pacotes homebrew caso necessário instalar algo. Se quiser o mesmo terminal que eu (ZSH com Oh My ZSH), utilize este vídeo para configurar https://youtu.be/bs1-Wxb_KIc
No Windows é possível utilizar o wsl2 e instalar uma versão do linux para acompanhar. Eu fiz alguns vídeos para você usar o Linux no Windows.
- After you've selected a feature to work on, create a branch in your local repo to build it in.
$ git checkout -b calaway/short_description_of_feature
- Implement the requested feature, make sure all tests are passing, and commit all changes in the new branch.
- Checkout the master branch locally.
$ git checkout master
- Pull down the master branch from GitHub to get the most up to date changes from others. If you practice git workflow as described here you should never have a merge conflict at this step.
$ git pull origin master
- Make sure all tests are passing on master and then checkout your new branch.
$ git checkout calaway/short_description_of_feature