Python setup in server

Problem: I have server access but I don’t have root privileges. Pyenv # Install pyenv $ curl | bash # Follow the instruction to modify ~/.bashrc # Install the latest Python from source code $ pyenv install 3.9.7 # Check installed Python versions $ pyenv versions # Switch Python version $ pyenv global 3.9.7 # Check where Python is actually installed $ pyenv prefix /home/admin/.pyenv/versions/3.9.7 Install pip Download pip from an online repository and add the path to your bashrc....

September 6, 2021

Peeking PayNow

PayNow QR is a unified payment across 9 banks in Singapore. It is interesting to peek at what is actually behind the QR code that power our daily payments

July 3, 2021

Kelly's Criterion

Kelly’s Criterion Assumption: You know the probability of success $p$. For an investment decision where the probability of success is $p$ If you succeed, the value of your investment increases from 1 to $1 + b$ If you fail (with probability $q = 1-p$), the value of your investment decreases from 1 to $1 - a$ Then the asymptotically optimal fraction of the current bankroll to wager is defined as $$f^* = \frac{p}{a} - \frac{1 - p}{b}$$...

May 29, 2021

Active Learning

Active Learning Active, because it is able to query instances based on past queries/response Overview Problem: Have access to lots of data, but infeasible to annotate everything. Key Assumption: if the algorithm were allowed to choose the data it wants to learn from, it could attain a higher level of accuracy while using a smaller number of training labels. Solution: The algorithm interactively pose queries (choose an instance of unlabelled data) for human to label....

May 24, 2021

Conflict-free Replicated Data Type (CRDT)

CRDT is a class of data structures that allows modifications in distributed environments to be applied on top of each other without any conflicts and in a consistent manner.

May 22, 2021

OAuth 2.0

OAuth 2.0 is an authorization scheme that is widely used today. In this note, we discussed oauth’s common flows, its tradeoffs and when to use each flow.

May 22, 2021

Mac must-haves

A list of must-haves when you setup a mac

May 8, 2021

Git Tricks

Git tricks Force pull git fetch origin master git reset --hard origin/master Add deleted files to index git add . tracks file deletion (but adds other files as well) For the index to track single file deletion, git add $(git ls-files --deleted) can do the job. If you want to also handle space in file name, you can do SAVEIFS=$IFS IFS=$(echo -en "\n\b") # change IFS to \n\b to handle space in filename :( git add `git ls-files --deleted` IFS=$SAVEIFS Edit last commit git commit --amend --no-edit...

February 3, 2021

Heroku Monorepo

Deploying monorepo + heroku Related repo: CS2102 Project Repo Based on: Heroku-Node-Pg Monorepo + Heroku What I’ve tried (but don’t work) Buildpacks Manually building by utilizing postinstall script which will run after Heroku finish installing dependencies. Heroku will complain cannot find dependency. Building the application on process run. Not feasible: Heroku will terminate your process if it doesn’t bind to a port within 60 secs. Checking in the build files to git (but still in its own packages)....

November 13, 2020

Sunfire as Git Server

Setting up sunfire as a remote git server Background CS2105 HW involves testing in a remote server (sunfire) and I want to use git. So, I need to use it as a git server, and then I can sync changes using my usual git workflow. Problem Encountered command: git-upload-pack not found, although git is installed Solution Digging, the above problem is caused because git-upload-pack is not in the non-interactive $PATH used by git when ssh....

October 2, 2020