Head
<head>
<!--<script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>-->
<script id="jquery" src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
</head>
Template
case class Currency(name: String, short: String, p: String, left: Boolean = false) { | |
def digits(value: Double) = append("%.2f" format value, short) | |
def words(value: Double) = { | |
val before = w(value.toLong) | |
val after = w(((value * 100.0f) % 100).toLong) | |
List(before, after).filterNot(_.isEmpty).zip(List(short, p)). | |
map(t => List(t._1, t._2)).flatten.mkString(" ").trim | |
} |
import org.apache.poi.ss.formula.{EvaluationWorkbook, EvaluationSheet, EvaluationCell, EvaluationName, FormulaParsingWorkbook, FormulaParser, FormulaType, WorkbookEvaluator, IStabilityClassifier} | |
import org.apache.poi.ss.formula.ptg.{Ptg, NamePtg, NameXPtg} | |
import org.apache.poi.ss.formula.udf.{UDFFinder, AggregatingUDFFinder} | |
import org.apache.poi.ss.formula.functions.FreeRefFunction | |
import org.apache.poi.ss.usermodel.Cell | |
import org.apache.poi.ss.SpreadsheetVersion | |
import org.apache.poi.ss.formula.eval._ | |
class DBUDFFinder extends UDFFinder { | |
def findFunction(name: String): FreeRefFunction = { |
object NotNull { | |
def apply[R](n: => R)(f: => R) = try { | |
if (n == null) throw new NullPointerException | |
n | |
} catch { case npe: NullPointerException => f } | |
} |
import javax.persistence._ | |
object JPA { | |
val unit = "jpa" | |
val emf = Persistence.createEntityManagerFactory(unit) | |
def t[R](f: EntityManager => R) = { | |
val em = emf.createEntityManager | |
val transaction = em.getTransaction |
import sbt._ | |
import Keys._ | |
import sbtassembly.Plugin._ | |
import AssemblyKeys._ | |
object SWTApp extends Build { | |
val osName = System.getProperty("os.name") | |
println("OS name: %s" format osName) | |
val osArch = System.getProperty("os.arch") |
Head
<head>
<!--<script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>-->
<script id="jquery" src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
</head>
Template
class DictoList: | |
def __init__(self): | |
self.d = {} | |
def add_keys(self, *keys): | |
d = self.d | |
for k in keys: | |
if not k in d: | |
d[k] = {} | |
d = d[k] | |
def get(self, *keys): |
class Picture(models.Model): | |
image = models.ImageField(upload_to = 'realestate/', null = True, blank = True) | |
... | |
picture = Picture.objects.create(image = File(open(urllib.urlretrieve(path)[0]))) |
# ID Sequences | |
You can provide a `Sequence` for your `Entities` in order to alter generated ID's from default UUID's. | |
The traits you can use: | |
``` | |
trait Entity extends BaseEntity with UUID | |
trait EntityWithCustomID[ID] extends BaseEntity with CustomID[ID] | |
trait EntityWithGeneratedID[ID] extends BaseEntity with GeneratedID[ID] |
val primes = { | |
def sieve(nums: Stream[Int]): Stream[Int] = | |
Stream.cons(nums.head, sieve((nums.tail) filter (_ % nums.head != 0))) | |
sieve(Stream.from(2, 1)) | |
} | |
println(primes.take(1000).mkString(", ")) |