2023年11月4日 星期六

2023年10月11日 星期三

文字簡譜_Text To Numbered Musical Notation

 # 前言 Intro

這個APP的目的是要讓你可以用純文字來打出簡譜,並且播放出聲音。
This app's purpose is to let you compose numbered musical notations by simple pure texts.

2023年10月3日 星期二

音階寫程式/輸入文字 Pure tone programming/inputting

這個小程式的目的

是要讓你哼唱一段音階來輸入數字

然後再用一個特殊編碼把數字轉成文字

或是轉成控制符號 例如讓遊標上下左右

或是選取 退格 刪除 複製 等等

盡量讓你用純聲控能寫出一個程式來

This app's purpose: 

Let you sing some pure tones to input numbers

Then convert the numbers by a special encoding

to text or some controlling characters

to move the cursor up down left right

or do select backspace delete, etc

Make the best to let you program by pure tone

2023年9月18日 星期一

Almighty converter & Useful functions

# TextArea


My ID is p1

My ID is p2

*=already preloaded on this page

# 小工具 Utilities
  • *Object keys listing: objls( object_to_list_properties )
  • *Copy to clipboard: cbcopy( "text_to_copy" )
  • Download current page html
    Type `javascript:` at url and paste
  • Eruda Console: Paste as URL
    Type `javascript:` at url and paste
  • *jQuery
  • *Advanced alert and showlist:

# 數學 Mathematics
  • 排列Permutations: patt( array_of_items )
  • 組合Combinations: comb( array_of_items , number_of_selection )

2021年7月5日 星期一

Javascript object keys listing (no matter enumerable or not)

function objls(obj)
      {
          let objO=obj;
          let listK={};
          while(obj!=null)
            {
                Object.getOwnPropertyNames(obj).forEach(i=>{
                    listK[i]=1;
                });
                obj=obj.__proto__;
            }
          let ret=Object.keys(listK);
          let oname=objO.constructor.name;
          if(oname=="Number")
            ret.unshift(objO);
          else if(oname=="String")
            ret.unshift(objO.substr(0,1000));
          else if(oname=="Array")
            ret.unshift(objO.slice(0,10).join(","));

          ret.unshift(objO.constructor.name);
          return ret;
      }







2021年7月4日 星期日

Zip/Unzip folder in Node.js

First, install jszip by npm install jszip, then paste the following code

Then you can use genZip("folder/to/zip","abc.zip") and extractZip("abc.zip","folder/to/extract/to") as promises to zip/unzip your folder

You can also pass an Array to genZip's first argument to zip multiple files and folders

2021年1月14日 星期四

Copy to Clipboard

 function cbcopy(s){

  obj=document.createElement("textarea");

  obj.value=(s+"");

  document.body.append(obj);

  obj.select();

  document.execCommand("copy");

  obj.remove();

}




2020年6月23日 星期二

Web crawling By Puppeteer @ Node.js - Part 2/2, How to make it work on Android?


Outlines

1. Install ubuntu on Android by AndroNix
2. Install node.js and puppeteer
3. start web crawling
4. advanced adjustments to display chinese characters


2020年6月22日 星期一

Web crawling By Puppeteer @ Node.js - Part 1/2

# Introduction


  • Puppeteer is a node.js library that achieves web crawling by an automated chromium browser (chrome open source project)
  • Unlike other methods needing to send pure http requests and parse responses yourself, even needing to handle cookies manually, your syntax is simply: 
  • Launch browser -> emulate real user operations on the web page -> get any data that is reachable by a real user

Web crawling by puppeteer is very simple.

This is part 1/2, in part 2/2 I'll demonstrate how to make it work on Android

# Getting Started

Start by installing:

  • npm install puppeteer

2019年10月17日 星期四

Javascript combinations enumeration (not fast)

comb=function(a,n){
  var ids=new Array(n).fill(0).map((i,ind)=>ind);
  var res=[];
  //console.log(indexes);
  var evs="";
  for(i in ids)
    evs+=`for(ids[${i}]=((ids[${i}-1]==null)?(-1):ids[${i}-1])+1;ids[${i}]<=a.length-n+${i};ids[${i}]++){\n`;
  evs+=`res.push(a.filter(    (ii,ind)=>(ids.indexOf(ind)!=-1)    ));\n`;
  evs+="}\n".repeat(n);
  console.log(evs);
  eval(evs);
  return (res);
}





2019年9月23日 星期一

Simple dialog / list dialog in javascript using jquery & bootstrap




First, include jquery and bootstrap

2019年9月3日 星期二

WebUSB/Arduino on Windows 8 - How to make it work

Recently I'm playing with arduino and hoped to utilize the WebUSB API to enable cross-platform control over my arduino board. Here's some directions on how to get it work:

Outlines

  • Get a board that is compatible: I used Arduino Leonardo
  • Download ArduinoDroid for Android
  • Download WebUSB library
  • Upload your sketch to the board
  • Install Zadig on your windows to replace the original Driver and let it work

2019年8月27日 星期二

Javascript Permutations Enumeration (not fast)

patt=function(arr){
if(arr.constructor.name!="Array")
  return [];
arr=arr.slice();
if(arr.length==1)
  return [arr];
else if(arr.length==2)
  return [arr,arr.slice().reverse()];
else
 {
  let sum=[];
  let el=arr.shift();
  let darr=patt(arr);
  for(var i in new Array(arr.length+1).fill(0))
    sum.push(...darr.map(item=>
      {
        let cp=item.slice();
        cp.splice(i,0,el);
        return cp;
      }));
  return sum;
 }
};





2019年7月30日 星期二

Webusb test










External library from
https://github.com/webusb/arduino





2019年7月16日 星期二

2019年7月14日 星期日

A javascript analog of python's range

var range=(a,b,c)=>
  {
    if(!b) b=1;
    if(!c) c=1;
    let arr=new Array(Math.floor(Math.abs(a-b)/c)+1).fill(0);
    arr=arr.map((i,ind)=>(ind*(b-a)/(arr.length-1)+a));
    return arr;
  };