Skip to content

Instantly share code, notes, and snippets.

View thara's full-sized avatar
🎯
Focusing

Tomochika Hara thara

🎯
Focusing
View GitHub Profile
@thara
thara / gist:4115486
Created November 20, 2012 02:03
Zipファイルに圧縮する
/**
* 指定されたファイルをZip形式で圧縮し、同じディレクトリに作成する。
*
* @param zipFile 作成先のZIPファイルを示す{@link File}オブジェクト
* @param srcFile 圧縮対象の元ファイルを示す{@link File}オブジェクト
* @throws IOException ファイルIOで例外が発生した場合
*/
void makeZip(File zipFile, File srcFile) throws IOException {
final int bufferSize = 256;
@thara
thara / gist:4258412
Created December 11, 2012 13:02
FizzBuzz -simple-
main() {
var limit = 100;
for (var i = 1; i <= limit; i++) {
var sb = new StringBuffer();
if (i % 3 == 0) {
sb.add("Fizz");
}
if (i % 5 == 0) {
sb.add("Buzz");
@thara
thara / gist:4258421
Created December 11, 2012 13:04
FizzBuzz - functional -
var limit = 100;
fizz(i) => i % 3 == 0 ? "Fizz" : "";
buzz(i) => i % 5 == 0 ? "Buzz" : "";
for (var i = 1; i <= limit; i++) {
var sb = new StringBuffer().add(fizz(i)).add(buzz(i));
print(sb.isEmpty ? "${i}" : sb);
}
@thara
thara / gist:4683134
Created January 31, 2013 14:17
build error for dartlang.org
t-hara:dartlang t_hara$ make copy
rm -rf ./build
compass compile src/site/
unchanged src/site/scss/style.scss
cd ./src/site && jekyll --no-server --no-auto && cd ../.. && cp -R ./src/appengine/* build/
Configuration from /Users/t_hara/work/site/dartlang/src/site/_config.yml
Building site: . -> ../../build/static
Liquid Exception: uninitialized constant Albino in index.markdown
/Users/t_hara/work/site/dartlang/src/site/_plugins/pygments_cache.rb:14:in `render_pygments'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/tags/highlight.rb:44:in `render'
@thara
thara / DCI-sample.dart
Last active December 14, 2015 20:38
A simple DCI sample with Mix-in in Dart.
import 'package:unittest/unittest.dart';
import 'dart:async';
main () {
test("DCI sample in Dart", () {
var checking = new Account(balance : 50);
var saving = new Account(balance : 45);
@thara
thara / itext_copy.java
Created March 19, 2013 06:02
iTextを使用した、既存PDFに対する編集
// PdfStamperのコンストラクタに渡したOutputStreamは、PdfStamper#close内でcloseメソッドが呼ばれてしまうため、
// 一時領域としてByteArrayOutputStreamを渡し、編集結果のバイト文字列を引数のOutputStreamに書き込む。
ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
PdfStamper stamp;
try {
stamp = new PdfStamper(original, tempOut);
} catch (IOException e) {
throw new DocumentException(e);
@thara
thara / operator_to_list_by_mixin.dart
Last active December 15, 2015 11:49
Mix-in sample in Dart. I want to make Seq looks like Seq in Scala...
import 'package:unittest/unittest.dart';
void main() {
print("intersect");
(new Seq([1, 2, 3]) & new Seq([2, 3, 4])).forEach(print);
print("union");
(new Seq([1, 2, 3]) | new Seq([2, 3, 4])).forEach(print);
@thara
thara / gist:5840840
Created June 22, 2013 13:20
Dependency Injection with Implicit Interfaces & Mix-in in Dart.
main () {
new Service().execute();
new AwesomeService().execute();
}
class Repository {
List<String> find() => ["data1", "data2"];
}
class Service {
@thara
thara / gist:5989564
Last active December 19, 2015 17:09
OCamlプロンプトで日本語表示する
# let printer ppf = Format.fprintf ppf "\"%s\"";;
# #install_printer printer;;
@thara
thara / gist:6659164
Last active December 23, 2015 15:59 — forked from kmizu/gist:1876800
com.github.mpeltonen#sbt-idea;1.0.0: not found対応

Scala 開発環境構築手順

前提条件

  • JDKがinstall済みであること
  • java コマンドに環境変数Pathが通っていること