Skip to content

Instantly share code, notes, and snippets.

View khatv911's full-sized avatar

khatv911

  • Singapore
View GitHub Profile

Kotlin for Javascript DEVs... or vice versa

what in common:

  • Modern Syntax
  • OOP + FP
  • Multiplatform

Variables & Constants

// blueprint
open class EpoxyModel {
fun bind() {}
}
class Factory(
val key: Int,
val createModel: (Any) -> EpoxyModel
)
@khatv911
khatv911 / coinchange.js
Created February 20, 2019 06:38
Coin change
fun coinChange(n, coins)
dp=[]// n+1 items
dp[0]=0
for i from 1 to n
minCoins = maxint
for(coin in coins)
if(i >= coin)
min = Math.min(min, dp[i -coin]+1)
dp[i] = min
@khatv911
khatv911 / max_substring.js
Last active February 17, 2019 12:30
find max substring
// find max substring
// using dynamic programming
// Time: O(n)
var maxSubString = s => {
if (s.length <=1) return s
let dp = [] // max-len of the substring at index i
var idx=0// mark start index of max substring
dp[0] =1
for(var i=1; i < s.length; i++){
@khatv911
khatv911 / Home.js
Created May 11, 2017 04:40
Hidden SearchBar on scroll
import React, { Component } from 'react';
import { SectionList, StyleSheet, Text, View, ScrollView, Animated } from 'react-native';
import { SearchBar } from 'react-native-elements';
import { Navigation } from 'react-native-navigation';
import LCE from '../../../../global/LCE';
import RoomRowActionButtonList from './RoomRowActionButtonList';
import RoomCell from './RoomCell';
import { CHECK_OUT_TYPE, CHECK_IN_TYPE, STAY_OVER, CHECKED_OUT_TYPE, PROFILE_ACTION, EDIT_ACTION, DATES_ACTION, CASHIER_ACTION } from '../../../../global/constants';
import SectionHeader from './SectionHeader';
const {SeparatorComponent} = require('../../../../global/components/sectionComponent.js');
@khatv911
khatv911 / SectionHeader.js
Last active April 27, 2017 09:31
Section Header
import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';
import {Icon, Text} from 'react-native-elements';
const SectionHeader = (section, index, isActive) => <View style={styles.container}>
<Text h4>{section.title}</Text>
<View style={styles.right}>
<Text style={{
marginRight: 5,
fontSize: 18