Skip to content

Instantly share code, notes, and snippets.

@wiflish
wiflish / RestTemplateGetJsonParameter.java
Last active October 21, 2015 03:59
RestTemplate的Get方法请求参数支持json结构的字符串
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
/**
*一般情况下,restTemplate的GET方法不支持类似:url?body={}的情况,因为会将{}解释为一个路径变量,会进行替换操作。
*这时要使用UriComponentsBuilder
*/
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("msisdn", msisdn)
.queryParam("email", email)
@wiflish
wiflish / .profile
Last active August 29, 2015 14:20
Mac OS X 中 Terminal 下 Bash 提示中显示 git 当前分支和状态
# Mac OS X 中 Terminal 下 Bash 提示中显示 git 当前分支和状态
# hostname:directory[branch-name] username$ # 干净的工作目录
# hostname:directory[branch-name*] username$ # 不干净的工作目录
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@wiflish
wiflish / logback.xml
Created October 17, 2014 13:22
logback配置文件.
<?xml version="1.0" encoding="UTF-8"?>
<!-- 打开自动扫描功能,间隔30秒,所以在系统启动后可以直接修改此文件,无需重启服务器 -->
<configuration scan="true" scanPeriod="30 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{80} - %msg%n</Pattern>
</encoder>
</appender>
<!-- 按照日期滚动日志文件,如果大于设置的值,则按照当日中文件大小滚动。 -->
@wiflish
wiflish / h5-placeholder
Created October 4, 2014 14:28
浏览器兼容性css设置placeholder样式
::-webkit-input-placeholder { /* WebKit browsers */
font-family: "Helvetica Neue","微软雅黑",Helvetica,STHeiTi,Arial,sans-serif ;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
font-family: "Helvetica Neue","微软雅黑",Helvetica,STHeiTi,Arial,sans-serif ;
opacity: 1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
font-family: "Helvetica Neue","微软雅黑",Helvetica,STHeiTi,Arial,sans-serif ;
opacity: 1;
@wiflish
wiflish / idea.desktop
Created October 4, 2014 00:16
ubuntu桌面描述文件.
[Desktop Entry]
Encoding=UTF-8
Name=idea
Comment=idea-IC-135.690
Exec=/home/wiflish/install/ide/idea-IC-135.690/bin/idea.sh
Icon=/home/wiflish/install/ide/idea-IC-135.690/bin/idea.png
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Development;
@wiflish
wiflish / PortUnificationServerHandler
Created September 2, 2014 13:20
netty支持多协议示例。
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
-- MySQL urlencode 函数、urldecode函数 、multiurldecode 函数
-- urlencode
DROP FUNCTION IF EXISTS urlencode;
DELIMITER |
CREATE FUNCTION urlencode (s VARCHAR(4096)) RETURNS VARCHAR(4096)
DETERMINISTIC
CONTAINS SQL
BEGIN
DECLARE c VARCHAR(4096) DEFAULT '';
DECLARE pointer INT DEFAULT 1;
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft