Skip to content

Instantly share code, notes, and snippets.

View tamtam180's full-sized avatar

tamtam180 tamtam180

View GitHub Profile
@tamtam180
tamtam180 / gist:2341752
Created April 9, 2012 05:49
AvocadoDBのJavaClientのサンプルコード。こんな感じのものになります。
/*
* Copyright (C) 2012 tamtam180
*
* 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
@tamtam180
tamtam180 / gist:2343583
Created April 9, 2012 13:55
AvocadoDB, Http response json was broken.
[tamtam@tamsvr20 tmp]$ curl --data @- -X POST --dump - "http://127.0.0.1:8529/document?collection=unit_test_issue35"
{"xx": "xx\""}
HTTP/1.1 202 Accepted
etag: "1811904640"
connection: Keep-Alive
content-type: application/json; charset=utf-8
server: triagens GmbH High-Performance HTTP Server
location: /document/1809181757/1811904640
content-length: 63
@tamtam180
tamtam180 / StringUtils.java
Created June 13, 2012 15:48
なんか構造が美しくないのでリファクタしたい・・
public class StringUtils {
private static final char NO_BREAK_SPACE = '\u00A0';
private static final char NARROW_NOBREAK_SPACE = '\u202F';
private static final char ZERO_WIDTH_NOBREAK_SPACE = '\uFEFF';
private static final char WORD_JOINER = '\u2060';
private static final char FIGURE_SPACE = '\u2007';
public static boolean isSpace(char c) {
@tamtam180
tamtam180 / gist:2925376
Created June 13, 2012 17:27 — forked from komiya-atsushi/gist:2925087
なんか構造が美しくないのでリファクタしたい・・ こんなのはどうかな?(komiya)
public static List<String> tokenize(String str) {
if (str == null || str.isEmpty()) {
return Collections.emptyList();
}
ArrayList<String> tokens = new ArrayList<String>();
int i = 0;
char[] chars = str.toCharArray();
while (i < chars.length) {
@tamtam180
tamtam180 / gist:2950233
Created June 18, 2012 19:29
JavaScriptで簡単なRubyの変数展開をサポートする
function format(template, param) {
param = param || [];
return template.replace(/#{(\w+?)}/g, function(matcher, key) {
var data = param[key] || '';
return (typeof data === "function") ? data() : data;
});
}
@tamtam180
tamtam180 / gist:2953002
Created June 19, 2012 08:23
どーすりゃよいのでござるか・・
function Hoge() {
}
Hoge.ptototype = {
kwd : [],
doFuga : function() {
var jqxhr = this.fetchKwd(); // 何かしらのajax
jqxhr.success(function(){
// ここで kwdにアクセスしたい...
});
}
@tamtam180
tamtam180 / Leak.java
Created June 23, 2012 05:07
リークの確認テスト
public class Leak {
public static void main(String[] args) throws Exception {
File tmpDir = new File("mytmp");
if (!tmpDir.exists()) {
tmpDir.mkdirs();
}
// 無理やりPIDを取得。Linuxのみ。
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
public class MySample1 {
public static void main(String[] args) throws Exception {
final AtomicInteger cnt1 = new AtomicInteger();
int[] array = new int[1000]; // ここはDBからとってくる
for (int i = 0; i < array.length; i++) {
array[i] = i;
}
public class PrototypeScopeMetadataResolver implements ScopeMetadataResolver {
private ScopeMetadata protoMetaData;
public PrototypeScopeMetadataResolver() {
protoMetaData = new ScopeMetadata();
protoMetaData.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
}
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {