Skip to content

Instantly share code, notes, and snippets.

View spicydog's full-sized avatar

spicydog spicydog

View GitHub Profile
@spicydog
spicydog / main.py
Created October 24, 2020 16:00
A Google Cloud Function to copy/clone a file from one Google Cloud Storage bucket to another with the same file path.
import os
from google.cloud import storage
OUTPUT_BUCKET = os.environ['OUTPUT_BUCKET']
def clone_gcs_file(event, context):
print(f"rev.4")
INPUT_BUCKET = event['bucket']
@spicydog
spicydog / .gitlab-ci.sh
Created August 29, 2020 16:41
SPICYDOG's Podcast EP 4 : Sample Scripts
#!/bin/sh
# exit with error
set -e
# Generate an application key. Re-cache.
php artisan config:cache
php artisan config:clear
php artisan cache:clear
@spicydog
spicydog / generate.js
Created February 8, 2020 15:49
Central Limit Theorem
const times = 20;
const n = 5
const set = {
1: 1,
2: 5,
3: 7,
4: 5,
5: 1,
@spicydog
spicydog / thai_national_id_validation.php
Last active July 13, 2018 08:11
The PHP function to check Thai national ID
/**
* 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 April 1, 2018 05:26
spicydog.org Wordpress's Editor 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;
หากวาง = หา|กวาง / หาก|วาง
ปีกว่า = ปี|กว่า / ปีก|ว่า
เกษตรกรอบกรอบ = เกษตรกร|อบ|กรอบ / เกษตร|กรอบ|กรอบ
#!/usr/bin/env python
# # -*- coding: utf-8 -*-
"""
__project__ = "MAQE Bot"
__reference__ = "https://maqe.github.io/maqe-bot.html"
__author__ = "Spicydog Proxy"
"""
def translate(input):

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 December 15, 2016 06:56
NGINX Let's Encrypt custom webroot location
location ^~ /.well-known/acme-challenge/ {
alias /var/www/acme-challenge/;
}
@spicydog
spicydog / keybase.md
Created December 13, 2016 05:22
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: