vim system clipboard setup

How vim interact with the system clipboard is something always tricky and debatable as vim carries its own register. Current Setting My previous way is using the vim register for operations like y, d, x etc and use a mapping of ctrl+c to copy the content to system clipboard like vmap <C-c> “+y to copy…

typeof and Mapped type in Typescript

I was reading an article introducing the usage of the typeof and Mapped type which was introduced back in TS 2.1. It is quite interesting that typescript can actually make generic of generic and infer the types of properties and then use them for border extensions. For typeof it basically yields the type of permitted property names. A keyof…

My first TS custom decorator

Background Was reading some nestjs related documentation and found the custom decorator portion quite interesting. So decided to write one myself. Decorator vs Annotation Syntax-wise decorator in Typescript is quite similar to the annotation in Java where we can assign metadata information to class/field/method. However under the hood, they are quite different. One of the major…

Google home not responding to ‘Hey Google’ but ‘Okay Google’

Recently I found my Google home becomes a bit silly. It never responds to my Hey Google command any more like before. However Okay Google still works. Also while playing my Google music playlists, it randomly stops and drops songs which is quite annoying. Then I notice in the version, its language value is Japanese which I set…

site diff tool with puppeteer

Background   We recently have a requirement to do a site diff tool so that we can compare our pages in qa and prod to make sure the changes go in is expected. Existing Stack There used to be a version that works but a bit complicated. The existing stack is user provides a list…

lambda@edge prototype

Recently I was doing a MVP for replacing a ELB/EC2/Docker based static site preview stack with a cloudfront/lambda/s3 based one. Background The purpose of this is to reduce the maintenance we has to do with the EC2 stack like regular AMI update. reduce the complexity of the stack  as the previous one involves building custom…

nginx reverse proxy S3 files

China access issue Recently some of our church site users reported that the sermon audio/video download feature does not work any more. We recently moved our large files from file system to s3. After some research looks like the aws s3 is blocked by the famous Chinese Great FireWall(GFW). Possible Solutions Moving files back to…

pipe operator in rxjs

Pipe is introduced so that we can combine any number of operators. const source$ = Observable.range(0, 10); source$ .filter(x => x % 2) .reduce((acc, next) => acc + next, 0) .map(value => value * 2) .subscribe(x => console.log(x)); Above can be converted to: const source$ = Observable.range(0, 10); source$.pipe( filter(x => x % 2), reduce((acc,…

unsubscribe in rxjs(angular 2+)

background In reactive world(rxjs/ng2+), it is common and convenient to just create some subject/observable and subscribe to them for event handling etc. It is like the gof observer pattern​ out of the box. issue One caveat we recently have is, we call subscribe() of some subjects from our service in our ngOnInit or ngAfterViewInit funtions we forget to…

sessionStorage/localStorage scope

Firstly, localStorage and sessionStorage are 2 objects on the window object. They tie to the origin of the current window. As a result they are bind to : protocol, http/https are different domain subdomain can share with parent by manually setting document.domain. xxx.capitalone.com cannot share with yyy.capitalone.com port Same thing apply to 302 redirect. The session/local storage value…

debug typescript mocha and server in vscode

We recently are developing a graphql api using apollo server and Typeorm on top of Aws Lambda. Code-wise is kind of straightforward with schema defined, then resolvers then service layer then dao layer then model defined typeorm with its annotations/decorators. However there are 2 issues related to debugging, unit test and run graphql local. unit…

aws cli ProfileNotFound

I was trying to do some KMS encryption for some of our prod credentials with aws cli. After pulling down the temporary aws sts token for prod roles and run the aws –profile SOME_PROD_ROLE kms encrypt xxx, the  botocore.exceptions.ProfileNotFound: The config profile (SOME_DEV_ROLE) could not be found constantly pop up. I checked the ~/.aws/credentails file and make…