Skip to content

Instantly share code, notes, and snippets.

@lhcpig
lhcpig / bash.sh
Last active October 15, 2015 05:14
useful command note
./command -yes -no /home/username
$# = 3
$* = -yes -no /home/username
$@ = array: {"-yes", "-no", "/home/username"}
$0 = ./command, $1 = -yes etc.
chkconfig --list #列出所有的系统服务
chkconfig --add httpd #增加httpd服务
chkconfig --del httpd #删除httpd服务
chkconfig --level httpd 2345 on #设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态
@lhcpig
lhcpig / git-deploy.py
Created July 21, 2015 08:54
script-tools
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'lhcpig'
import sys
import os
gitDir = "/home/git/repositories/test.git"
deployLogPath = "/home/lhcpig/deploy.log"
tomcatPath = "/this/is/tomcat"
workTree = "/home/lhcpig/projectName"
  • 使用 env 命令来查看 web 容器的环境变量 $ sudo docker run --rm --link redis-test:redis redis env

  • 连接名为redis-test的redis container sudo docker run -it --link redis-test:xxx --rm redis sh -c 'exec redis-cli -h "$XXX_PORT_6379_TCP_ADDR" -p "$XXX_PORT_6379_TCP_PORT"'

  • 启动activeMQ sudo docker run -d -P --name activemq-test -e 'ACTIVEMQ_MIN_MEMORY=128' -e 'ACTIVEMQ_MAX_MEMORY=512' webcenter/activemq

  • 进入正在运行的docker

# Firefox over VNC
#
# VERSION 0.1
# DOCKER-VERSION 0.2
from ubuntu:12.04
# make sure the package repository is up to date
run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
run apt-get update
  • show variables like'character_set_%'; 查看编码
  • set names utf8; 设置编码
  • load data infile "/answer" into table test1 fields terminated by '|'; mysql导入数据
  • update a join b on a.id = b.id set a.columnToUpdate = [something];
@lhcpig
lhcpig / 0_reuse_code.js
Created January 26, 2016 02:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public static String[] getNullPropertyNames (Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
Set<String> emptyNames = new HashSet<String>();
for(java.beans.PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
if (srcValue == null) emptyNames.add(pd.getName());
}
String[] result = new String[emptyNames.size()];
@lhcpig
lhcpig / start.sh
Last active April 14, 2017 09:12
jenkins 部署spring-boot应用
#!/bin/sh
nohup /usr/bin/java -jar $1 >> $2 &
wget http://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.bz2 -O /var/tmp/Python-3.5.0.tar.bz2
bzip2 -cd /var/tmp/Python-3.5.0.tar.bz2 | tar xvf -
cd /var/tmp/Python-3.5.0
./configure
yum groupinstall "Development tools"
yum install openssl-devel
make && make install
/usr/local/bin/python3 --version
ln -s /usr/local/bin/python3 /usr/bin/python3
@lhcpig
lhcpig / trial.key
Created December 19, 2017 06:45 — forked from huqi/trial.key
Beyond Compare 4 license for Mac
Beyond Compare 4
Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Windows
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t