Skip to content

Instantly share code, notes, and snippets.

View yanhua365's full-sized avatar

yanhua365 yanhua365

View GitHub Profile
@yanhua365
yanhua365 / gist:cbdc2512ab5d75003ab4d80e399af774
Created June 26, 2018 07:07 — forked from tinoviena/gist:2893779
Groovy script to make HTTP request using Java standard library.
URL url = new URL(urlTarget);
HttpURLConnection connection;
method = "GET" // POST, PUT, ...
data = "" // for GET, otherwise e..g JSON
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod(method);
connection.setRequestProperty("Content-Length", "" + Integer.toString(data.getBytes().length));
@yanhua365
yanhua365 / ConcordionSpringJunit4ClassRunner.java
Created August 25, 2017 10:49 — forked from eeichinger/ConcordionSpringJunit4ClassRunner.java
Spring Test / Concordion integration - integrate Concordion with Spring's test runner
package testsupport;
import org.concordion.api.ResultSummary;
import org.concordion.internal.FixtureRunner;
import org.junit.runner.Description;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@yanhua365
yanhua365 / solrj-dependencies-by-grapes.groovy
Created October 20, 2014 07:20
Groovy中通过Grape设置solrj依赖的代码
@Grapes([
@Grab(group='org.apache.solr', module='solr-solrj', version='4.6.0'),
@Grab(group='org.slf4j', module='slf4j-api', version="1.6.6"),
@Grab(group='org.slf4j', module='slf4j-log4j12', version="1.6.6")
])
@yanhua365
yanhua365 / read-head-line-of-big-file.sh
Created October 11, 2014 02:15
读取大文件的前几行的命令
#这样的速度快
sed -n '10,20p' test.txt
#用cat配合head或tail也可以,但大文件会内存溢出
cat test.txt|head -n 30
@yanhua365
yanhua365 / install-tiddlywiki-in-node.md
Last active August 29, 2015 14:07
安装tiddlywiki的node版本
Install [[Node.js]] from http://nodejs.org
Open a command line terminal and type:

npm install -g tiddlywiki

If it fails with an error you may need to re-run the command as an administrator:

npm install -g tiddlywiki (Windows)

sudo npm install -g tiddlywiki (Mac/Linux)

@yanhua365
yanhua365 / run-bat-and-hide-window.vbs
Created October 10, 2014 00:57
用vbscript来运行bat文件并隐藏窗口
dim objShell
set objShell=wscript.createObject("WScript.Shell")
iReturnCode=objShell.Run("c:\testcopy.bat",0,TRUE)
@yanhua365
yanhua365 / discuz_is_login.php
Created October 9, 2014 07:53
discuz论坛判断用户是否登录的功能
//$_G['uid'] 表示注册用户的的 id 号,如果用户已经登录,该变量非空!
//通过判断 $_G['uid'] 是否为空来判断用户是否已经登录,如果没有登录,则调用 showmessage 提示用户登录或者注册!
if(empty($_G['uid'])) {
showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
}
@yanhua365
yanhua365 / get_request_by_request_context.java
Created September 18, 2014 09:42
Spring配置RequestContextListener可以在任何地方得到HttpRequest对象。
//在任意的class下通过以下方法获取到HttpServletRequest
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
@yanhua365
yanhua365 / file_write_bench_test.groovy
Last active August 29, 2015 14:06
使用groovy和gbench对文件操作的两种方式(append和writer)进行基准测试(来自:https://stackoverflow.com/questions/23552282/groovy-file-append-vs-file-newwriter)
@Grab(group='org.gperfutils', module='gbench', version='0.4.2-groovy-2.1')
def b = benchmark {
'append' {
def f = File.createTempFile('file', 'append')
(1..1000).each {
f.append(it.toString())
}
}
'writer' {
title: My Slideshow
output: slideshow.html
author:
name: xxx
email: [email protected]
--
# Hello, world!
## This is my slideshow