Skip to content

Instantly share code, notes, and snippets.

View mingtsay's full-sized avatar
🇹🇼

Ming Tsay mingtsay

🇹🇼
View GitHub Profile
@mingtsay
mingtsay / boorkmarklet.md
Last active June 7, 2022 06:40 — forked from 71/boorkmarklet.md
Lists all participants in a Google Meet meeting.

The following bookmarket shows a popup with the name of the participants separated by comma(,) .

javascript:((n=2e3)=>{try{function h(a,b=0){if(b>7||"object"!=typeof a||null===a||a===window)return;let c=Object.getOwnPropertyDescriptors(a);for(let d in c){if(d.startsWith('["spaces/'))return Object.values(a);let e=h(c[d].value,b+1);if(void 0!==e)return e}}let i=Object.entries(window).find(a=>a[0].startsWith("closure_lm_"))[1],e=h(i),a=[];function j(b){for(let c in b){let a=b[c];if("object"==typeof a&&null!==a&&"string"==typeof a[1])return a[1]}}for(let c=0;c<e.length;c++){let f=j(e[c]);-1===a.indexOf(f)&&a.push(f)}if(0===a.length)throw new Error("Could not find any name.");a.sort((a,b)=>a.localeCompare(b));let g=a.slice(1).reduce((a,b)=>(a[0].length+b.length+1>=n?a.unshift(b):a[0]+=", "+b,a),[a[0]]).reverse();for(let b=0,{length:d}=g;b<d;b++){let k=1===d?"":" ("+(b+1)+"/"+d+")",l="Please find the list of participants below"+k+".";if(null===prompt(l,g[b]))break}}catch(m){alert("Unexpected error when runni
@mingtsay
mingtsay / npm_chpwd_hook.sh
Created November 9, 2020 02:09 — forked from nunofgs/npm_chpwd_hook.sh
Adds node_modules/.bin to the PATH (zsh)
if ((!$+commands[npm])); then
return 1
fi
# Adds node_modules/.bin to the PATH
npm_bin_hook() {
if [ -n "${OLDPATH+x}" ]; then
PATH=$OLDPATH
unset OLDPATH
fi
// 1~7 16(0) = C4, 16(1) = #C4
// 8(0) = C4, 8(1) = C5
// 32(1) 8(0) = C3, 8(1) = C6
unsigned short notes[] = {
0, NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_B4,
0, NOTE_C5, NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5,
0, NOTE_CS4, NOTE_EB4, NOTE_F4, NOTE_FS4, NOTE_GS4, NOTE_BB4, NOTE_C5,
0, NOTE_CS5, NOTE_EB5, NOTE_F5, NOTE_FS5, NOTE_GS5, NOTE_BB5, NOTE_C6,
0, NOTE_C3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, NOTE_A3, NOTE_B3,
0, NOTE_C6, NOTE_D6, NOTE_E6, NOTE_F6, NOTE_G6, NOTE_A6, NOTE_B6,
<?php
$cities = [
'Taipei',
'NewTaipei',
'Taoyuan',
'Taichung',
'Tainan',
'Kaoshiung',
'KinmenCountry',
'TaipeiCloud',
@mingtsay
mingtsay / keybase.md
Created October 31, 2017 19:22
Proving my GitHub for Keybase

Keybase proof

I hereby claim:

  • I am mingtsay on github.
  • I am mingtsay (https://keybase.io/mingtsay) on keybase.
  • I have a public key ASCyGXEX0b6wv4_7b-D6VB7_sgI_iCTQBrR3F5l6jogGMwo

To claim this, I am signing this object:

@mingtsay
mingtsay / mcu-att-abs.js
Last active October 19, 2017 03:22
for MCU Attending form select all for personal leave
(function(d){
var f = d.getElementsByTagName("select");
for (var i in f) {
if (f[i] && !f[i].disabled) {
f[i].selectedIndex = 0;
}
}
}(document));
/*
Usage: put the following link into your bookmark
HOSTNAME=centos.mt.rmstudio.tw
SHELL=/bin/bash
TERM=xterm-256color
HISTSIZE=1000
USER=root
LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*
@mingtsay
mingtsay / itsa20161027-4-dp.knr-style.cpp
Last active October 26, 2016 20:22
布丁阿嬤的煩惱
#include <iostream>
using namespace std;
int T, N, G, c, w, C[1000], W[1000];
int knapsak() {
int dp[35] = {0};
for (int i = 0; i < N; ++i)
for (int j = w, k; (k = j - W[i]) >= 0; --j)
dp[j] = max(dp[j], dp[k] + C[i]);
@mingtsay
mingtsay / pwgen.php
Last active February 3, 2019 04:53
Password Generator by Ming Tsay
<?php
define('PWGEN_SYMBOLS', 0x01);
define('PWGEN_NUMBERS', 0x02);
define('PWGEN_LOWERS', 0x04);
define('PWGEN_UPPERS', 0x08);
define('PWGEN_EX_SIMILAR', 0x10);
define('PWGEN_EX_AMBIGUOUS', 0x20);
define('PWGEN_SEPARATOR_ARRAY', 0);
define('PWGEN_SEPARATOR_LF', 1);
define('PWGEN_SEPARATOR_CR', 2);
@mingtsay
mingtsay / ibon-doc-refresh.js
Last active August 29, 2015 14:27
script for ibon document upload view status (for http://www.ibon.com.tw/printscan_ie.aspx#D0131)
// save the interval id for stop the script
window._ibon_doc_interval = setInterval(function() {
// function for get element by id
b = function(id) { return (this.getElementById ? this : document).getElementById(id); };
// close the status window if exists
if (a = b("majorContents"))
b.call(a.contentDocument, "inquiry_btn").getElementsByTagName("a")[0].click();
// fill in the document code