Skip to content

Instantly share code, notes, and snippets.

@1206yaya
1206yaya / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@1206yaya
1206yaya / MonthlyCalendar.java
Last active August 29, 2015 14:13
Calendar
import java.util.Calendar;
public class MonthlyCalendar {
private int year;
private int month;
private int[][] calendarMatrix = new int[6][7];
private int startDay;
private int lastDate;
/**
@1206yaya
1206yaya / 01Application.java
Last active August 29, 2015 14:13
play tettei 3.2
package controllers;
import models.*;
import java.util.*;
import play.*;
import play.data.*;
import play.mvc.*;
import views.html.*;
@1206yaya
1206yaya / Application.java
Created January 18, 2015 02:26
play tettei 3.3 scalaを使ったテンプレートの記述 @Repeaat
package controllers;
import models.*;
import java.util.*;
import play.*;
import play.data.*;
import play.mvc.*;
import views.html.*;
@1206yaya
1206yaya / Application.java
Created January 19, 2015 02:23
playJava 全件取り出し
// Finder用の内部クラス
public static class FindForm {
@Required
public String input;
}
// /findにアクセスした際のAction
public static Result find() {
Form<FindForm> f = new Form(FindForm.class).bindFromRequest();
List<Message> datas = null;
@1206yaya
1206yaya / conf.evolutions.default.1.sql
Created January 19, 2015 08:28
Play 2.xからPostgresqlに接続してAnormでCRUD操作するには
# --- !Ups
create table users(
id SERIAL,
name varchar(100),
email varchar(100),
password varchar(100),
createDate timestamp default current_timestamp,
primary key(id));
# --- !Downs
drop table users;
@1206yaya
1206yaya / FirstStep_2.scala
Created January 20, 2015 07:38
scala 基本
def max(x: Int, y: Int): Int = {
if (x > y) x
else y
}
def max2(x: Int, y: Int) = if (x > y) x else y
val list: List[String] = List[String]("A", "B", "C\n")
println(max(1, 2))
println(max2(3, 4))
@1206yaya
1206yaya / FunctionalObjects_6.scala
Created January 20, 2015 12:14
分数オブジェクトRational メソッド> + - * / 約分 ができる
package PSSE.code
//class Rational(n: Int, d: Int) {
// require(d != 0) // falseならば、IllegalArgumentExceptionを投げる
// override def toString = n + "/" + d
//}
// thatはaddメソッド呼びだしのレシーバーではないので、that.nとかthat.dとすることはできない※
// thatの分子や分母にアクセスするには、それらをフィールドにする必要がある
//class Rational(n: Int, d: Int) { // This won't compile
@1206yaya
1206yaya / BuiltinControlStructure.scala
Created January 21, 2015 04:20
組み込み制御構造 while for if 例外処理 match
package PSSE.code
object BuitinControlStructures extends App {
def gcdLoop(x: Long, y: Long): Long = {
var a = x
var b = y
while (a != 0) {
val temp = a
a = b % a
@1206yaya
1206yaya / ControlAbstraction_9.scala
Created January 21, 2015 10:25
制御の抽象化 カリー化 _ ローンパターン
package PSSE.code
import java.io.PrintWriter
object FileMatcher extends App {
private def filesHere = (new java.io.File("/tmp/scalaLesson/")).listFiles
// def filesEnding(query: String) =
// for (file <- filesHere; if file.getName.endsWith(query))
// yield file