Skip to content

Instantly share code, notes, and snippets.

View pnlinh's full-sized avatar
😃
Focusing

Linh Pham pnlinh

😃
Focusing
View GitHub Profile
@pnlinh
pnlinh / md5-example.go
Created May 9, 2025 15:39 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@pnlinh
pnlinh / main.go
Created May 5, 2025 09:36 — forked from alexedwards/main.go
JSON encoding benchmarks #2
package main
import (
"encoding/json"
"net/http"
)
func main() {}
func healthcheckHandlerMarshalIndent(w http.ResponseWriter, r *http.Request) {
@pnlinh
pnlinh / REVAMPED.md
Created November 22, 2024 11:30 — forked from sergiotabanelli/REVAMPED.md
MYSQLND_MS REVAMPED: Single and multi-master read/write consistency enforcing in MySQL asynchronous clusters with PHP and mysqlnd_ms extension

MYSQLND_MS REVAMPED: Single and multi-master read/write consistency enforcing in MySQL asynchronous clusters with PHP and mysqlnd_ms extension

NOTE: The service level and consistency feature is one of the most changed areas of the mymysqlnd_ms fork. Functionalities like server side read consistency and server side write consistency allow transparent migration to MySQL asyncronous clusters in almost all use cases with no or at most extremely small effort and application changes.

Different types of MySQL cluster solutions offer different service and data consistency levels to their users. Any asynchronous MySQL replication cluster offers eventual consistency by default. A read executed on an asynchronous slave may return current, stale or no data at all, depending

@pnlinh
pnlinh / jing.sh
Created November 22, 2024 11:29 — forked from populov/jing.sh
Flameshot + upload screenshot to SFTP
#!/bin/bash
# Prerequisites:
# * flameshost (Take screenshot + basic edit): https://flameshot.org
# * scp (OpenSSH/SFTP file copy client) https://www.mankier.com/1/scp
# * notify-send (Desktop notifications) https://ss64.com/bash/notify-send.html
# * xclip (copy to clipboard) https://opensource.com/article/19/7/xclip
#
## Install prerequisites (Ubuntu):
# sudo apt-get install flameshot openssh-client notify-send xclip
nginx.conf
php-fpm.conf
www.conf
php.ini
phpinfo
phpinfo.php
Procfile
procfile
Makefile
project.toml
@pnlinh
pnlinh / apns.sh
Created October 22, 2024 07:43 — forked from greencoder/apns.sh
Curl the APNS http/2 API
# Note: You MUST have curl 7.47+ with http/2 support compiled in
curl -v \
-d '{"aps":{"alert":"<message>","badge":42}}' \
-H "apns-topic: <bundle id>" \
-H "apns-priority: 10" \
--http2 \
--cert <certificate file> \
https://api.development.push.apple.com/3/device/<device token>
@pnlinh
pnlinh / .env
Created October 11, 2024 10:54 — forked from thesafaraliyev/.env
Laravel with Localstack S3 and SQS setup
FILESYSTEM_DRIVER=s3
QUEUE_CONNECTION=sqs
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=bucket1
AWS_ENDPOINT=http://localhost:4566/
AWS_USE_PATH_STYLE_ENDPOINT=true
SQS_QUEUE=queue1
SQS_PREFIX=http://localhost:4566/000000000000/
@pnlinh
pnlinh / gist:273ddd0abebdd9093beafea97e6a9493
Created October 7, 2024 09:16 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
<?php
use Illuminate\Database\Query\Builder;
Builder::macro('orderByNulls', function ($column, $direction = 'asc', $nulls = 'last', $bindings = []) {
$column = $this->getGrammar()->wrap($column);
$direction = strtolower($direction) === 'asc' ? 'asc' : 'desc';
$nulls = strtolower($nulls) === 'first' ? 'NULLS FIRST' : 'NULLS LAST';
return $this->orderByRaw("$column $direction $nulls", $bindings);
});
# SETUP #
DOMAIN=example.com
PROJECT_REPO="git@github.com:example.com/app.git"
AMOUNT_KEEP_RELEASES=5
RELEASE_NAME=$(date +%s--%Y_%m_%d--%H_%M_%S)
RELEASES_DIRECTORY=~/$DOMAIN/releases
DEPLOYMENT_DIRECTORY=$RELEASES_DIRECTORY/$RELEASE_NAME
# stop script on error signal (-e) and undefined variables (-u)