Skip to content

Instantly share code, notes, and snippets.

View kfwong's full-sized avatar
🏠
Working from home

Wong Kang Fei kfwong

🏠
Working from home
View GitHub Profile
"use strict";
var Heap = require('heap');
class Cell{
constructor(row, col, dist){
this.row = row;
this.col = col;
this.dist = dist;
}
@kfwong
kfwong / decorator-pattern.ts
Created October 23, 2019 04:28
Decorator Pattern
interface Greetable{
greet(): String;
}
class Person implements Greetable{
constructor(public name: String) { };
greet(): String {
return "Hello";
}
@kfwong
kfwong / notes.swift
Last active December 18, 2017 07:36
Notes on the features I learn in Swift.
enum WeatherType {
case sun
case cloud
case rain
case wind
case snow
}
// Enumeration with Type Inference
func getHaterStatus(weather: WeatherType) -> String? {
1 CXXLVNZCR 1
1 XPDKYGHCVQMBFHISNIC 1
1 RAEGYEKIAOSVJOSGIAEZWVBIN 1
1 HCHBDDBLKEGFALA 2
1 RDABAHEOPEISLSRA 2
1 PTCRVQROAQNKDHXTMBMYNEIR 2
1 QHPVGCAK 2
1 JASKNVCHKA 1
1 IBUIKZ 2
1 TOIQRHO 2
@kfwong
kfwong / android ion example.java
Created May 24, 2016 09:25
for android example stuff
package com.synchro.synchro_model01;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
for( var i = 0; i< 5; i++){
var x = 1000;
}
console.log(x); //give 1000
@kfwong
kfwong / svn-useful-command.md
Created December 22, 2014 09:10
SVN of some useful commands

To "unadd" files (not committed)

# svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm

Do not use wildcard (*) when adding files in svn, because all ignored files will be added regardless of settings, instead:

# svn add --force .
@kfwong
kfwong / mongodb-document-subarray-find.json
Created November 3, 2014 08:13
mongodb document subarray find
function () {
var tagsJson = '{"tags":[{"confidence":43.10115825222821,"tag":"flower"},{"confidence":35.64136447136573,"tag":"pink"},{"confidence":28.634130526364913,"tag":"blossom"},{"confidence":26.31923191840067,"tag":"spring"},{"confidence":25.342480116322598,"tag":"garden"},{"confidence":25.186642759326695,"tag":"flowers"},{"confidence":25.01607544605281,"tag":"petal"},{"confidence":24.922798569394423,"tag":"plant"},{"confidence":23.854798038972252,"tag":"floral"},{"confidence":23.6310246044367,"tag":"bloom"},{"confidence":21.284477322919674,"tag":"flora"},{"confidence":16.41916774293343,"tag":"summer"},{"confidence":15.924073499807283,"tag":"botanical"},{"confidence":14.153358313439634,"tag":"blooming"},{"confidence":13.941621753334235,"tag":"petals"},{"confidence":13.355016885025824,"tag":"leaf"},{"confidence":13.263226955288609,"tag":"color"},{"confidence":12.762897096197667,"tag":"natural"},{"confidence":12.304395954588891,"tag":"fresh"},{"confidence":11.942053845058787,"tag":"bouquet"},{"confidenc
@kfwong
kfwong / mongodb-rockmongo-aggregation-grouping-pushing.json
Created October 20, 2014 07:28
Rockmongo aggregation, grouping, pushing
{
aggregate : "images",
pipeline : [
{ $group: {"_id": "$albumId", "data": {$push :
{
"title": "$title",
"description": "$description"
}
}}}
]