Skip to content

Instantly share code, notes, and snippets.

View trhura's full-sized avatar

Thura Hlaing trhura

View GitHub Profile
@trhura
trhura / MMPhoneNumber.js
Created March 9, 2018 08:38
Myanmar Phone Number validation & normalization
// 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})$`;
(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 April 19, 2018 08:51
Write Syllable -> IPA mappings for Myanmar Syllables
#! /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 March 19, 2015 05:12
script to convert burmese syllables to ipa symbols
#! /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 January 18, 2015 13:49
Unicode <-> Zawgyi Converter Generated from paytan
<?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 December 10, 2023 09:29
Unicode <-> Zawgyi Java Converter
// 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
-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");
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
-- 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 October 12, 2014 03:40
opencv color picker
#! /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())