Skip to content

Instantly share code, notes, and snippets.

View algotrader-dotcom's full-sized avatar

Mai_Xoa algotrader-dotcom

View GitHub Profile
@algotrader-dotcom
algotrader-dotcom / Setup path env maven in Jenkins
Created June 12, 2016 12:35
Setup path env maven in Jenkins
Manage jenkins -> Configure system -> Global properties
key:PATH
value:$PATH:/var/jenkins_home/apache-maven-3.3.9/bin
Then in shell exec build: you can call $mvn clean package
@algotrader-dotcom
algotrader-dotcom / Docker cheat sheet
Last active July 24, 2018 01:50
Docker cheat sheet
# https://serversforhackers.com/video/ansible-installation-and-basics
################# Docker ##################
1. Run docker mysql version 5.7 with mounted volume on /docker-data/mysql on host and mount to 3306 to host port
$docker run -p 172.16.20.213:3306:3306 --name mysql-server -v /docker-data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7
OR
$docker run -p 3306:3306 --name mysql-server -v /docker-data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7
2. List docker running
$docker ps
@algotrader-dotcom
algotrader-dotcom / basic_iptables.sh
Created May 24, 2016 08:15 — forked from deangerber/basic_iptables.sh
Simple iptables firewall setup script.
#! /bin/bash
iptables -F
iptables -X
echo Allow ssh
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
echo Allow http and https
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
echo Allow pop, imap and smtp
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
@algotrader-dotcom
algotrader-dotcom / Convert vietnamese to non-ascii
Created May 10, 2016 17:41
Convert vietnamese to non-ascii
function covnvert_novn($str) {
// In thường
$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
$str = preg_replace("/(đ)/", 'd', $str);
// In đậm
@algotrader-dotcom
algotrader-dotcom / Translate "Featured Product" to "Anything" for woocommerce
Last active April 22, 2016 04:07
Translate "Featured Product" to "Anything" for woocommerce
@algotrader-dotcom
algotrader-dotcom / notes.md
Created March 15, 2016 03:18 — forked from DavidWittman/notes.md
A Brief Introduction to Fabric

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

@algotrader-dotcom
algotrader-dotcom / fabfile.py
Created March 14, 2016 16:24 — forked from elliottb/fabfile.py
Example Python Fabric deployment script. Deploys code from a deployment box to a remote host. Usage from command line on the deployment box: fab deploy.
from fabric.api import local, run, env, put
import os, time
# remote ssh credentials
env.hosts = ['10.1.1.25']
env.user = 'deploy'
env.password = 'XXXXXXXX' #ssh password for user
# or, specify path to server public key here:
# env.key_filename = ''
@algotrader-dotcom
algotrader-dotcom / Script auto install ffmpeg
Created March 7, 2016 08:51
Script auto install ffmpeg
#!/bin/bash
#Install FFmpeg
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel -y
mkdir ~/ffmpeg_sources
read -p "Ready?"
#Yasm
cd ~/ffmpeg_sources
@algotrader-dotcom
algotrader-dotcom / Drupal 7: Get path alias from node id
Created March 4, 2016 16:34
Drupal 7: Get path alias from node id
Edit index.php
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$path = $_GET["q"];
$alias = drupal_get_path_alias($path,"vi"); // Check table url_alias
print $alias;
@algotrader-dotcom
algotrader-dotcom / install-ffmpeg-amazon-linux.sh
Created March 4, 2016 09:04 — forked from gboudreau/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2)
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF