Skip to content

Instantly share code, notes, and snippets.

View decodedmrq's full-sized avatar
🏠
Working from home

Quyen Nguyen decodedmrq

🏠
Working from home
View GitHub Profile
@decodedmrq
decodedmrq / vanilla-js-cheatsheet.md
Created May 9, 2021 02:19 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@decodedmrq
decodedmrq / nginx-tuning.md
Created March 4, 2021 14:06 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@decodedmrq
decodedmrq / psql-error-fix.md
Created March 3, 2021 16:42 — forked from AtulKsol/psql-error-fix.md
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

{
"plugins": [
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"rules": {
"indent": [
/**
* Remove space fullsize
*
* @param string $str string before remove
* @return string after removed
*/
public static function mb_trim($str, $chars = '\s ') {
$str = preg_replace("/^[$chars]+/u", '', $str);
$str = preg_replace("/[$chars]+$/u", '', $str);
return $str;
mb_convert_encoding($text, 'UTF-8', 'Shift-JIS, EUC-JP, JIS, SJIS, JIS-ms, eucJP-win, SJIS-win, ISO-2022-JP,ISO-2022-JP-MS, SJIS-mac, SJIS-Mobile#DOCOMO, SJIS-Mobile#KDDI,SJIS-Mobile#SOFTBANK, UTF-8-Mobile#DOCOMO, UTF-8-Mobile#KDDI-A,UTF-8-Mobile#KDDI-B, UTF-8-Mobile#SOFTBANK, ISO-2022-JP-MOBILE#KDDI')
@decodedmrq
decodedmrq / Simple-CSV.lua
Created March 23, 2020 08:35 — forked from obikag/Simple-CSV.lua
Simple Lua Object that can read and modify a CSV file. Strings containing a comma (,) are not supported.
--Initialise
SimpleCSV = {}
SimpleCSV.__index = SimpleCSV
--Create new object
function SimpleCSV.new()
self = setmetatable({},SimpleCSV)
self.csv_table = {}
return self
end
@decodedmrq
decodedmrq / gist:8cffbd5ffeae084a087d5703f9bba36f
Created June 21, 2019 03:58 — forked from dosjota/gist:9666a7274b4036588b92987b84267245
Downgrade php 7.2 to 7.1 in Ubuntu 18.04 LTS
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-intl php7.1-simplexml
sudo a2dismod php7.2
sudo a2enmod php7.1
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
Adavance new file
AlignTab
AutoFileName
Emmet
Material Theme
Origami
PHP Companion
PHP Getters and Setters
SideBarEnhancements
SublimeCodeIntel