Skip to content

Instantly share code, notes, and snippets.

View loinguyenduc101's full-sized avatar

Loi Nguyen loinguyenduc101

View GitHub Profile
@loinguyenduc101
loinguyenduc101 / nginxvarcore.md
Created October 20, 2017 17:41 — forked from esfand/nginxvarcore.md
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line
# Let us consider the following typical mysql backup script:
mysqldump --routines --no-data -h $mysqlHost -P $mysqlPort -u $mysqlUser -p$mysqlPassword $database
# It succeeds but stderr will get:
# Warning: Using a password on the command line interface can be insecure.
# You can fix this with the below hack:
credentialsFile=/mysql-credentials.cnf
echo "[client]" > $credentialsFile
echo "user=$mysqlUser" >> $credentialsFile
echo "password=$mysqlPassword" >> $credentialsFile
@loinguyenduc101
loinguyenduc101 / ip_blacklist.lua
Created October 17, 2017 03:04 — forked from chrisboulton/ip_blacklist.lua
Redis based IP blacklist for Nginx (LUA)
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@loinguyenduc101
loinguyenduc101 / stream_to_youtube.sh
Created September 11, 2017 18:33 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@loinguyenduc101
loinguyenduc101 / jenkins_yii.sh
Created September 11, 2017 14:40
shell script for yii app on jenkins
composer global require "fxp/composer-asset-plugin:^1.3.1"
composer config github-oauth.github.com fefbbf1d7e41286ed05fe5314260f7943e37a765
composer update
php init --env=Development --overwrite=All
@loinguyenduc101
loinguyenduc101 / install-docker-debain-9.sh
Last active July 29, 2017 11:17
install docker on debian 9 stretch
remove old version
#apt-get remove docker docker-engine
install all preRequisite packages
#apt install apt-transport-https \
ca-certificates software-properties-common \
curl apt-transport-https
@loinguyenduc101
loinguyenduc101 / nginx_reverse_proxy.conf
Created July 24, 2017 15:11
nginx reverse proxy config, eg for jenkins....
server{
listen 80;
server_name ci.xxx.vn;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
@loinguyenduc101
loinguyenduc101 / spring-boot-jenkin.sh
Last active July 17, 2017 03:36
spring-boot-jenkin
#http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
#https://stackoverflow.com/questions/28500066/how-to-deploy-springboot-maven-application-with-jenkins
sudo mvn clean package
service=appp_pay
jarfile=/var/lib/jenkins/workspace/appp_pay/target/appp-pay-0.1.jar
if ps ax | grep -v grep | grep -v $0 | grep $service > /dev/null
then
sudo service appp_pay stop
sudo unlink /etc/init.d/appp_pay
sudo chmod +x $jarfile
@loinguyenduc101
loinguyenduc101 / README-Template.md
Created July 14, 2017 19:23 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@loinguyenduc101
loinguyenduc101 / MailServiceImpl.java
Created July 11, 2017 06:54
Spring MailServiceImpl
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.mail.MessagingException;