Skip to content

Instantly share code, notes, and snippets.

View WJWang's full-sized avatar

William Wang(Wei) WJWang

View GitHub Profile
@WJWang
WJWang / machine.js
Created April 25, 2021 20:03
Generated by XState Viz: https://xstate.js.org/viz
const spotFuture = Machine({
type: 'parallel',
states: {
'建立部位': {
initial: '現貨數 < 設定目標數',
states: {
'現貨數 < 設定目標數': {
on: {
'買現貨': '期貨空單數 < 現貨數',
},
@WJWang
WJWang / machine.js
Created April 25, 2021 19:43
Generated by XState Viz: https://xstate.js.org/viz
const spotFutureCreate = Machine({
id: '建立部位',
initial: '現貨數 < 設定目標數',
states: {
'現貨數 < 設定目標數': {
on: {
'買現貨': '期貨空單數 < 現貨數',
},
},
'期貨空單數 < 現貨數': {
@WJWang
WJWang / DemoError.jsx
Last active December 10, 2019 07:19
ProgressRing in React Hooks
import React, { useState, useEffect } from 'react';
import T from 'prop-types';
import Ring from './components/Ring';
const targetProgress = 95;
function DemoErrorRing() {
const [progress, setProgress] = useState(0);
useEffect(() => {
@WJWang
WJWang / Observer_Class.js
Last active September 3, 2019 19:29
Vue 2.6.10 Study (Reactivity)
export class Observer {
value: any;
dep: Dep;
vmCount: number; // number of vms that have this object as root $data
constructor (value: any) {
this.value = value
this.dep = new Dep()
this.vmCount = 0
def(value, '__ob__', this)
@WJWang
WJWang / QREncrypter.cs
Created August 12, 2019 19:31 — forked from imrehg/QREncrypter.cs
QR code encryption code for Taiwanese electronic invoice
namespace tw.gov.nat.einvoice.qrutil {
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
public class QREncrypter {
public string AESEncrypt(string plainText, string AESKey) {
byte[] bytes = Encoding.Default.GetBytes(plainText);
ICryptoTransform transform = new RijndaelManaged { KeySize = 0x80, Key = this.convertHexToByte(AESKey), BlockSize = 0x80, IV = Convert.FromBase64String("Dt8lyToo17X/XkXaQvihuA==") }.CreateEncryptor();
@WJWang
WJWang / blocker-sample.js
Created March 22, 2019 22:21
blocker-sample.js
// 單人
ARTIST_ID_BLACKLIST=["Tqyk2VnYD3.Md.I0F01bv08J"]
// 多人
ARTIST_ID_BLACKLIST=["藝人編號1", "藝人編號2"]
@WJWang
WJWang / blocker.js
Created March 22, 2019 22:16
KK Webplayer Blocker
let ARTIST_ID_BLACKLIST = [];
setInterval(() => {
if (!!~ARTIST_ID_BLACKLIST.indexOf(JSON.parse(localStorage.getItem('ngStorage-playing')).current.song.artist_id)) {
[]
.filter
.call(document.querySelector('#player > div.controls').children, child => child.getAttribute('title') === '下一首')
.forEach((el) => {
if (el.fireEvent) {
el.fireEvent('onclick');
} else {
<template lang="html" id="autocomplete">
<div class="sample-row row autocomplete-wrapper">
<div class="autocomplete row">
<div class="sample-col sample-col col-xs-1 sample-col col-form-label area-label">{{ title }}</div>
<div class="sample-col col-xs-6">
<input class="form-control" type="text" placeholder="search word here..." @blur="emptyInput" v-model="searchWord" maxlength="40" />
<span class="fold-icon" @click="emptyInput" v-if="!!searchWord">
<i class="fa fa-close" aria-hidden="true"></i>
</span>
<transition name="fade">
<template lang="html">
<div v-if="processing">
<button disabled>play</button>
<input type="range" v-model="volume" />
</div>
<div v-else>
playing at : {{ playTime }} / {{ songDuration }} secs<br>
Position: <input type="text" v-model="position" /> %
<br>
<button @click="play" v-if="!isPlaying">play</button>