Skip to content

Instantly share code, notes, and snippets.

View oakhole's full-sized avatar

Yang oakhole

View GitHub Profile
@oakhole
oakhole / download_mp3_from_nginx_server
Last active February 9, 2022 13:33
Download mp3 from nginx server
location ~ ^.*/(?P<request_basename>[^/]+\.(mp3))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
@oakhole
oakhole / date_format.js
Created December 19, 2017 15:00
日期格式化
/**
* 日期格式化
* @param {[type]} fmt [description]
* @return {[type]} [description]
*/
Date.prototype.format = function(fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
@oakhole
oakhole / GetV4IP.java
Created July 13, 2017 02:37
获取外网IP地址
public static String getV4IP(){
String ip = "";
String chinaz = "http://ip.chinaz.com";
StringBuilder inputLine = new StringBuilder();
String read = "";
URL url = null;
HttpURLConnection urlConnection = null;
BufferedReader in = null;
try {
@oakhole
oakhole / WebHook
Created August 18, 2015 05:02
利用 inetd 实现web server
#!/bin/bash
base=/var/www
read request
while /bin/true; do
read header
[ "$header" == $'\r' ] && break;
done
url="${request#POST }"
@oakhole
oakhole / Center-vertical
Created July 11, 2015 15:29
CSS垂直居中显示
div{
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
@oakhole
oakhole / H5-web-Orientation
Last active August 29, 2015 14:24
h5移动端网页头部标签模板
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<!-- 声明文档使用的字符编码 -->
<meta charset='utf-8'>
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 页面描述 -->
<meta name="description" content="不超过150个字符"/>
<!-- 页面关键词 -->
@oakhole
oakhole / Generate.java
Last active August 29, 2015 14:04
基于freemarker代码生成,根据个人需要修改模板
/*
* Copyright (c) 2013-2014. Powered by http://oakhole.com .
*
* Licensed 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
<html>
<head>
<title>simple tree demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function initTree(){
var nodes=[{id:1,name:'a',pid:0},
{id:2,name:'b',pid:1},
{id:3,name:'c',pid:1},
{id:4,name:'d',pid:0},
@oakhole
oakhole / CompressFileGZIP.java
Last active January 1, 2016 19:39
gzip 打包/解包 文件
import java.util.zip.GZIPOutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class CompressFileGZIP {
private static void doCompressFile(String inFileName) {
@oakhole
oakhole / RandomValidateCode.java
Last active January 10, 2018 15:51
生成随机验证码
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;