Skip to content

Instantly share code, notes, and snippets.

@roundrop
roundrop / gist:1432442
Created December 5, 2011 05:35
A sample to shorten url using Google URL Shortener API.
package jp.roundrop.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
@roundrop
roundrop / gist:1450687
Created December 9, 2011 08:03
jQuery plugin sample: Twitter-like dynamic character countdown for textareas
/*
jQuery plugin sample: Twitter-like dynamic character countdown for textareas
Example:
$('#textarea').countdown({
limit: 140,
init: function(counter){
$('#counter').css('color','#999999').val(counter);
$('#submit').attr('disabled','disabled');
@roundrop
roundrop / uninstall_homebrew.sh
Created March 18, 2012 08:53 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
# check sudo
if [ "`whoami`" != "root" ]; then
echo "You need to be root to run this!"
exit 1
fi
@roundrop
roundrop / env.txt
Created September 28, 2012 15:24 — forked from kimukou/env.txt
facebook4j_twitter4j_compare
GroovyConsleの動きがいまいちの場合は以下を修正すること
(groovyConsoleのシェルの方を治すのも可。特にMac!!)
$GROOVY_HOME/bin
startGroovy
## 先頭に
export JAVA_HOME=/Library/Java/Home
export JAVA_OPTS='-Dgroovy.source.encoding=UTF-8 -Dfile.encoding=UTF-8'
@roundrop
roundrop / Jetty9.1.5 + Quercus4.0.39 + WordPress3.9日本語版
Last active December 13, 2015 21:28
Jetty9.1.5 + Quercus4.0.39 + WordPress3.9日本語版
Jetty9.1.5 + Quercus4.0.39 + WordPress3.9日本語版
環境
===========
* Vagrant 1.5.3
* Ubuntu 14.04 64bit - https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
* Java 1.7.0_55
事前準備
====
@roundrop
roundrop / S2ExceptionHandler
Created June 24, 2013 11:02
org.apache.struts.action.ExceptionHandler の拡張。 これをglobal-exceptionsのhandlerに使用することで、pathにSAStrutsが認識するパスをそのまま記述することが可能となる。
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;
import org.seasar.struts.config.S2ActionMapping;
@roundrop
roundrop / S2RequestProcessor#setProperty(Object, String, Object) の拡張
Created June 24, 2013 11:05
S2RequestProcessor#setProperty(Object, String, Object) の拡張 PHPでよくある感じのattributes[]などでもActionFormにセットされるように拡張
private static final String INDEXED_DELIM = "[";
private static final String INDEXED_DELIM2 = "]";
@Override
protected void setProperty(Object bean, String name, Object value) {
if (bean == null) {
return;
}
int startIndexedIndex = name.indexOf(INDEXED_DELIM);
int endIndexedIndex = name.indexOf(INDEXED_DELIM2);
@roundrop
roundrop / code.gas
Created July 4, 2013 11:07
GroovyからGoogle Spreadsheetに何かを書き込むってのを書いてみた 参考: https://gist.github.com/cho45/4222750 GETでリクエストするのであまり大量のデータは書き込めない
function doGet(req) {
var result = { ok : 0 };
if (req.parameters.api_key == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') {
var rows = [];
try { rows = JSON.parse(req.parameters.rows) } catch (e) { }
if (rows.length) {
var ss = SpreadsheetApp.openById('*****************************************');
var sheet = ss.getSheets()[0];
for (var i = 0, len = rows.length; i < len; i++) {
@roundrop
roundrop / index.html
Created September 10, 2013 02:57
javascriptでテキストボックスの末尾にキャレット移動
<html>
<head></head>
<body>
<input type="text" id="foo" value="" />
</body>
</html>
@roundrop
roundrop / gist:6789917
Created October 2, 2013 06:52
S2JDBC で PostgreSQL の CopyManager を取得する方法
public CopyManager getCopyManager() throws SQLException {
Connection conn = ((JdbcManagerImplementor) jdbcManager).getDataSource().getConnection();
XAConnection xaConn = ((ConnectionWrapperImpl) conn).getXAConnection();
Connection pgConn = xaConn.getConnection();
return ((PGConnection) pgConn).getCopyAPI();
}