Skip to content

Instantly share code, notes, and snippets.

View vuthaihoc's full-sized avatar
🤒
ke ke ặc ặc

Stupid Dev vuthaihoc

🤒
ke ke ặc ặc
View GitHub Profile
@vuthaihoc
vuthaihoc / backup.sh
Created October 12, 2021 18:26
Dump db and put to s3 by minio client
#!/bin/bash
# file /var/www/backup.sh
# Run `cd /var/www && sh backup.sh`
# This script is used for laravel projects deployed by deployer php
function run_backup(){
export $(cat current/.env | sed 's/#.*//g' | xargs)
@vuthaihoc
vuthaihoc / pdftitle.py
Last active May 25, 2021 01:40 — forked from TestItOnlyOnce/pdftitle.py
Rename pdf files to their content's titles (for Python 3; with wildcard support; default rename all pdfs)
#!/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
@vuthaihoc
vuthaihoc / docker-compose.yml
Created December 24, 2020 08:42
Example with seaweedfs
version: '3'
services:
master:
image: chrislusf/seaweedfs # use a remote image
ports:
- 9333:9333
- 19333:19333
command: "master -ip=master"
volumes:
@vuthaihoc
vuthaihoc / ChatCommand.php
Created November 26, 2020 10:29
demo redis pub/sub
<?php
declare(ticks = 1);
namespace App\Console\Commands;
use Illuminate\Console\Command;
class ChatCommand extends Command
{
@vuthaihoc
vuthaihoc / dump_db
Created November 15, 2020 16:02
Dump DB with mysql info from .env file (laravel)
#!/bin/bash
export $(cat current/.env | sed 's/#.*//g' | xargs)
export MYSQL_PWD=$DB_PASSWORD
mysqldump -u $DB_USERNAME $DB_DATABASE \
--no-tablespaces \
--verbose \
--result-file $DB_DATABASE.sql
@vuthaihoc
vuthaihoc / PrependsTimestamp.php
Created October 20, 2020 02:39
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
{
@vuthaihoc
vuthaihoc / parseLinks.php
Created August 18, 2020 01:50
Parse link dạng range
@vuthaihoc
vuthaihoc / system_usage_log.sh
Last active June 23, 2020 09:54
System usage bash
#!/bin/bash
## Use : ss command
## variable for change :
##
##----------
Timetemp='%H%M'
Time=$(date +"${Timetemp}")
Date=$(date +"%y%m%d")
Yest=$(date --date="1 day ago" +"%y%m%d")
#Day=$(date +"%a")
@vuthaihoc
vuthaihoc / create_mysql5_db.sh
Last active September 28, 2020 01:42
Script create db, user and grant permission
#!/bin/bash
# sudo ./mysql-db-create.sh dbname dbuser password
# Functions
ok() { echo -e '\e[32m'$1'\e[m'; } # Green
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
@vuthaihoc
vuthaihoc / create user.md
Created May 30, 2020 15:45
Centos scripts

Login as root and ...

# create new user
useradd hocvt
# change pass
passwd hocvt
# add to sudoer
usermod -aG wheel hocvt
# login to created user