Skip to content

Instantly share code, notes, and snippets.

@hexx
hexx / main.scala.html
Created May 26, 2012 13:36
main.scala.html
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>@title</title>
</head>
@hexx
hexx / board.scala.html
Created May 26, 2012 12:35
board.scala.html
@import com.github.hexx.messageboard.Message
<table class="table table-striped">
<thead>
<tr><th>Name</th><th>Message</th><th>Date</th></tr>
</thead>
<tbody>
@for(m <- Message.query.sort(_.date desc).asIterator) {
<tr><td>@m.name</td><td>@m.message</td><td>@m.date</td></tr>
}
</tbody>
@hexx
hexx / form.scala.html
Created May 26, 2012 12:31
form.scala.html
<form action="/" method="post" class="well form-inline">
<label>Name:<input name="name"></label>
<label>Message:<input name="message"></label>
<input type="submit">
</form>
@hexx
hexx / gaeds-twirl-sample.scala
Created May 26, 2012 02:55
Gaeds and Twirl Sample
package com.github.hexx.messageboard
import java.util.Date
import unfiltered.request._
import unfiltered.response._
import com.github.hexx.gaeds.{ Datastore, Mapper, Property }
import com.github.hexx.gaeds.Property._
class Message(
val name: Property[String],
@hexx
hexx / rsstumblrbot.scala
Created April 26, 2012 10:08
RSS Tumblr-Bot
package com.github.hexx.rsstumblrbot
import java.util.Date
import scala.collection.JavaConverters._
import com.sun.syndication.feed.synd.SyndEntry
import com.sun.syndication.io.{ SyndFeedInput, XmlReader }
import _root_.dispatch._
import _root_.dispatch.gae.Http
import _root_.dispatch.oauth.{ Consumer, Token }
import unfiltered.request._
@hexx
hexx / gaeds-lowlevel-query-sample.scala
Created April 21, 2012 11:11
Google App Engine Low Level API Query Sample
import scala.collection.JavaConverters._
import com.google.appengine.api.datastore.Query
import com.google.appengine.api.datastore.Query.FilterOperator._
import com.google.appengine.api.datastore.Query.SortDirection._
val q = new Query(kind)
q.addFilter("age", GREATER_THAN_OR_EQUAL, 10)
q.addFilter("age", LESS_THAN_OR_EQUAL, 20)
q.addSort("age", ASCENDING)
q.addSort("name", ASCENDING)
@hexx
hexx / gaeds-query-sample.scala
Created April 21, 2012 11:00
gaeds Query Sample
val ps = Person.query.filter(_.age #>= 10).filter(_.age #<= 20).sort(_.age asc).sort(_.name asc).asIterator
@hexx
hexx / gaeds-put-get-sample.scala
Created April 21, 2012 10:44
gaeds Put and Get Sample
// 共通部分
import com.github.hexx.gaeds.{ Mapper, Property }
import com.github.hexx.gaeds.Property._
// データ定義
class Person(val name: Property[String], val age: Property[Long]) extends Mapper[Person] {
def this() = this("", 0)
}
object Person extends Person
@hexx
hexx / gaeds-lowlevel-put-get-sample.scala
Created April 21, 2012 10:38
Google App Engine Low Level API Put and Get Sample
// 共通部分
import com.google.appengine.api.datastore.{ DatastoreServiceFactory, Entity }
val ds = DatastoreServiceFactory.getDatastoreService
val kind = "Person"
// データ定義
case class Person(name: String, age: Long)
// 保存
@hexx
hexx / launchconfig
Created April 14, 2012 16:30
Scalamblr Lauchconfig
[app]
version: 0.0.1
org: com.github.hexx
name: scalamblr
class: com.github.hexx.scalamblr.Scalamblr
[scala]
version: 2.9.1
[repositories]
local
scala-tools-releases