Skip to content

Instantly share code, notes, and snippets.

View nguyenhiepvan's full-sized avatar
😊
i think, therefore i am

Nguyễn Hiệp nguyenhiepvan

😊
i think, therefore i am
View GitHub Profile
@nguyenhiepvan
nguyenhiepvan / apache.txt
Last active October 26, 2020 05:45
Automation vitural host laravel
UseCanonicalName Off
<VirtualHost *:80>
ServerName vhosts.fqdn
ServerAlias *.local.com
VirtualDocumentRoot /var/www/laravel/%1/public
<Directory ~ "/var/www/laralve/%1/public">
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
@nguyenhiepvan
nguyenhiepvan / nginx.conf
Created April 12, 2021 02:17
stream mysql
#nginx config here
#....
#end nginx config
stream {
server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 127.0.0.1:3306;
@nguyenhiepvan
nguyenhiepvan / torrc
Last active May 5, 2021 01:50
Tor Privoxy ExitNodes
echo "ExitNodes {vn},{jp},{sg},{tw},{hk},{kr},{th}" >> /etc/tor/torrc \
&& echo "MaxCircuitDirtiness 30" >> /etc/tor/torrc
@nguyenhiepvan
nguyenhiepvan / pdftitle.py
Last active May 14, 2021 04:22 — forked from vuthaihoc/pdftitle.py
supported extracting vietnamese title
#!/usr/bin/env python
"""
Extracts title from PDF files (Python 3).
Depends on: pdf, pyPDF2, PDFMiner3k, unidecode.
Usage:
pdftitle -d tmp --rename *.pdf{}
"""
from io import StringIO
@nguyenhiepvan
nguyenhiepvan / PrependsTimestamp.php
Created June 25, 2021 02:15 — forked from vuthaihoc/PrependsTimestamp.php
Prepend timestamp to Artisan Console Output
<?php
/**
* @credit https://stackoverflow.com/questions/33046020/laravel-php-prepend-timestamp-to-artisan-console-output
*/
namespace App\Commands;
trait PrependsTimestamp
{
//To Get Size of all the Databases
//please Avoid using this it will take very Long time based on the number of databases
$sizeOnly = DB::table('information_schema.TABLES')
->sum(DB::raw('data_length + index_length'));
$sizeOfAllDataBases = DB::table('information_schema.TABLES')
->select(['TABLE_NAME as TableName','table_rows as TableRows','data_length as DataLength','index_length as IndexLength','TABLE_SCHEMA as DatabaseName'])
->get()
->map(function($eachDatabse){
@nguyenhiepvan
nguyenhiepvan / server_health.php
Created August 4, 2021 10:59
caculating server linux health
function serverHealth(): array
{
$start_time = microtime(true);
// Linux CPU
$load = sys_getloadavg();
$cpuload = $load[0];
// Linux MEM
$free = shell_exec('free');
$free = trim($free);
$free_arr = explode("\n", $free);
@nguyenhiepvan
nguyenhiepvan / seaweedfs_master.service
Last active April 19, 2022 02:23
seaweedfs deamon services
[Unit]
Description="seaweedfs master service"
[Service]
User=ssh_5pdf
WorkingDirectory=/var/www/media.123doc
ExecStart=/usr/bin/weed master -mdir=/var/www/media.123doc/master -volumePreallocate -volumeSizeLimitMB=128000 -ip=127.0.0.1
Restart=always
[Install]
@nguyenhiepvan
nguyenhiepvan / seaweedfs_docker.yml
Created August 12, 2021 07:55
using docker to integrate seaweedfs
version: '3'
services:
master:
image: chrislusf/seaweedfs:2.40_large_disk # use a remote image
# ports:
# - 9333:9333
# - 19333:19333
entrypoint: "/usr/bin/weed"
command: "master -ip=master -mdir=/data -volumePreallocate -volumeSizeLimitMB=20000"
@nguyenhiepvan
nguyenhiepvan / run.sh
Created September 23, 2021 03:06
simple library
#!/bin/sh
echo "Ho va ten:"
read name
echo "Lop:?"
read class
echo "So dien thoai:"
read phone_number
echo "Thu vien sach"