Skip to content

Instantly share code, notes, and snippets.

View jamesnguyen101's full-sized avatar

Loi Nguyen jamesnguyen101

View GitHub Profile
@jamesnguyen101
jamesnguyen101 / setenv.sh
Last active August 29, 2015 14:17 — forked from terrancesnyder/setenv.sh
$TOMCAT_HOME/bin/setenv.sh|bat
#! /bin/sh
# ==================================================================
#https://gist.github.com/terrancesnyder/986029
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
# and enterprise use with large-scale deployments.
# Credits:
# Google -> Couldn't survive without it
# Stackoverflow.com -> Community support
/**
* Autowire Quartz Jobs with Spring context dependencies
* @see http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring/15211030#15211030
*/
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;
public void setApplicationContext(final ApplicationContext context) {
beanFactory = context.getAutowireCapableBeanFactory();
}
@jamesnguyen101
jamesnguyen101 / 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

@jamesnguyen101
jamesnguyen101 / 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
@jamesnguyen101
jamesnguyen101 / 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:
# 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
@jamesnguyen101
jamesnguyen101 / 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
@jamesnguyen101
jamesnguyen101 / 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
@jamesnguyen101
jamesnguyen101 / 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
@jamesnguyen101
jamesnguyen101 / 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
}
}