This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Xiaomi LightBar Controller</title> | |
<style> | |
* { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Download & Trim Video | |
# ./run.sh video_id out.mp4 00:00 1:00 | |
OUTPUT_FILE=$2 | |
VIDEO_ID=$1 | |
yt-dlp --quiet --force-overwrites \ | |
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import time | |
from transformers import ViTFeatureExtractor, ViTForImageClassification | |
from PIL import Image | |
import json | |
from flask import Flask, request | |
app = Flask(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Note: Not the fastest solution! It's a demo on how to use bitwise operator to avoid branching. | |
* Convert 24-hour time to 12-hour. | |
* @returns {string} | |
* @param {number} a 24-hour number. | |
*/ | |
function to12time(a) { | |
return (a - 1) % 12 + 1 + String.fromCharCode(112 - 15 * (a < 12 ^ 0)) + "m" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function lunar(date = new Date()) { | |
const aharakoune = y => (y * 292207 + 373) % 800; | |
const harakoune = (y) => Math.floor((y * 292207 + 373) / 800) + 1; | |
const avomane = (y) => (11 * harakoune(y) + 650) % 692; | |
const regularLeap = y => (800 - aharakoune(y)) <= 207 | |
function bodethey(y) { | |
const ha = harakoune(y); | |
return (ha + Math.floor((11 * ha + 650) / 692)) % 30; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An average of a set of numbers. | |
* @param {number[]} values | |
* @returns {number} | |
*/ | |
export function mean(...values) { | |
if (values.length === 0) return; | |
return values.reduce((a, b) => a + b, 0) / values.length; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SPACE_CODEPOINTS = [ | |
0xa, // newline r | |
0xd, // newline r | |
0x9, // tab, | |
0x0020, // space | |
0x00A0, // no-break space | |
0x1680, // Ogham space mark | |
0x180E, // Mongolian vowel separator | |
0x2000, // en quad | |
0x2001, // em quad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import { load } from 'cheerio' | |
import fs from 'fs/promises' | |
import fse from 'fs-extra' | |
import Interpreter from 'js-interpreter' | |
// download provinces list | |
async function downloadProvinceList() { | |
const { data: html } = await axios.get('https://www.cambodiapost.post/page/postal-codes', { responseType: "text" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const km2ascii = (s) =>[...s].reduce((p,c)=>p+(c=c.charCodeAt(0),String.fromCharCode(c-(c>=6112&&c<=6121?6064:0))),'') | |
km2ascii('1234abc១២៣៤') | |
// => '1234abc1234' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MagicString from "magic-string"; | |
/** | |
* Automatically insert ZWSP into text. | |
* @param {string} value | |
* @param {string | undefined} sep | |
* @returns {string} | |
*/ | |
export function insertZeroWidthSpace(value, sep = '\u200b') { |
NewerOlder