This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://th.wikipedia.org/wiki/จังหวัดของประเทศไทย | |
// 77 จังหวัด | |
var province_th = [ | |
'กรุงเทพฯ', | |
'กระบี่', | |
'กาญจนบุรี', | |
'กาฬสินธุ์', | |
'กำแพงเพชร', | |
'ขอนแก่น', | |
'จันทบุรี', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sleep8bit (second: Int, width: Int=10, callback: (String)->Unit) { | |
val d = (second * 1000 / width ).toLong() | |
(1..width).forEach { | |
Thread.sleep(d) | |
val progress = "[${"#".repeat(it)}${" ".repeat(width-it)}]" | |
callback(progress) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val h = Handler(Looper.getMainLooper()) | |
GlobalScope.launch(Dispatchers.Main) { | |
(1..5).forEach { proc(it, h) } | |
} | |
h.removeCallbacksAndMessages(null) | |
} | |
suspend fun proc(no: Int, h: Handler): Boolean = suspendCoroutine { | |
h.post { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set GITBRANCH= | |
for /f "tokens=2" %%I in ('git.exe branch 2^> NUL ^| findstr /b "* "') do set GITBRANCH=%%I | |
if "%GITBRANCH%" == "" ( | |
prompt $P$G | |
) else ( | |
prompt $P $C$E[10;7;32;47m%GITBRANCH%$E[0m$F $G | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.alibaba.fastjson.JSON | |
data class Setting ( | |
val title: String, | |
val info: List<TimeRange> | |
) | |
data class TimeRange ( | |
val from: String, | |
val to: String, | |
val temp: Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name YOUR_SERVERS_IP_ADDRESS; | |
location ~ ^/(js/|img/|css/) { | |
root /path/to/public/static/; | |
access_log off; | |
expires 24h; | |
} | |
location / { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReadLine { | |
private val EOL = listOf( | |
13.toByte(), // CR | |
10.toByte() // LR | |
) | |
private val EOL_SIZE = EOL.size | |
private val MSG_MAX_LENGTH = 99 | |
private var line = byteArrayOf() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------- | |
# http://forum.xda-developers.com/showthread.php?t=2278508 | |
# http://forum.xda-developers.com/showthread.php?t=2294786 | |
# | |
# (require root) | |
# reset | |
wm size reset | |
wm density reset | |
wm overscan reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajax_json(type, url, data, success_fn, failure_fn){ | |
let ajax_options = { | |
type: type, | |
url: url, | |
dataType: 'json', | |
contentType: 'application/json; charset=utf-8', | |
data: JSON.stringify(data), | |
success: function(resp){ | |
success_fn(resp); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(10): | |
print('{:<10}: {}'.format('*'*(i+1), 'row %s' % (i+1))) |