Skip to content

Instantly share code, notes, and snippets.

Avatar

Thura Hlaing trhura

View GitHub Profile
@trhura
trhura / MMPhoneNumber.js
Created Mar 9, 2018
Myanmar Phone Number validation & normalization
View MMPhoneNumber.js
// Myanmar Phone Number validation & normalization for ES6
// Based on https://github.com/trhura/mm_phonenumber
const mobileCode = "(0?9)";
const countryCode = "(\\+?95)";
const ooredooNumber = "(?:9(?:7|6)\\d{7})";
const telenorNumber = "(?:7(?:9|8|7|6)\\d{7})";
const mptNumber =
"(?:5\\d{6}|4\\d{7,8}|2\\d{6,8}|3\\d{7,8}|6\\d{6}|8\\d{6}|7\\d{7}|9(?:0|1|9)\\d{5,6})";
const allOperators = `(${ooredooNumber}|${telenorNumber}|${mptNumber})$`;
View flag.scm
(define (border-flag filename)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-proc-db-call "script-fu-double-border"
RUN-NONINTERACTIVE
image
drawable
'(238 238 238)
7
@trhura
trhura / ipa-write.py
Last active Apr 19, 2018
Write Syllable -> IPA mappings for Myanmar Syllables
View ipa-write.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
def get_ipa (syllable):
ipa = ''
consonant = syllable[0]
i = 1
while i < len(syllable) and syllable[i] in ['\u103B', '\u103C','\u103D','\u103E']:
i += 1
medial = syllable[1:i]
@trhura
trhura / to-ipa.py
Created Mar 19, 2015
script to convert burmese syllables to ipa symbols
View to-ipa.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
def get_ipa (syllable):
ipa = ''
ipa += get_cons_ipa(syllable)
ipa += get_medial_ipa(syllable)
ipa += get_vowel_ipa (syllable)
if u"\u028A" in ipa:
@trhura
trhura / converter.php
Created Jan 18, 2015
Unicode <-> Zawgyi Converter Generated from paytan
View converter.php
<?php
/* Zawgyi<>Unicode converter python module */
/* Based on rules from Parabaik Myanmar Text Converter */
/* Copyright (C) 2014 Ngwe Tun (Solveware Solution) */
/* Copyright (C) 2014 Thura Hlaing */
/* This file is part of Paytan. */
/* Paytan is free software: you can redistribute it and/or modify */
@trhura
trhura / Converter.java
Last active Nov 16, 2020
Unicode <-> Zawgyi Java Converter
View Converter.java
// Zawgyi<>Unicode converter python module
// Based on rules from Parabaik Myanmar Text Converter
// Copyright (C) 2014 Ngwe Tun (Solveware Solution)
// Copyright (C) 2014 Ye Mon Kyaw
// This file is part of Paytan.
// Paytan is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
View calculator.erl
-module (calculator).
-export ([exponential/2, multiply/2]).
multiply(_, 0) -> 1;
multiply(Num, 1) -> Num;
multiply(Num, Exp) -> Num + multiply(Num, Exp-1).
exponential(_, 0) -> 1;
exponential(Base, 1) -> Base;
exponential(_, Exp) when(Exp < 0) -> throw("Bad argument");
View lambda-talks.py
def multiply(a, b):
# Assuming a and b are not negative
if b == 0: return 0
if b == 1: return a
return a + multiply(a, b-1)
def power(b, e):
# Assuming e is not negative
if e == 0: return 1
if e == 1: return b
View lambda-talks.hs
-- Assuming a and b are not negative
multiply a 0 = 0
multiply a 1 = a
multiply a b = a + multiply a (b-1)
-- Assuming e is not negative
power b 0 = 1
power b 1 = b
power b e = multiply b $ power b (e-1) -- aka multiply b (power b e-1)
@trhura
trhura / cvpicker.py
Created Oct 12, 2014
opencv color picker
View cvpicker.py
#! /usr/bin/env python2
import cv2
import numpy as np
colors = []
def on_mouse_click (event, x, y, flags, frame):
if event == cv2.EVENT_LBUTTONUP:
colors.append(frame[y,x].tolist())
You can’t perform that action at this time.