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 / three.doc.js
Created January 16, 2022 17:10 — forked from kopiro/three.doc.js
ThreeJS DeviceOrientationControls
/**
* @author richt / http://richt.me
* @author WestLangley / http://github.com/WestLangley
*
* W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
*/
THREE.DeviceOrientationControls = function( object ) {
var scope = this;
@decodedmrq
decodedmrq / laravel-quickstart-project-docker.md
Created August 10, 2021 17:04 — forked from wataridori/laravel-quickstart-project-docker.md
Running Laravel Quick Start Project easily using Docker
  • Install Docker
    • Docker for Ubuntu: https://docs.docker.com/engine/installation/linux/ubuntulinux/
      sudo apt-get update && apt-get install -y apt-transport-https ca-certificates
      sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
      
      // Open the /etc/apt/sources.list.d/docker.list and add the following line then save it
      // Ubuntu 14.04
      deb https://apt.dockerproject.org/repo ubuntu-trusty main
      

// Ubuntu 16.04

@decodedmrq
decodedmrq / RegisterRequest.php
Created August 10, 2021 17:01 — forked from tuanpht/RegisterRequest.php
Laravel Form Request Testing
<?php
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Unique;
class RegisterRequest extends FormRequest
{
const NAME_MAX_LENGTH = 255;
const EMAIL_MAX_LENGTH = 255;
const PASSWORD_MIN_LENGTH = 8;
@decodedmrq
decodedmrq / xmlrpc.php
Created July 7, 2021 18:19 — forked from hofmeister/xmlrpc.php
PHP simple XML-RPC Client
<?php
/**
* @author Henrik Hofmeister
* @license MIT
* @version 1.0
*
* XmlRPC using SimpleXML and CURL
*
* Usage:
*
@decodedmrq
decodedmrq / curl.md
Created July 6, 2021 17:27 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@decodedmrq
decodedmrq / Git-Pre-commit-setup.md
Created June 30, 2021 17:26 — forked from sdavara/Git-Pre-commit-setup.md
Git-pre-commit-hooks for PHP/Laravel Project

Pre Commit Setup

Setup pre-commit hook in php projects for lint, code standard, test cases etc.

Prerequisites

  • php >= 5.6
  • composer
  • git

Installation

@decodedmrq
decodedmrq / dantri.com.js
Created June 14, 2021 16:05 — forked from anhdiepmmk/dantri.com.js
Sử dụng puppeteer, cheerio của js để crawler trang web có ajax
const puppeteer = require('puppeteer');
const cheerio = require('cheerio');
(async () => {
const browser = await puppeteer.launch({headless: false, devtools: true})
const page = await browser.newPage()
await page.goto('https://dantri.com.vn/')
//https://github.com/cheeriojs/cheerio
let content = await page.content();
@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