Skip to content

Instantly share code, notes, and snippets.

View buagern's full-sized avatar

Settawat Jamsai buagern

  • Bangkok, Thailand
View GitHub Profile
@buagern
buagern / repack_ue4_ipas_for_dist.sh
Created November 4, 2017 13:43 — forked from piinecone/repack_ue4_ipas_for_dist.sh
Unpack, resign, and repack IPA's generated with Unreal Engine 4
#!/bin/bash
# USAGE
# 1. name this file something like `distbuild`, make it executable (chmod +x), and put it in your PATH
# 2. run it and pass it the name of your project, eg `distbuild MySweetGame`
TIMESTAMP=$(date +"%m%d%y") # eg, 070214
CERT_NAME="iPhone Distribution: Your Certificate's Name (And Identifier)"
# where you want your builds to go
@buagern
buagern / nginx-tuning.md
Created May 3, 2017 08:47 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

#!/bin/bash
(for i in `dpkg -l | grep '^ii' | awk '{print $2}'`; do
echo $i; sudo /usr/sbin/dpkg-reconfigure $i;
done
) 2>&1 | tee /var/log/dpkg-reconfigure.log
<?php
$dbname = 'test';
if (!$link = mysqli_connect('localhost', 'root', '', $dbname)) {
echo 'Could not connect to mysql';
exit;
}
$sql = "SHOW TABLES FROM $dbname";
$result = mysqli_query($link, $sql);
@buagern
buagern / date-th.php
Last active August 13, 2022 00:53
PHP Thai locale date Function
<?php
function dateth() {
if (0 === $given = func_num_args()) {
return trigger_error(__FUNCTION__.'() expects at least 1 parameter, '.$given.' given', E_USER_WARNING);
}
$mapping = [ 'D' => [ 'Mon' => 'จ.', 'Tue' => 'อ.', 'Wed' => 'พ.', 'Thu' => 'พฤ.', 'Fri' => 'ศ.', 'Sat' => 'ส.', 'Sun' => 'อา.' ], 'l' => [ 'Monday' => 'จันทร์', 'Tuesday' => 'อังคาร', 'Wednesday' => 'พุธ', 'Thursday' => 'พฤหัสบดี', 'Friday' => 'ศุกร์', 'Saturday' => 'เสาร์', 'Sunday' => 'อาทิตย์' ], 'M' => [ 'Jan' => 'ม.ค.', 'Feb' => 'ก.พ.', 'Mar' => 'มี.ค.', 'Apr' => 'เม.ย.', 'May' => 'พ.ค.', 'Jun' => 'มิ.ย.', 'Jul' => 'ก.ค.', 'Aug' => 'ส.ค.', 'Sep' => 'ก.ย.', 'Oct' => 'ต.ค.', 'Nov' => 'พ.ย.', 'Dec' => 'ธ.ค.' ], 'F' => [ 'January' => 'มกราคม', 'February' => 'กุมภาพันธ์', 'March' => 'มีนาคม', 'April' => 'เมษายน', 'May' => 'พฤษภาคม', 'June' => 'มิถุนายน', 'July' => 'กรกฎาคม', 'August' => 'สิงหาคม', 'September' => 'กันยายน', 'October' => 'ตุลาคม', 'November' => 'พฤศจิกายน', 'December' => 'ธันวาคม' ]];
$args = func_get_args();
$ts