Friday, 11 December 2020

Vanguard unit price plotting

  • I want to keep track of particular Vanguard ETFs
  • The Vanguard website doesn't let me track multiple ETFs
  • Turns out the Vanguard website relies on an externally exposed API
  • Along the way I picked up
    • JQuery
    • Plotly
  • https://vanguardplotly.kkwoo.repl.co/

Diceware offsite

  • I want to create passwords using my browser
  • Diceware is good
  • Not having physical dice and the Diceware list is inconvenient
  • I have a JS page on this blog already but I wanted to publish elsewhere
  • So I copied it to https://diceware-atyourownrisk.kkwoo.repl.co/

Chaos Theory Flash Game

  • There's a Flash game I like but Flash won't be supported past Dec-2020
  • I wrote a cut-down version with HTML5 at https://chaos-theory-flash.kkwoo.repl.co/
  • There were a few challenges
    • Getting started
    • Learning the following from scratch
      • HTML5
      • CSS
      • JS
      • Suitable libraries
        • At first I went with phaser and other game libraries
        • I departed from game libraries because they were suited to platform games and other traditional games involving a protagonist player and enemies 
        • So I chose Pixi.js
      • Pixi.js
      • GSAP
    • Limited concentration time
    • This led to increased planning
    • Resulted in several minimum viable products
      • Learning pixi.js
        • Get the quickstart working
        • Get shape sprites working
        • Get containers working
      • Get collision detection working
        • Copy/paste spicyoghurt code
      • Get tweening working
        • GSAP piece
      • Construct game logic
        • Something to play the game once
      • Add a main screen
      • Add a link to start a new game
        • I did this only because I'm tired of hitting reload on the browser and wasting mobile data
    • Next steps are
      • make it more like the original
        • Cool comments/insults based on scoring
        • 3 rounds instead of 1
      • refactor the code because it's terrible design
    • However, I'm content with the game as it now stands

"npx degit sveltejs/template abc" resulting in "could not fetch remote https://github.com/sveltejs/template"

  • at first I thought it was a firewall issue
  • I banged away trying different things including stopping the firewall
  • none of this worked because the firewall wasn't the problem
  • I was too thick to stop and walk away
  • instead I took the kids to swimming class
  • afterwards, I was playing around and ran "npx degit" for fun and induced an error and discovered:
    • (Use `node --trace-warnings ...` to show where the warning was created)
  • I ran "npx --trace-warnings degit sveltejs/template abc" which gave:
    • npm ERR! code ENOENT
      npm ERR! syscall spawn git
      npm ERR! path git
      npm ERR! errno -2
      npm ERR! enoent Error while executing:
      npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/sveltejs/template.git
      npm ERR! enoent
      npm ERR! enoent
      npm ERR! enoent spawn git ENOENT
      npm ERR! enoent This is related to npm not being able to find a file.
      npm ERR! enoent

      npm ERR! A complete log of this run can be found in:
      npm ERR!     /root/.npm/_logs/2020-12-12T04_25_29_798Z-debug.log
  • At first, I thought I was missing ssh
  • Then I discovered I was missing git
  • Running "npx --trace-warnings degit sveltejs/template proj02" resulted in failure
    • command not found: template
  • But once I removed "--trace-warnings" I had success:
    • DESKTOP-NNBAUML:~# npx  degit sveltejs/template proj01
      > cloned sveltejs/template#master to proj01

Friday, 22 May 2020

3 Auto-Resizing Graphs in JSFiddle

Refer to:

https://jsfiddle.net/kkwoo/m5jL8yhz/41/

Techniques used:
-  "height: 30vh;" in the CSS
-  "Plotly.Plots.resize(document.getElementById("output02a"));" on graphs requiring automatic resizing

Sources:
- https://stackoverflow.com/questions/1575141/how-to-make-a-div-100-height-of-the-browser-window
- https://bl.ocks.org/etpinard/edc678711ca231a8a4a5

Sunday, 12 January 2020

20200113: Installing Notepad++ 7.6 plugins

From <https://stackoverflow.com/questions/40015350/how-to-install-a-notepad-plugin-offline>:

Here are the steps that worked for me:
  1. Download the plugin and extract the plugin dll file.
  2. Place the plugin.dll file under plugin folder of notepad++ installation. For me it was : C:\Program Files\Notepad++\plugins
    • For me, I had to create a separate subdirectory under the plugins directory and place the DLL in the separate subdirectory
  3. Go to Notepad++ then : Settings -> Import -> Import plugin (import the plugin).
  4. Notepad++ will show the restart message / Sometimes it may not show it.
  5. Restart the notepad++.
  6. Should see new plugin under the Plugins menu. ALL DONE!!

Monday, 6 January 2020

20200107 - for-each in Google Script

Refer to <https://stackoverflow.com/questions/46693496/for-each-loop-in-google-apps-script>:

In Google Apps Script:
When using "for (var item in itemArray)",
'item' will be the indices of itemArray throughout the loop (0, 1, 2, 3, ...).

When using "for each (var item in itemArray)",
'item' will be the values of itemArray throughout the loop ('item0', 
'item1', 'item2', 'item3', ...).

Wednesday, 1 January 2020

20200102: Rabbit Warren 01 - M'Cheyne and Make

Goal:
- Make r/o REST API of the M'Cheyne Bible Reading Plan
- Use https://my-json-server.typicode.com/
- Scrape raw data from https://bibleplan.org/plans/mcheyne/
- PS w3m -dump -cols 132 https://bibleplan.org/plans/mcheyne/  
- Pre-process data
- Document pre-processing procedure with Makefile
- Install make
- Learn make
- Download Alpine container
- Create Dockerfile for Alpine+make (from https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
FROM alpine
RUN apk update
RUN apk add make
CMD /bin/sh
- upload to Docker Hub (from https://docs.docker.com/docker-hub/)
- PS C:\u\docker\alpine-make> docker build -t kkwoo/my-first-repo .
- PS C:\u\docker\alpine-make> docker run --rm -it kkwoo/my-first-repo
- PS C:\u\docker\alpine-make> docker login (from https://github.com/docker/hub-feedback/issues/1222)
- PS C:\u\docker\alpine-make> docker push  kkwoo/my-first-repo
- PS C:\u\docker\alpine-make> docker run -it --rm -v c:/u/docker/alpine-make:/mnt kkwoo/my-first-repo

Saturday, 28 September 2019

20180213: Android Camera Black Screen After Flashing SlimROM

20180213: Android Camera Black Screen After Flashing SlimROM

posted Feb 13, 2018, 3:54 PM by Kevin Woo
This was fixed by wiping the cache and the wiping the dalvik cache. The Gallery app started to load photos as well afterwards.

Dygraphs + R: JSON Visualisation for Vanguard

library(ggplot2)
library(httr)
library(jsonlite)
library(dygraphs)   # zoomable graphs
library(fasttime)   # for fastPOSIXct
library(data.table) # like using data.table

vanguardData <- function (productIDStr, startDate, endDate) {
  urlStr <- paste0("https://api.vanguard.com/rs/gre/gra/1.7.0/datasets/auw-retail-price-history-mf.jsonp?",
                   "vars=portId:",productIDStr,
                   ",issueType:S,sDate:",startDate,
                   ",eDate:",endDate,
                   ",as_of:DAILY&callback=angular.callbacks._4")
  rawData <- GET(urlStr) 
  return (fromJSON(strsplit(content(rawData, "text"), "[()]")[[1]][[2]]))
}

plotDygraph <- function (i01.vgdata, i02.title) {
  dgObj.01 <- as.data.table(i01.vgdata)
  dgObj.01[, asOfDate.ft := fastPOSIXct(substring(asOfDate, 1, 10))] # this one fails
  dygraph(dgObj.01[, .(asOfDate.ft, price)],
          main = i02.title) %>%
    dyOptions(useDataTimezone = FALSE) %>%
    dyBarChart() %>%
    dyRoller(rollPeriod = 1)
}

globalStart <- "2017-02-20"
globalStart <- "1996-02-10"
globalEnd <- "2019-02-20"
vg.8129 <- vanguardData("8129", globalStart, globalEnd) # Vanguard Index Australian Shares Fund
vg.8145 <- vanguardData("8145", globalStart, globalEnd) # Vanguard Index International Shares Fund
vg.8146 <- vanguardData("8146", globalStart, globalEnd) # Vanguard Index Hedged International Shares Fund

# compare buy price of different products
ggplot() +
  geom_jitter(data=vg.8129$fundPricesBuy,
              aes(x=asOfDate,y=price), color='blue') +  # Vanguard Index Australian Shares Fund
  geom_jitter(data=vg.8145$fundPricesBuy,
              aes(x=asOfDate,y=price), color='red') +   # Vanguard Index International Shares Fund
  geom_jitter(data=vg.8146$fundPricesBuy,
              aes(x=asOfDate,y=price), color='green')   # Vanguard Index Hedged International Shares Fund

plotDygraph(vg.8129$fundPricesBuy, "Vanguard Index Australian Shares Fund")
plotDygraph(vg.8145$fundPricesBuy, "Vanguard Index International Shares Fund")
plotDygraph(vg.8146$fundPricesBuy, "Vanguard Index Hedged International Shares Fund")

Wednesday, 28 March 2018

Javascript Diceware Selector

Click the button to simulate die roll. View the source to ensure everything here is above board:

Length:
Modulo result: