Skip to content

Instantly share code, notes, and snippets.

@kinumi
kinumi / gist:3674361
Created September 8, 2012 12:21
try-with-resourcesを使ったトランザクション/Finder
// Finder
try (Tx tx = new Tx(sf)) {
{
DBTest test = tx.from(DBTest.class).uniq();
assertNotNull(test);
}
{
DBTest test = tx.from(DBTest.class).where("name = 'aaa'").uniq();
assertNotNull(test);
}
@kinumi
kinumi / gist:3672491
Created September 8, 2012 07:11
try-with-resourcesを使ったトランザクション/テスト
package info.kinumi.common;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Test;
public class TxTest {
@kinumi
kinumi / gist:3672486
Created September 8, 2012 07:10
try-with-resourcesを使ったトランザクション
package info.kinumi.common;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
/**
* try-with-resourcesを使ったトランザクション
*
* try (Tx tx = new Tx(sf)) {
var load = this.load;
this.win.addEventListener("open", function() {
load();
});
Ti.include("win_search.js");
var tabGroup = Titanium.UI.createTabGroup();
var tab1 = Titanium.UI.createTab({
icon: "KS_nav_views.png",
title: "検索",
window: (new SearchWindow1().win)
});
@kinumi
kinumi / gist:1139868
Created August 11, 2011 14:53
TiBlobを受け取って、文字列化して返すTitaniumモジュール
#pragma Public APIs
-(id)stringFromShiftJISData:(id)args
{
ENSURE_SINGLE_ARG(args, NSObject);
if ([args isKindOfClass:[TiBlob class]]) {
TiBlob *blob = (TiBlob*)args;
return [[[NSString alloc] initWithData:blob.data encoding:NSShiftJISStringEncoding] autorelease];
}
else {
@kinumi
kinumi / gist:1017011
Created June 9, 2011 15:41
MRTGのCPU温度監視設定 / VAIO TypeP + Ubuntu 11.04
Target[cputemp]: `/usr/bin/sensors | grep temp1 | awk '{print $2}' | sed -e 's/+//' -e 's/[^0-9+\.].*//';echo 0.0`
MaxBytes[cputemp]: 100
Title[cputemp]: CPU Temperature
PageTop[cputemp]: <h1>CPU Temperature</h1>
Options[cputemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[cputemp]: ymw
#unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: CPU