Skip to content

Instantly share code, notes, and snippets.

View limweb's full-sized avatar

Thongchai Lim (样生海) limweb

View GitHub Profile
# How to use
# Make sure you install curl. By running curl -v to test it.
# Provide your Gmail username and password and who you need to send email to.
# For password it is not your Gmail password but it is App passwords https://support.google.com/mail/answer/185833. Please go to your Gmail account setting and create it.
# chmod -R 777 send-email-gmail.com
# ./send-email-gmail.com
# Your Gmail username (email) (Required)
SENDER_GMAIL_USERNAME=
# Your App password (Required)
# How to use
# Make sure you install curl. By running curl -v to test it.
# Provide your Gmail username and password and who you need to send email to.
# For password it is not your Gmail password but it is App passwords https://support.google.com/mail/answer/185833. Please go to your Gmail account setting and create it.
# chmod -R 777 send-email-gmail-thai.com
# ./send-email-gmail-thai.com
# Your Gmail username (email) (Required)
SENDER_GMAIL_USERNAME=
# Your App password (Required)
@limweb
limweb / LunarCalendar.php
Created January 2, 2020 04:05 — forked from jfcherng/LunarCalendar.php
PHP 農曆相關
<?php
class Lunar
{
const MIN_YEAR = 1891;
const MAX_YEAR = 2100;
const LUNAR_INFO = [
[0, 2, 9, 21936], [6, 1, 30, 9656], [0, 2, 17, 9584], [0, 2, 6, 21168], [5, 1, 26, 43344], [0, 2, 13, 59728],
[0, 2, 2, 27296], [3, 1, 22, 44368], [0, 2, 10, 43856], [8, 1, 30, 19304], [0, 2, 19, 19168], [0, 2, 8, 42352],
@limweb
limweb / check_cluster_1
Created May 25, 2018 11:00 — forked from NSLog0/check_cluster_1
on my blog
$ docker service ps mysite
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
ad0lvaxnsbgcirz5botfle2k3 mysite.1 wordpress ubuntu-node01 Running Running 7 minutes ago
3w6vx7b5kbykgmnpl4n3xgz95 mysite.2 wordpress ubuntu-node02 Running Running less than a second ago
btjrw6f33rud9vh6wa4pinzhj mysite.3 wordpress ubuntu-node03 Running Preparing 28 seconds ago
ab1p9p075zvwlb3t1g5f1n8ww mysite.4 wordpress ubuntu-node04 Running Preparing 28 seconds ago
@limweb
limweb / AES-256 encryption and decryption in PHP and C#.md
Created April 30, 2018 08:06
AES-256 encryption and decryption in PHP and C#

AES-256 encryption and decryption in PHP and C#

Update: There is a more secure version available. Details

PHP

<?php

$plaintext = 'My secret message 1234';
@limweb
limweb / openssl_encrypt_decrypt.php
Created April 27, 2018 11:21 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@limweb
limweb / bootstrap.php
Created November 13, 2017 04:22 — forked from pascal08/bootstrap.php
Laravel 5.4 Queue Standalone
<?php
require_once 'vendor/autoload.php';
require_once 'container.php';
$app = Container::getInstance();
$app->bind('database', function($app) {
$database = new Illuminate\Database\Capsule\Manager($app);
@limweb
limweb / Foo.php
Created November 12, 2017 17:41 — forked from h-collector/Foo.php
Standalone Laravel Queue + Redis example
<?php
namespace Jobs;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Redis\Database as Redis;
class Foo extends Job
{
use InteractsWithQueue;
@limweb
limweb / promises_reduce.js
Created November 2, 2017 04:56 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@limweb
limweb / my.cnf
Created September 11, 2017 08:22 — forked from kenelliott/my.cnf
16CPU / 16GB My.cnf
[mysqld_safe]
nice = -15
[mysqld]
max_binlog_size = 256M #max size for binlog before rolling
expire_logs_days = 1 #binlog files older than this will be purged
## Per-Thread Buffers * (max_connections) = total per-thread mem usage
thread_stack = 256K #default: 32bit: 192K, 64bit: 256K
sort_buffer_size = 1M #default: 2M, larger may cause perf issues