Skip to content

Instantly share code, notes, and snippets.

View eimg's full-sized avatar

Ei Maung eimg

View GitHub Profile
var app = angular.module('ngSlides', []);
app.controller("SlideController", function ($scope) {
$scope.slides = [];
$scope.activeSlide = 0;
$scope.addSlide = function() {
if(!$scope.slideTitle && !$scope.slideBody) {
return false;
}
@eimg
eimg / wp-install.sh
Created October 29, 2013 14:15
Download and install latest version of Wordpress. Only for XAMPP linux on Ubuntu.
#!/bin/bash
echo "Project/DB Name: "; read -e dbname
echo "Database User: "; read -e dbuser
echo "Database Password: "; read -s dbpass
echo "Run the install? (y/n)"; read -e run
if [ "$run" == n ] ; then
exit
else
wget http://wordpress.org/latest.tar.gz
@eimg
eimg / burmese-syllabus-count.js
Last active May 5, 2022 08:30
A regular expression example to us in counting Burmese syllabus in a string.
// RegEx to count syllabus a string
// with Burmese content
"မန္တလေးမြို့မှ XYZ စတိုး (၂) ကို ဒီလမ်းအတိုင်း ဖြောင့်ဖြောင့် သွားပါ".match(
/([က-ဪ](?!်|္|့်)|[ဿ-၏]|[!-~]|\s)/g
).length;
// => 29
@eimg
eimg / mm2en.js
Last active May 5, 2022 08:31
Convert Myanmar numbers to English numbers
// INPUT: ၁၁.၁၂.၂၀၁၇
// OUTPUT: 11.12.2017
function mm2en(num) {
var nums = { '၀': '0', '၁': 1, '၂': 2, '၃': 3, '၄': 4 , '၅': 5, '၆': 6, '၇':7, '၈':8, '၉':9 };
return num.replace(/([၀-၉])/g, function(s, key) {
return nums[key] || s;
});
}
@eimg
eimg / moment.my-mm.locale.js
Created August 6, 2017 07:56
Burmese locale for Moment.js
moment.locale('my-mm', {
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
monthsShort: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
monthsParseExact: true,
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသာပတေး_သောကြာ_စနေ'.split('_'),
weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_တေး_ကြာ_နေ'.split('_'),
weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_တေး_ကြာ_နေ'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
@eimg
eimg / generate-image-thumb.php
Last active November 28, 2017 03:59
Create image thumb on given size without effection original aspect ratio
<?php
function generate_thumb($source_image_path, $thumbnail_image_path, $result_width, $result_height) {
if(!file_exists($source_image_path)) {
return false;
}
if(!getimagesize($source_image_path)) {
return false;;
}
@eimg
eimg / basic-paging.php
Created January 14, 2018 03:19
PHP paging - sample code
<?php
$conn = mysqli_connect("localhost", "root", "");
mysqli_select_db($conn, "test");
$start = isset($_GET['start']) ? $_GET['start'] : 0;
$result = mysqli_query($conn, "SELECT * FROM countries LIMIT $start, 10");
$total = mysqli_query($conn, "SELECT * FROM countries");
@eimg
eimg / slider.html
Created February 4, 2018 01:47
Simple JavaScript Slider
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 800px;
margin: 20px auto;
position: relative;
@eimg
eimg / promise.md
Last active November 17, 2022 12:58
JavaScript Promise & async/await

JavaScript Promise & async/await

JavaScript တွင် Asynchronous process များအတွက် Callback များကို သုံးနိုင်သည်။ Asynchronous Process ဆိုသည်မှာ Synchronous Process ၏ ဆန့်ကျင်ဘက်ဖြစ်သည်။ Synchronous Process ဆိုသည်မှာ လုပ်ငန်းစဉ်များကို တစ်ခုပြီးမှသာ နောက်တစ်ခု ဆက်ခြင်းအားဖြင့် အစီအစဉ်အတိုင်း အလုပ်လုပ်သွားသည့် Process ဖြစ်သည်။ Asynchronous Process များတွင် လုပ်ငန်းစဉ်တစ်ခု ပြီးဆုံးအောင် နောက်တစ်ခုက စောင့်ရန်မလို၊ ကြိုတင်၍သော်လည်ကောင်း၊ ပြိုင်တူသော်လည်ကောင်း ဆောင်ရွက်သည့် သဘောဖြစ်သည်။

ဥပမာ - ကောင်မလေးတစ်ယောက်ကို ချဉ်းကပ်စကားပြောလိုသည့် လူငယ်တစ်ဦး ရှိသည် ဆိုကြပါစို့။ ထိုလုပ်ငန်းစဉ်အတွက် Synchronous Process ကို သုံးပါက အောက်ပါအတိုင်း ဖြစ်ပေလိမ့်မည်။

function check() {
	// walk to her
	// status = check her out
@eimg
eimg / ES6-overview.md
Last active April 6, 2024 10:36
Overview of some ES6 features

ES6 - Modern JavaScript

ခြောက်ကြိမ်မြောက် တည်းဖြတ်မှုဖြစ်သည့်အတွက် ES6 ဟု အတိုကောက်ခေါ်၍ 2015 ခုနှစ်တွင် ဖန်တီးခဲ့သည့် အတွက် ECMAScript2015 ဟု ရံဖန်ရံခါ ခေါ်သည့် နည်းပညာသည် လက်ရှိ JavaScript (ES5) ကို အဆင့်မြှင့်တင်ထားသည့် နည်းပညာဖြစ်သည်။ ES6 တွင် ပါဝင်လာသည့် လုပ်ဆောင်ချက်များမှ အချို့ကို ရွေးထုတ် ဖော်ပြလိုက်ပါသည်။

Block-scope Variable

မူလ JavaScript တွင် var Keyword ကို အသုံးပြု၍ Variable များ ကြေငြာနိုင်သည်။ ထို Variable များသည် Function-scope သဘောသဘာဝ ရှိကြသည်။ ES6 တွင် let Keyword ကို အသုံးပြု၍ Block-scope Variable များ ကြေငြာအသုံးပြုနိုင်သည်။

let i = 10