Skip to content

Instantly share code, notes, and snippets.

View veryyoung's full-sized avatar

veryyoung veryyoung

View GitHub Profile
@veryyoung
veryyoung / City.java
Last active August 29, 2015 14:20
从统计局获取的城市信息
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum City implements BaseEnum {
/**
* 北京
@veryyoung
veryyoung / OrderBySqlFormulaUtils.java
Last active August 29, 2015 14:20
扩展hibernate自定义排序
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.criterion.CriteriaQuery;
import org.hibernate.criterion.Order;
/**
* Created by veryyoung on 2015/5/7.
* Extends {@link org.hibernate.criterion.Order} to allow ordering by an SQL formula passed by the user.
* Is simply appends the <code>sqlFormula</code> passed by the user to the resulting SQL query, without any verification.
*
@veryyoung
veryyoung / auto_reload.sh
Last active August 29, 2015 14:24
自动化部署服务
#!/bin/bash
sh /data/tomcat8/bin shutdown.sh
cd /data/source && git pull origin branch
mvn clean package -Dmaven.test.skip=true
sh /data/tomcat8/bin startup.sh
@veryyoung
veryyoung / FileGathering.java
Last active October 10, 2015 08:40
合并文件,可用来制作传说中的图种。运行时把文件路径当做参数传入,最后一个参数为输出文件的路径。
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class FileGathering {
public static void main(String[] args) throws IOException {
combineFiles(args);
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('110000', '北京市', '010', 'beijing', 'bj', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('120000', '天津市', '022', 'tianjin', 'tj', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('310000', '上海市', '021', 'shanghai', 'sh', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('500000', '重庆市', '023', 'zhongqing', 'zq', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('130000', '河北省', '', 'hebei', 'hb', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simple_pinyin, city_type) VALUES ('140000', '山西省', '', 'shanxi', 'sx', 'PROVINCE');
INSERT INTO `pp_common_city` (city_code, city_name, area_code, pinyin, simpl
@veryyoung
veryyoung / db_backup.sh
Last active September 26, 2016 11:36
定时备份数据
#! /bin/Bash
# config in crontab 30 23
# 30 23 * * * sh /root/backup/backup.sh>>/root/backup/backup.log
DB_USER='root'
DB_PASSWORD=''
DB_NAME='test'
BACKDIR='/root/backup'
currentDate=`date +%F`
#!/sh/bash
###
### 查询当日 uv, 接收 yyyyMMdd 格式的参数, 默认日期为今天
###
LOG_PATH='/var/log/nginx/'
FILE_PREFIX='access.log-'
date=$1
#!/sh/bash
###
### 查询当月 uv, 接收 yyyyMMdd 格式的参数, 默认月份为当月
###
LOG_PATH='/var/log/nginx/'
FILE_PREFIX='access.log-'
month=$1
#!/sh/bash
###
### 查询当月的每日 uv 详情, 接收 yyyyMMdd 格式的参数, 默认月份为当月
###
LOG_PATH='/var/log/nginx/'
FILE_PREFIX='access.log-'
month=$1
#include <stdio.h>
int main(void) {
int nums[] = {1, 2, 3 , 4, 5};
int length = sizeof(nums) / sizeof(nums[0]);
for(int i=0; i<length; i++){
printf("%d,", nums[i]);
}
printf("%c", 8);
return 0;