Skip to content

Instantly share code, notes, and snippets.

View FlandreDaisuki's full-sized avatar
🌈
世界にバグは不要です

Chun-Hao Lien FlandreDaisuki

🌈
世界にバグは不要です
View GitHub Profile
@FlandreDaisuki
FlandreDaisuki / index.html
Last active August 21, 2021 08:38
single-page-file-watcher-poc
<pre><code id="output"></code></pre>
<script>
// https://stackoverflow.com/a/59925724
if (/^file:\/\/\//.test(location.href)) {
let path = './';
let orig = fetch;
window.fetch = (resource) => ((/^[^/:]*:/.test(resource)) ?
orig(resource) :
new Promise(function(resolve, reject) {
let request = new XMLHttpRequest();
@FlandreDaisuki
FlandreDaisuki / webkit-selector-list-bug.html
Last active June 11, 2021 05:55
Webkit ignores the CSS rule that its selector list contains unknown pseudo element selector
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Webkit Selector List Bug</title>
</head>
@FlandreDaisuki
FlandreDaisuki / sync.sh
Last active June 6, 2021 09:18
Download youtube playlist
#!/bin/bash
# usage:
# # if you install youtube-dl locally
# $ type youtube-dl
# youtube-dl 是 /usr/bin/youtube-dl
# $ bash sync.sh
#
# # if you use youtube-dl by docker alias
# $ type youtube-dl
@FlandreDaisuki
FlandreDaisuki / foo.ts
Created March 30, 2021 02:07 — forked from OliverJAsh/foo.ts
Records and dictionaries in TypeScript
/*
In JavaScript, objects can be used to serve various purposes.
To maximise our usage of the type system, we should assign different types to our objects depending
on the desired purpose.
In this blog post I will clarify two common purposes for objects known as records and dictionaries
(aka maps), and how they can both be used with regards to the type system.
@FlandreDaisuki
FlandreDaisuki / sum.js
Last active May 1, 2020 14:18
應該是最美的 currying sum
// ref: https://t.me/JavaScriptTw/52631
function sum(...args) {
const total = args.reduce((p, c) => p + c);
const sumFunc = sum.bind(null, total);
sumFunc.valueOf = () => total;
return sumFunc;
}
import AbortController from "abort-controller"
import { AbortSignal } from "abort-controller"
import { AbortablePromise } from "."
var controller = new AbortController()
function sleep (signal: AbortSignal, time: number) {
return AbortablePromise(signal, function (resolve, reject, handleCancel) {
var id = setTimeout(resolve, time)
handleCancel(() => {
@FlandreDaisuki
FlandreDaisuki / luxin.sh
Created January 16, 2019 14:52
u need curl and jq
#!/bin/sh
# 還願機器人
# 用法:
# $ chmod +x ./luxin.sh
# $ ./luxin.sh '陸心是誰創辦的?'
# {
# "type": "text",
# "data": "陸心青年服務團是由陸恭銘先生在1987年所創立。"
# }
@FlandreDaisuki
FlandreDaisuki / Patchouli-custom-style.user.css
Last active August 27, 2018 16:58
安裝 Stylus(https://github.com/openstyles/stylus/#releases) 然後點 Raw 安裝,安裝好後到 pixiv 可點 Stylus 齒輪設定顏色。 Raw在這---↓
/* ==UserStyle==
@name Patchouli 自訂樣式
@namespace https://github.com/FlandreDaisuki
@version 4.2.0-alpha
@description Patchouli 自訂樣式
@author FlandreDaisuki
@var color illust-title-visited-color "拜訪過的連結顏色" #FF0000
==/UserStyle== */
@-moz-document domain("pixiv.net") {
@FlandreDaisuki
FlandreDaisuki / triangle.bf
Created May 14, 2018 20:19
Can input a digit character and print the triangle
>++++++[<+++++++>-]
++++++++++>
,
>++++++[<-------->-]<
[
>+
[
>+>+<<-
@FlandreDaisuki
FlandreDaisuki / README.md
Last active June 23, 2018 21:45
self-hosted clock

安裝方式

  1. 安裝 node
  2. 新增一個資料夾放入index.js
  3. 到資料夾下安裝 node-canvas
$ npm i canvas