Skip to content

Instantly share code, notes, and snippets.

@leonmak
leonmak / README.md
Last active November 10, 2023 13:11
how to setup matrix server dendrite

Docker

in ~/docker/matrix:

  • wget https://raw.githubusercontent.com/matrix-org/dendrite/main/build/docker/docker-compose.yml
  • edit docker-compose.yaml
    • to add postgres password
    • to add volume file below
      • ./config:/etc/dendrite for below config
      • ./:/mnt for keys in container, see below
  • edit config/dendrite.yaml
@leonmak
leonmak / fetch-content.js
Created October 17, 2022 06:12
get-substack
const runner = ((links) => {
var parser = new DOMParser();
links.forEach(async link => {
const resp = await fetch(link)
const text = await resp.text()
const doc = parser.parseFromString(text, "text/html");
const title = doc.querySelector('.post-title').textContent;
const subtitle = doc.querySelector('.subtitle').textContent
const bodyHTML = doc.querySelector('.available-content').innerHTML;
const html = `<html>
@leonmak
leonmak / test2.json
Last active September 5, 2022 04:30
test2.json
[
{
"id": "gender",
"type": "select",
"question": "Gender?",
"options": [
{
"value": "0",
"label": "Decline to answer"
},
@leonmak
leonmak / test.json
Last active January 27, 2022 08:48
test
[
{
"id": "dateOfBirth",
"required": true,
"type": "date",
"question": "生年月日",
"format": "yyyy/MM/dd",
"min": "2008/01/02"
}
]
@leonmak
leonmak / auth.js
Last active May 24, 2021 14:05
chrome extension login id token
// need to use launchWebAuthFlow in chrome extension
// can't use gapi in extension
// https://github.com/google/google-api-javascript-client/issues/64
async function getIdTokenInfo(id_token: string) {
const resp = await fetch(
`https://oauth2.googleapis.com/tokeninfo?id_token=${id_token}`
);
return resp.json();
}
@leonmak
leonmak / pecs.java
Last active May 26, 2020 06:07
Producer extend Consumer super
import java.util.ArrayList;
import java.util.List;
class Scratch {
class Shark {
private final String name = "Sharkie";
public String getName() { return name; }
}// A
class HammerShark extends Shark{
@leonmak
leonmak / mac_word_move.plist
Last active May 30, 2019 05:59
iterm2 mac profile - word movement, deletion and pane selection
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AlternateMouseScroll</key>
<true/>
<key>AppleAntiAliasingThreshold</key>
<integer>1</integer>
<key>AppleScrollAnimationEnabled</key>
<integer>0</integer>
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)
@leonmak
leonmak / udfs.py
Created March 4, 2019 03:18
Union Disjoint Find Set
# if not root, find parent, set parent, return parent
p = map(chr, range(n))
def find(p, x):
if p[x] != x:
p[x] = find(p, p[x])
return p[x]
def union(p, i, j):
pi, pj = find(p, i), find(p, j)