Skip to content

Instantly share code, notes, and snippets.

View amorist's full-sized avatar
🔞
Focusing

Amor amorist

🔞
Focusing
View GitHub Profile
@amorist
amorist / chunking-regex.ts
Created August 15, 2024 04:52 — forked from hanxiao/testRegex.js
Use regex to do chunking by using all semantic cues
// Used in https://jina.ai/tokenizer (Aug. 14th version)
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 6;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
const MAX_HTML_HEADING_ATTRIBUTES_LENGTH = 100;
const MAX_LIST_ITEM_LENGTH = 200;
const MAX_NESTED_LIST_ITEMS = 5;
const MAX_LIST_INDENT_SPACES = 7;
const MAX_BLOCKQUOTE_LINE_LENGTH = 200;

Keybase proof

I hereby claim:

  • I am amorist on github.
  • I am amorist (https://keybase.io/amorist) on keybase.
  • I have a public key ASADO0UC4lM2tZGw2PeGwJfBFZF2uaJSCHbtfmfG1lsx4go

To claim this, I am signing this object:

@amorist
amorist / clean.sh
Created August 1, 2019 02:17
sentry clean
crontab -e
0 0 * * * docker exec -it onpremise_web_1 sentry cleanup --days 7 && docker exec -it onpremise_postgres_1 vacuumdb -U postgres -d postgres -v -f --analyze
pred='process matches ".*(ocker|vpnkit).*"
|| (process in {"taskgated-helper", "launchservicesd", "kernel"} && eventMessage contains[c] "docker")'
/usr/bin/log stream --style syslog --level=debug --color=always --predicate "$pred"
@amorist
amorist / app.go
Created June 19, 2019 01:24
go static html server
package main
import (
"log"
"net/http"
)
func main() {
fs := http.FileServer(http.Dir("./"))
http.Handle("/", fs)
@amorist
amorist / converter.py
Created May 8, 2019 12:53 — forked from Kronopath/converter.py
WeChat audio converter script. See http://kronopath.net/blog/extracting-audio-messages-from-wechat/ for more details.
# WeChat aud file converter to wav files
# Dependencies:
# SILK audio codec decoder (available at https://github.com/gaozehua/SILKCodec)
# ffmpeg
#
# By Gabriel B. Nunes (gabriel@kronopath.net)
# Adapted from another script by Nicodemo Gawronski (nico@deftlinux.net)
#
import os, argparse, subprocess
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/stamblerre/gocode
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/josharian/impl
const getWindowPosition = () => {
const windowBounds = window.getBounds()
const trayBounds = tray.getBounds()
// Center window horizontally below the tray icon
const x = Math.round(trayBounds.x + (trayBounds.width / 2) - (windowBounds.width / 2))
// Position window 4 pixels vertically below the tray icon
const y = Math.round(trayBounds.y + trayBounds.height + 4)
@amorist
amorist / MyClippings.txt
Last active October 19, 2018 05:16
My Clippings.txt
note_path='/Volumes/Kindle/documents/My Clippings.txt'
f=open(note_path,'r+')
digest_path='/Users/amor/Documents/'
while True:
onenote=[]
for i in range(0,5):
line=f.readline()
if not line:
exit()
onenote.append(line)