Skip to content

Instantly share code, notes, and snippets.

View khzaw's full-sized avatar
💻
Crushing it

Kaung Htet khzaw

💻
Crushing it
View GitHub Profile
@khzaw
khzaw / closure.js
Created June 10, 2020 02:17
Closure exmaple
function outerFunc() {
// the outer scope
let outerVar = 'I am outside!';
function innerFunc() {
console.log(outerVar); // -> I am outside!
}
innerFunc();
}
outerFunc();
@khzaw
khzaw / README
Created March 20, 2017 11:18 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@khzaw
khzaw / class_examples.js
Created December 9, 2015 16:59
Javascript class
// the class use
class Animal {
constructor(name) {
this.name = name;
}
walk() {
console.log(`${this.name} is walking`);
}
}
@khzaw
khzaw / japan.py
Created November 8, 2015 07:55
Calculating average delta difference
#!/usr/bin/python
from itertools import izip
from datetime import datetime
PROFILE_PICS = [
'07 September 2015',
'14 June 2015',
'09 May 2015',
'15 April 2015',
double sqrt(double); // the square root function takes a double
class Vector {
public:
Vector(int s);
double& operator[](int i);
int size();
private:
double* elem; // elem points to an array of sz doubles
@khzaw
khzaw / -
Created March 12, 2015 12:07
int count_x(char* p, char x) {
// count the number of occurrences of x in p[]
// p is assumed to point to a zero-terminated array of char (or to nothing)
if(p == nullptr) return 0;
int count = 0;
for(; p != nullptr; ++p)
if(*p == x)
++count;
return count;
@khzaw
khzaw / lab4.sql
Created February 18, 2015 01:49
lab4.sql
create table `member` (
`number` int,
`name` varchar(256) not null,
`address` varchar(512) not null,
primary key (`number`)
);
create table `wine` (
`name` varchar(256),
`appellation` date,
@khzaw
khzaw / histogram.ml
Created February 2, 2015 14:30
To get a historgram
let most_frequent_elt list =
let rec loop maxelt maxcount elt count = function
| [] -> if count > maxcount then elt else maxelt
| x::xs ->
if elt = x then loop maxelt maxcount elt (count + 1) xs
else if count > maxcount then loop elt count x 1 xs
else loop maxelt maxcount x 1 xs in
match List.sort compare list with
| [] -> None
| x::xs -> Some (loop x 0 x 1 xs);;
@khzaw
khzaw / removeDupl.ml
Created January 28, 2015 05:07
Remove duplicates from a polymorphic list
let rec removeDupl (xs:'a list) : 'a list -> match xs with
| [] -> []
| hd::tl -> hd :: (removeDupl (List.filter (fun x -> x <> hd ) tl));;
@khzaw
khzaw / lab1.sql
Created January 28, 2015 01:32
CS2101 Lab1
-- 1
CREATE TABLE book (
title VARCHAR(256) NOT NULL,
format CHAR(9) NOT NULL,
pages INT,
authors VARCHAR(256),
publisher VARCHAR(256),
year DATE,
edition INT,
ISBN10 CHAR(10) NOT NULL UNIQUE,