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 / DbReplicate.php
Created April 13, 2023 05:20 — forked from vuthaihoc/DbReplicate.php
Laravel DB replicate
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
class DbReplicate extends Command
{
version: '2'
# Run with docker-compose up -d
# Navigate to http://localhost:4200
# See Crate's getting started docs: https://crate.io/docs/reference/hello.html
services:
crate01:
image: crate
hostname: crate01
ports:
- "4200:4200"
@nguyenhiepvan
nguyenhiepvan / Google-Drive-PDF-Downloader.js
Last active August 23, 2022 10:26
download pdf view only from google drive
let res = document.createElement("script");
res.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js';
document.body.appendChild(res);
res.onload = function () {
const pdf = new jsPDF();
const added_images = [];
const added_pages = [];
const images = [];
// var loopCounter = 0;
let allElements = document.querySelectorAll("*");
@nguyenhiepvan
nguyenhiepvan / FilterScope.php
Last active July 28, 2022 08:41
Filter Command using deferred join
<?php
/**
* Created by PhpStorm.
* User: Hiệp Nguyễn
* Date: 26/07/2022
* Time: 09:25
*
* app/Models/Traits/FilterScope.php
* use this trait in model
*/
@nguyenhiepvan
nguyenhiepvan / FastPaginationOperation.php
Last active July 28, 2022 08:20
backpack listing operation for very big table using Deferred Joins
<?php
/**
* Created by PhpStorm.
* User: Hiệp Nguyễn
* Date: 27/07/2022
* Time: 15:43
*
* we don't care about exactly total records, just pagination as page by page
* see https://github.com/hammerstonedev/fast-paginate
*/
@nguyenhiepvan
nguyenhiepvan / cockroachdb-compose.yml
Last active May 9, 2022 14:13 — forked from vuthaihoc/docker-compose.yml
Run cockroachdb cluster with docker
version: "3"
services:
crdb1:
image: cockroachdb/cockroach:v21.2.6
ports:
# - "26257:26257"
- "8889:8080"
command: start --certs-dir=/cockroach/certs --join crdb1,crdb2,crdb3 --accept-sql-without-tls --store=path=/cockroach/cockroach-data,size=1G --listen-addr=crdb1
@nguyenhiepvan
nguyenhiepvan / clean.sh
Created March 25, 2022 13:15
clean server
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs
@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"
@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 / 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]