Skip to content

Instantly share code, notes, and snippets.

spicydog spicydog

View GitHub Profile
@spicydog
spicydog / thai_national_id_validation.php
Last active Jul 13, 2018
The PHP function to check Thai national ID
View thai_national_id_validation.php
/**
* Validate Thai national ID
* @param string $nationalId
* @link https://th.wikipedia.org/wiki/เลขประจำตัวประชาชนไทย
* @return bool
*/
public function isValidNationalId(string $nationalId)
{
if (strlen($nationalId) === 13) {
$digits = str_split($nationalId);
@spicydog
spicydog / editor-style.css
Created Apr 1, 2018
spicydog.org Wordpress's Editor CSS
View editor-style.css
/*
Theme Name: Twenty Eleven
Description: Used to style the TinyMCE editor.
*/
@import url("https://cdn.spicydog.org/fonts/th-sarabun-new/th-sarabun-new.css");
@import url("https://cdn.spicydog.org/fonts/thaisans-neue/thaisans-neue.css");
body {
color: #333;
View รวมคำยากในการตัดคำภาษาไทย
หากวาง = หา|กวาง / หาก|วาง
ปีกว่า = ปี|กว่า / ปีก|ว่า
เกษตรกรอบกรอบ = เกษตรกร|อบ|กรอบ / เกษตร|กรอบ|กรอบ
View maqe_bot.py
#!/usr/bin/env python
# # -*- coding: utf-8 -*-
"""
__project__ = "MAQE Bot"
__reference__ = "https://maqe.github.io/maqe-bot.html"
__author__ = "Spicydog Proxy"
"""
def translate(input):
View Caldera Forms Export to CSV in UTF-8 with BOM.md

On Caldera Forms, when you export entries as CSV.

It cannot be open perfectly with excel because it missing BOM in file prefix.

Therefore, we have to intercept the process and here is how to.

At the file wp-content/plugins/caldera-forms/classes/admin.php.

There is a function to export the CSV here.

@spicydog
spicydog / gist:99da4482692fcb4028d44a848d8801ea
Created Dec 15, 2016
NGINX Let's Encrypt custom webroot location
View gist:99da4482692fcb4028d44a848d8801ea
location ^~ /.well-known/acme-challenge/ {
alias /var/www/acme-challenge/;
}
View keybase.md

Keybase proof

I hereby claim:

  • I am spicydog on github.
  • I am spicydog (https://keybase.io/spicydog) on keybase.
  • I have a public key whose fingerprint is 7F92 B174 29D3 8BAE 25D5 A98B 6EFF 2366 9E52 EDC1

To claim this, I am signing this object:

@spicydog
spicydog / Authenticate.php
Last active Nov 14, 2016
Laravel Authentication Middleware
View Authenticate.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Authenticate
{
/**
@spicydog
spicydog / random_project.php
Last active Nov 7, 2016
Random Project on Web Programming 2016
View random_project.php
<?php
$projects = [
'1 ร้านเช่า หนังสือ',
'2 ร้านเช่า ชุดเสื้อผ้า เครื่องแต่งกาย',
'3 ร้านเช่า รถยนต์',
'4 ระบบสมัครสมาชิก',
'5 เว็บ Blog',
'6 ระบบจองคิวคลินิก',
'7 ระบบสั่งอาหารจากโต๊ะ',
'8 ระบบคำนวณเกรดวิชาเรียน',
@spicydog
spicydog / dockerfile
Created Sep 24, 2016
docker ubuntu nginx php7.0 mariadb
View dockerfile
FROM ubuntu:latest
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y vim curl wget
RUN apt-get install -y software-properties-common language-pack-en-base
RUN LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej/php
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
RUN add-apt-repository -y 'deb [arch=amd64,i386,ppc64el] http://mirrors.bestthaihost.com/mariadb/repo/10.1/ubuntu xenial main'
You can’t perform that action at this time.