Skip to content

Instantly share code, notes, and snippets.

View trungpv1601's full-sized avatar
🤖
Diversifying; Practical; more code than talk.

trungpv trungpv1601

🤖
Diversifying; Practical; more code than talk.
View GitHub Profile
@trungpv1601
trungpv1601 / puppeteer.sh
Last active April 16, 2019 14:58
puppeteer.sh
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nodejs -y
sudo apt-get install npm -y
# Fix Trouble Puppeteer
sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libnss3-dev
let NETWORK_PRESETS = {
'GPRS': {
'offline': false,
'downloadThroughput': 50 * 1024 / 8,
'uploadThroughput': 20 * 1024 / 8,
'latency': 500
},
'Regular2G': {
'offline': false,
'downloadThroughput': 250 * 1024 / 8,
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
// == Enforcing Options ===============================================
//
// These options tell JSHint to be more strict towards your code. Use
// them if you want to allow only a safe subset of JavaScript, very
@trungpv1601
trungpv1601 / INSTALL.MD
Created March 14, 2019 05:27
Template Nodejs Web Application
npm install --save consolidate cookie-parser csurf debug dotenv finalhandler helmet mustache router shortid xtend
@trungpv1601
trungpv1601 / Fix Puppeteer on Ubuntu.md
Created March 13, 2019 07:43
Chrome Headless doesn't launch on Debian
sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
const browser = await puppeteer.launch({args: ['--no-sandbox']});
function getBaseUrl($includeTrailingSlash = FALSE)
{
$protocol = (isset($_SERVER['HTTPS']) && 'off' !== $_SERVER['HTTPS']) ? 'https' : 'http';
$domain = php_uname('n');
$port = '';
if (isset($_SERVER['HTTP_HOST'])) {
$domain = filter_input(
INPUT_SERVER,
'HTTP_HOST',
@trungpv1601
trungpv1601 / README.MD
Last active February 16, 2019 08:16
Docker Command

Redis

docker run --name my-redis -p 6379:6379 --restart always --detach redis --requirepass <password>

Selenium

docker run -d --name selenium-hub -p 4444:4444 --restart always selenium/hub
@trungpv1601
trungpv1601 / index.js
Created May 7, 2018 07:45
Async Map in Javascript
const arr = [ { key: 1 }, { key: 2 }, { key: 3 } ]
const result = arr.map(async (obj) => { return obj.key; });
console.log(`Result: ${result}`);
// outputs "Result: ???"
@trungpv1601
trungpv1601 / docker-command.md
Last active May 7, 2018 05:50
Docker command

MYSQL

docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 --restart=always -d mysql --default-authentication-plugin=mysql_native_password

PHPMYADMIN

  • mysql <= Name contatiner mysql
@trungpv1601
trungpv1601 / README.MD
Created February 4, 2018 02:24
Using Genymotion With Charles Proxy

In your Genymotion Android emulator…

  • Settings -> Wifi -> Press and hold your active network
  • Select “Modify Network”
  • Select “Show Advanced Options”
  • Select “Proxy Settings -> Manual”
  • Set your Proxy to: 10.0.3.2 (Genymotion’s special code for the local workstation)
  • Set your Port to: 8888
  • Press Save

You should now be able to see Genymotion traffic showing up in your Charles Proxy