Skip to content

Instantly share code, notes, and snippets.

View o0101's full-sized avatar
🏖️
Netscaping

Cris o0101

🏖️
Netscaping
View GitHub Profile
@o0101
o0101 / tinysegmenter_japanese.js
Created January 2, 2022 18:38
TinySegmenter
// TinySegmenter 0.1 -- Super compact Japanese tokenizer in Javascript
// (c) 2008 Taku Kudo <taku@chasen.org>
// TinySegmenter is freely distributable under the terms of a new BSD licence.
// For details, see http://chasen.org/~taku/software/TinySegmenter/LICENCE.txt
function TinySegmenter() {
var patterns = {
"[一二三四五六七八九十百千万億兆]":"M",
"[一-é¾ ã€…ã€†ãƒµãƒ¶]":"H",
"[ぁ-ん]":"I",
@o0101
o0101 / chrome_bookmark_checksum.py
Created January 2, 2022 16:21 — forked from simon816/chrome_bookmark_checksum.py
Calculate Chrome bookmarks checksum
from hashlib import md5
# See https://chromium.googlesource.com/chromium/src/+/master/components/bookmarks/browser/bookmark_codec.cc
def regen_checksum(roots):
digest = md5()
def digest_url(url):
digest.update(url['id'].encode('ascii'))
digest.update(url['name'].encode('UTF-16-LE'))
@o0101
o0101 / export-sync-bookmarks.js
Created December 29, 2021 15:13 — forked from ilokhov/export-sync-bookmarks.js
Node.js script for exporting and synchronising bookmarks from Google Chrome
const fs = require("fs");
const path = require("path");
function newItem(name, url) {
return { name, url };
}
const bookmarkPath = path.join(
process.env.HOME,
"/Library/Application Support/Google/Chrome/Default/Bookmarks"
@o0101
o0101 / enum.js
Created October 3, 2021 17:15
Enums in JavaScript
class Enum extends Function {
static opts = { enumerable: true, writeable: true, configurable: false };
constructor() {
super();
const names = (this.constructor+'').split('{')[1].split('}')[0].split(';').map(n => n.trim()).filter(n => n);
names.forEach((name, i) => {
Object.defineProperty(this.constructor, name.slice(1), { get: () => i, set: () => true, ...Enum.opts });
});
return this.constructor;
}
@o0101
o0101 / on_testing.md
Created September 30, 2021 13:05
My testing philosophy

On testing

  • fast feedback loop
  • set up your code so you can see it working. e.g dev server, CI/CD
  • code with imagination
    • (you're constantly thinking of edge caes naturally and places where things can go wrong, and coding defensively, or at least with awareness)
  • dogfooding, test by using
  • think of it as a product, test it from the user interaction
@o0101
o0101 / sysctl.conf
Created August 14, 2021 06:39 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
#
# See also: https://gist.github.com/kgriffs/4027835
#
# Assumes a beefy machine with lots of network bandwidth
@o0101
o0101 / CLA.md
Last active August 9, 2021 09:41
DOSYAGO CLA

DOSYAGO SOFTWARE CONTRIBUTOR ASSIGNMENT AGREEMENT

This Dosyago Contributor Agreement (this "Agreement") applies to any Contribution you make to any Work. This is a binding legal agreement on you and any organization you represent. If you are signing this Agreement on behalf of your employer or other organization, you represent and warrant that you have the authority to agree to this Agreement on behalf of the organization.

1. Definitions.

  • "Contribution" means any original work, including any modification of or addition to an existing work, that you submit to Dosyago in any manner for inclusion in any Work, including software source code, object code, documentation, or other material.
  • "Dosyago", "we", and "us" means The Dosyago Corporation (equivalently and variously, “Dosyago”, “DOSYCORP”, “Dosy”).
  • "Work" means any project, work, or materials owned or managed by Dosyago.
function z(n) {
const T = 0.00001
let lastT = 0; let L = Math.log(n);
while(Math.abs(lastT-L) > T) { lastT = L;
L = Math.log(n)/Math.log(L);
}
return L;
}
this is sort of the natural base of any number
@o0101
o0101 / script-template.sh
Created December 15, 2020 12:07 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
@o0101
o0101 / gist:b52c5a1808548b991c22857e358db61c
Created October 31, 2020 15:09 — forked from kurokikaze/gist:350fe1713591641b3b42
install chrome from powershell
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec