Skip to content

Instantly share code, notes, and snippets.

View jsgao0's full-sized avatar

Anson jsgao0

View GitHub Profile
@jsgao0
jsgao0 / logstash.conf
Created September 20, 2016 05:50
Logstash config file on Ubuntu.
input {
file {
path => "/var/log/tomcat8/localhost_access_log*"
start_position => beginning
sincedb_path => "/dev/null"
ignore_older => 0
type => "access_log"
}
}
@jsgao0
jsgao0 / install-docker.sh
Last active September 14, 2016 05:48
Install docker and run a container of Tomcat on CentOS.
#!/bin/bash
# Program:
# Install docker engine.
# History:
# 2016/09/01 Anson First release
# 2016/09/02 Anson Second release: tomcat:8.5 & verify docker command is exist
# Set environment path.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
@jsgao0
jsgao0 / master-post-receive.sh
Last active November 3, 2016 07:10
Git hooks: change directory, git pull, mvn package, scp.
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
cd /git/project/path || exit
unset GIT_DIR
git pull
mvn clean package
sshpass -p password scp from_path username@remote_url:to_path
@jsgao0
jsgao0 / killTomcatUsingGrep.sh
Created August 17, 2016 07:31
Useful shells.
ps aux | grep ^tomcat | awk '{print$2}' | xargs kill -9
@jsgao0
jsgao0 / cssWaveAndStar.html
Last active August 12, 2016 15:58
The difference between CSS selector *= and ~=. DEMO link: http://codepen.io/jsgao0/pen/oLmgPO/.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>CSS selector *= vs ~=</title>
</head>
<body>
<h1 class="header" data-now="day">ALL SHOPS</h1>
<div class="promotion-bar" data-promotion-detail="day">John Bar</div>
@jsgao0
jsgao0 / Sample.java
Last active August 10, 2016 06:17
JPA Entity for DEMO.
package com.sample.entity;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Lob;
import javax.persistence.Table;
@jsgao0
jsgao0 / googleDrivePublicFile_s2.html
Last active July 11, 2016 05:07
Retrieve File From Google Drive Using Google Drive v2.
<html>
<head>
<script>
function driveRequest() {
var request = gapi.client.drive.files.get({
'fileId': 'File ID'
});
request.then(function(response) {
// response is the result.
});
@jsgao0
jsgao0 / page-load-status.html
Last active July 2, 2016 16:42
Check is first-page-load using Cookie.
<!DOCTYPE>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div id="pageLoadStatus"></div>
<script>
var _ = {};
/**
// Define JSON.
var contents = {
'en-US': {
'title': 'Hello!'
},
'zh-TW': {
'title': '哈囉!'
}
};
@jsgao0
jsgao0 / data-prefix.js
Created June 30, 2016 01:01
Difference between data-ng-model and ng-model in AngularJS
// Reference: http://www.concretepage.com/forum/thread?qid=462
/*
This is for #1 and #2.
<div id="userInfo" data-user-name="Anson">Anson</div>
*/
function nativeJS() { // #1
var userInfo = document.getElementById("userInfo");
var name = userInfo.getAttribute("data-user-name");