Thursday, June 25, 2020

Generate FPS QR Code with customized amount


  1. Scan an existing QR code at https://zxing.org/w/decode.jspx https://qrcoderaptor.com to get the text content
  2. Remove the last 4 characters, which is the checksum (CRC), from the text content
  3. Spot the substring that contains the amount from the text content
  4. Replace the amount substring with new amount using the *same number* of characters, for example, replacing 
    • 1755.00
      • with
    • 0050.00
      • will update the amount from $1,755 to $50
  5. Calculate the new checksum
    1. http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
      1. width: CRC-16
      2. parametrization: Custom
      3. Polynomial: 0x1021
      4. Initial Value: 0xFFFF
      5. Input Data: String
      6. Paste the updated text content from above
      7. Click Calculate CRC
  6. Generate new QR code
    1. https://www.qrcode-monkey.com/#text
    2. Paste the updated text content appended with the new 4-character CRC
    3. Click Create QR Code


Ref: FPS QR code specification at https://www.hkma.gov.hk/media/eng/doc/key-functions/financial-infrastructure/infrastructure/retail-payment-initiatives/Common_QR_Code_Specification.pdf

Thursday, April 30, 2020

send email html content with inline image


  • preferred way:
    • script to generate html content with image encoded as base64 text
      • <img src='data:imag/png;base64,....'/>
      • base64.b64encode().decode("ascii") to get that ... string from image
    • single html file to include all the html and images, etc. 😀
    • cat that html and pipe to mutt -e "set content_type=text/html" to send the email

Tuesday, March 3, 2020

url to pdf on linux

yum install wkhtmltopdf
To manipulate the pdfs, use pdfunite / pdfseparate from
yum install poppler-utils

Saturday, December 28, 2019

centos minimal

install centos 8 minimal

install google-chrome from google repo, which should install all the X dependencies

additional language support for web page display
> yum groupinstall Fonts

To start chrome full screen
> X& DISPLAY=:0 google-chrome --window-size=1920,1080&

if sound is not already working,
> yum install alsa-utils
unmute everything with
> alsamixer
https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Disabling_auto_mute_on_startup



Wednesday, March 6, 2019

Monday, February 18, 2019

running graphical applications without desktop env


  1. install linux w/ desktop environment
  2. start run level 3
  3. $ X &
  4. $ DISPLAY=:0 google-chrome
  5. "You can switch from the X server and the framebuffer by using CTRL+ALT+F1 and CTRL+ALT+F7"

https://superuser.com/questions/407043/is-it-possible-to-run-graphical-applications-such-as-firefox-without-installing

Tuesday, January 1, 2019

save / print pdf without margin

Why?
pdf, including ones at research site ssrn, in general have huge margin.  when you wanna print 2 pages per sheet, the text become smaller with a lot of unnecessary white space for the margin

What do you need?
pdfcrop, which is available at ubuntu, but not centos7 afaik at the time of writing

How?
pdfcrop -h
pdfcrop <input.pdf> <output.pdf>

Appendix:
What if you don't have ubuntu?
if you have centos7 running on virtualbox with windows host, here's what I did:

  1. download ubuntu 18 desktop installation iso
  2. Virtualbox, existing vm, storage, optical drive
    1. select the downloaded iso
    2. check Live CD/DVD box
  3. start VM
  4. choose "Try ubuntu" after it boots from disc
  5. Follow https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt to update package download source
  6. Open a terminal in ubuntu
    1. sudo apt-get install texlive-extra-utils
    2. pdfcrop <input.pdf> <output.pdf>
  7. ubuntu map windows host's shared drive
    1. netstat -nr to see window host's ip address from ubuntu
    2. ubuntu "Files" app, which has a folder icon
    3. connect to Server by entering smb://<windows ip>
  8. drag and drop <output.pdf> to shared folder