Skip to content

Instantly share code, notes, and snippets.

@pastleo
pastleo / try-proxy.js
Created October 18, 2019 09:28
experiments about js proxy api
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
const magicObj = new Proxy({}, {
get: (obj, name) => {
if (obj[name] === undefined) obj[name] = 1;
else obj[name]++;
return obj[name];
},
set: (obj, name, value) => {
if (obj[name] === undefined) return Reflect.set(obj, name, value); // will explain below
else return Reflect.set(obj, name, obj[name] + value);
@pastleo
pastleo / try-event-target.js
Created October 18, 2019 09:27
experiments about EventTarget and nodejs polyfill
const isBrowser = (function() {
try { return !!window; } catch (_) { return false; }
})();
if (isBrowser) {
window.global = window;
}
const Event = isBrowser ? class extends window.Event {
constructor(type, payload) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
body {
margin: 0;
height: 100vh;
width: 100vw;
@pastleo
pastleo / asdf-erlang-openssl-not-found-arch.md
Last active December 24, 2023 12:09
asdf erlang openssl not found issue in archlinux

asdf erlang openssl not found issue in archlinux

using asdf to install erlang:

asdf install erlang 19.3

but I got:

@pastleo
pastleo / blue-tether-nmcli.md
Created August 9, 2018 05:10
bluetooth tethering using NetworkManager

bluetooth tethering using NetworkManager

  1. pair and connect with the Android phone, remember to enable bluetooth tethering on Android
  2. nmcli device should have a new device with type: bt, copy the device name, i.e. AA:BB:CC:DD:EE:FF
  3. nmcli device connect AA:BB:CC:DD:EE:FF

in KDE Plasma, connection should show up on system tray

@pastleo
pastleo / litelement-webcomponent-pastleo.md
Created July 6, 2018 04:44
LitElement - 像 React 一樣寫 WebComponent

LitElement - 像 React 一樣寫 WebComponent

2018/6/21

在 React, Vue 還不存在的時代,純粹透過 jQuery 或是 DOM API 撰寫 User interface ,不過問題就是 html, js 容易進入混亂的狀態,沒有元件的概念,不好模組化,所以許多人一直發(ㄔㄨㄥˊ)明(ㄗㄠˋ)工(ㄔㄜ)具(ㄌㄨㄣˊ)幫助開發

也有另一派人馬希望可以透過改善瀏覽器本身 API 來做到元件化開發,因此 WebComponent 的概念就出現了,WebComponent 包含了許多面向,我覺得最重要的部分是 Custom Elements

什麼是 Custom Element?

[Desktop Entry]
Version=1.0
Exec=python ~/.bin/iio-rotate.py
Name=IIO rotate
GenericName=IIO rotate
Comment=IIO rotate
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;System;

notes from Google IO 2018 polymer 3.0

youtube video

  • custom element
  • shadow root
  • html imports
  • polymer 3.0
    • use npm instead
@pastleo
pastleo / personal-income-tax-docker-arch.md
Last active April 30, 2021 07:07
綜合所得稅申報系統 Docker Image that ArchLinux can use

綜合所得稅申報系統 Docker Image that ArchLinux can use

在 2021/4/30 更新給 google 到這邊的朋友們:

這篇很可能已經不能用,原作者也有更新導致下方連結失效,原作者 repo: https://github.com/chihchun/personal-income-tax-docker/

同時在筆者稍微了解此這邊的技術架構後,偏好讓 docker 只執行最小需要虛擬的部份,也就是只有健保卡元件 mLNHIICC,因為政府網站只有提供給 Ubuntu, Fedora 用的 binary,其他部份可以用原本 host 的軟體就用原本 host 的軟體,改成筆者的版本,有興趣的朋友也歡迎參考:

@pastleo
pastleo / README.md
Last active February 14, 2018 10:04
kkbox-player-full-screen css overwrite

kkbox-player-full-screen css overwrite

this make the kkbox web player full screen with lyrics

How to use?

  1. install stylus first: https://add0n.com/stylus.html
  2. head to Stylus manage page, click Write new style
  3. Click import, and choose kkbox-player-full-screen.css