Skip to content

Instantly share code, notes, and snippets.

View loinguyenduc101's full-sized avatar

Loi Nguyen loinguyenduc101

View GitHub Profile
@loinguyenduc101
loinguyenduc101 / bootapp.sh
Last active April 12, 2018 17:56
spring boot application start with jenkins
#!/bin/sh
#set -e
#latest jar
jarFile=$(ls ./target/*.jar | sort -r | head -1)
echo "===========> Jar File $jarFile"
#check and kill process
UP=$(pgrep -f $jarFile | wc -l)
UP_PID=$(pgrep -f $jarFile)
@loinguyenduc101
loinguyenduc101 / RsaExample.java
Created March 31, 2018 08:47 — forked from nielsutrecht/RsaExample.java
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
@loinguyenduc101
loinguyenduc101 / sync-dir.sh
Created February 27, 2018 04:41
sync two dir on local or remote
To sync the contents of dir1 to dir2 on the same system, type:
rsync -av --progress --delete dir1/ dir2
-a, --archive
        archive mode
--delete
        delete extraneous files from dest dirs
@loinguyenduc101
loinguyenduc101 / monitor.sh
Created February 25, 2018 16:45 — forked from mheadd/monitor.sh
Simple bash script to check whether MySQL is running.
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi
@loinguyenduc101
loinguyenduc101 / gist:14b8b48cf338e3f2233e77669c959d38
Created January 31, 2018 17:35 — forked from Ara4Sh/gist:863e4796801f0453460faddb78e0ea62
Nginx Redirect if useragent is android or iphone
# 1
location / {
set $mobile 0;
if ($http_user_agent ~* "iphone|android") {
set $mobile 1;
}
if ($mobile = 1) {
# return or rewrite to somewhere
}
}
@loinguyenduc101
loinguyenduc101 / ffmpeg_snapshot_version_install_centos_6.sh
Last active August 17, 2021 04:31
ffmpeg snapshot version install on centos 6
#! /bin/sh
#set -e
#to remove trailing \r character
#sed -i 's/\r$//' file_name.sh or using dos2unix to format: sudo yum install dos2unix -y
#https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
#ffmpeg_version=3.2.1
FFMPEG_HOME=/opt/ffmpeg
ffmpeg_version=snapshot
exec_time=$(date +"%Y%m%d%H%M%S");
echo "===============> install required packages for ffmpeg $ffmpeg_version"
@loinguyenduc101
loinguyenduc101 / ffmpeg_install_centos_6.sh
Last active January 20, 2018 15:04
ffmpeg 3.3.6 install on CentOS 6
#! /bin/sh
#set -e
#to remove trailing \r character
#sed -i 's/\r$//' file_name.sh or using dos2unix to format: sudo yum install dos2unix -y
#https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
#https://abi-laboratory.pro/tracker/timeline/ffmpeg/
FFMPEG_HOME=/opt/ffmpeg
FFMPEG_VERSION=3.3.6
exec_time=$(date +"%Y%m%d%H%M%S");
echo "=======================================> install required packages for ffmpeg $FFMPEG_VERSION"
@loinguyenduc101
loinguyenduc101 / latest-ffmpeg-centos6.sh
Created January 17, 2018 03:44 — forked from mustafaturan/latest-ffmpeg-centos6.sh
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@loinguyenduc101
loinguyenduc101 / Linux Static IP
Created October 31, 2017 16:17 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@loinguyenduc101
loinguyenduc101 / mysql_auto_backup.sh
Created October 25, 2017 14:35
mysql_auto_backup shell script! tested on centos 7
#!/bin/sh
## crontab: min hr mday month wday command
# 15 9 * * * /Users/[your user name]/scripts/auto_mysql_backup.sh
## Restore from Backup
# gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]
# or
# gunzip [backupfile.sql.gz]
# mysql -u [uname] -p[pass] [dbname] < [backupfile.sql]
HOSTNAME=localhost