Skip to content

Instantly share code, notes, and snippets.

View musubu's full-sized avatar

Musubu Inc. musubu

View GitHub Profile
@musubu
musubu / gist:2596655
Created May 4, 2012 18:05
Java Regex for ISO8601
^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$
// Match
2009-12T12:34
2009
2009-05-19
2009-05-19
20090519
2009123
@musubu
musubu / ztrim.java
Created May 1, 2012 05:08
Javaで文字列の行頭と行末の全角または半角スペースをトリム
private static String ztrim(String string) {
int length = string.length();
int st = 0;
char[] val = string.toCharArray();
while (st < length && (val[st] <= ' ' || val[st] == ' ')) {
st++;
}
while (st < length && (val[length - 1] <= ' ' || val[length - 1] == ' ')) {
length--;
@musubu
musubu / schema.xml
Created April 30, 2012 12:25
junii2のメタデータで利用するためのSolrのschema.xml(部分)
<!-- junii2 -->
<field name="title" type="text_ja" indexed="true" stored="true" />
<field name="alternate" type="text_ja" indexed="true" stored="true" multiValued="true" />
<field name="creator" type="text_ja" indexed="true" stored="true" multiValued="true" />
<field name="subject" type="text_ja" indexed="true" stored="true" multiValued="true" />
<field name="NIIsubject" type="text_ja" indexed="true" stored="true" multiValued="true" />
<field name="NDC" type="string" indexed="false" stored="true" multiValued="true" />
<field name="NDLC" type="string" indexed="false" stored="true" multiValued="true" />
<field name="BSH" type="string" indexed="false" stored="true" multiValued="true" />
<field name="NDLSH" type="string" indexed="false" stored="true" multiValued="true" />
@musubu
musubu / XMLGregorianCalendarConversionutil.java
Created April 29, 2012 19:53
XMLGregorianCalendarConversionutil.java
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class XMLGregorianCalendarConversionUtil {
private static DatatypeFactory datatypeFactory = null;
@musubu
musubu / gist:2368792
Created April 12, 2012 16:20
load external script with jQuery
$.getScript('/path/to/script.js', function(data) {
eval(data)
})
@musubu
musubu / load-json-from-file.js
Created April 8, 2012 12:51
load json from file in node.js
var fs = require('fs');
fs.readFile('path/to/file.json', 'utf8', function(err, data) {
if (!err) {
var data = JSON.parse(data);
console.log(data);
} else {
console.log(err);
}
})
@musubu
musubu / opds-real-world.xml
Created April 8, 2012 04:29
opds-real-world.ymlから生成したOPDS Acquisition Feed
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:lang="ja">
<id>http://example.com/all.opds</id>
<title>サンプル出版社のOPDS取得フィード</title>
<updated>2012-04-03T15:00:00.000Z</updated>
<icon>http://example.com/favicon.ico</icon>
<author>
<name>サンプル出版株式会社</name>
<email>support@example.com</email>
<uri>http://example.com/support</uri>
@musubu
musubu / opds-may.xml
Created April 8, 2012 04:28
opds-may.ymlから生成したOPDS Acquisition Feed
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:lang="ja">
<id>http://example.com/all.opds</id>
<title>サンプル出版社のOPDS取得フィード</title>
<updated>2012-04-03T15:00:00.000Z</updated>
<icon>http://example.com/favicon.ico</icon>
<author>
<name>サンプル出版株式会社</name>
<email>support@example.com</email>
<uri>http://example.com/support</uri>
@musubu
musubu / opds-should.xml
Created April 8, 2012 04:26
opds-should.ymlから生成したOPDS Acquisition Feed
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:lang="ja">
<id>http://example.com/all.opds</id>
<title>サンプル出版社のOPDS取得フィード</title>
<updated>2012-04-03T15:00:00.000Z</updated>
<icon>http://example.com/favicon.ico</icon>
<author>
<name>サンプル出版株式会社</name>
<email>support@example.com</email>
<uri>http://example.com/support</uri>
@musubu
musubu / opds-must.xml
Created April 8, 2012 04:25
opds-must.ymlから生成したOPDS Acquisition Feed
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:lang="ja">
<id>http://example.com/all.opds</id>
<title>サンプル出版社のOPDS取得フィード</title>
<updated>2012-04-03T15:00:00.000Z</updated>
<icon>http://example.com/favicon.ico</icon>
<author>
<name>サンプル出版株式会社</name>
<email>support@example.com</email>
<uri>http://example.com/support</uri>