Skip to content

Instantly share code, notes, and snippets.

View cvhau's full-sized avatar
🐪
Coding is a half of my life!

Cao Van Hau cvhau

🐪
Coding is a half of my life!
  • Ho Chi Minh
View GitHub Profile
@cvhau
cvhau / wpsalts.php
Created October 28, 2022 08:10
WordPress Salts Generator
#!/usr/bin/env php
<?php
class WpSaltsGenerator
{
private static $instance = null;
public function __construct()
{
// code
@cvhau
cvhau / wp-config-generate.php
Created October 28, 2022 07:24
WordPress config file generator
#!/usr/bin/env php
<?php
namespace WpConfig;
use RuntimeException;
class ConfigOption
{
@cvhau
cvhau / gist:2ecf7645156f89e23fb56b36dd5875c2
Created August 11, 2022 08:08 — forked from voskobovich/gist:537b2000108e4781f70b
List of most currency ISO code and symbol format in SQL.
DROP TABLE currency;
-- Create table variable
CREATE TABLE currency (
name VARCHAR(20),
code VARCHAR(3),
symbol VARCHAR(5)
);
ALTER TABLE currency CONVERT TO CHARACTER SET utf8;
@cvhau
cvhau / what-forces-layout.md
Created July 18, 2022 04:23 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@cvhau
cvhau / widget-update-function.js
Created April 19, 2022 09:16 — forked from pagelab/widget-update-function.js
jQuery function for update events on WordPress widgets save/add
( function( $ ){
function initColorPicker( widget ) {
widget.find( '.color-picker' ).wpColorPicker( {
change: _.throttle( function() { // For Customizer
$(this).trigger( 'change' );
}, 3000 )
});
}
function onFormUpdate( event, widget ) {
@cvhau
cvhau / sublime-text-scopes.md
Created December 10, 2021 05:07 — forked from J2TEAM/sublime-text-scopes.md
Sublime Text 2/3: Snippet scopes

Here is a list of scopes to use in Sublime Text 2/3 snippets -

ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
@cvhau
cvhau / mariadb-docker-container-starter.md
Last active January 29, 2021 10:35
Guid to start a mariadb docker container

Create volume for persistence data storage

docker volume create mariadb-volume

The volume data is stored under the /var/lib/docker/volumes on your host.

Start a mariadb docker container

docker run -d --name mariadb -p 3306:3306 -e "MYSQL_ROOT_PASSWORD=YOUR_ROOT_PASSWORD" --restart unless-stopped -v mariadb-volume:/var/lib/mysql mariadb:latest
@cvhau
cvhau / README.md
Created November 16, 2020 09:58 — forked from ikennaokpala/README.md
Setting Nginx FastCGI response buffer sizes.

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is also explained at the Nginx ngx_http_fastcgi_module page document page.

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).

The related Nginx options are:

@cvhau
cvhau / Laravel-Container.md
Created August 27, 2020 08:05
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@cvhau
cvhau / input-reset.css
Created July 9, 2020 07:57 — forked from Tombarr/input-reset.css
CSS to remove input pseudo-elements and normalize input styling cross-browser
/* All of our custom controls should be what we expect them to be */
input,
textarea {
-webkit-box-sizing:content-box;
-moz-box-sizing:content-box;
box-sizing:content-box;
}
/*
Show overflow in Edge