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
#!/bin/bash | |
read -p "Enter server name: " SERVER_NAME | |
echo "INSTAP_SERVER=${SERVER_NAME}" > env | |
echo "File 'env' has been created with the server name." | |
sudo apt -y install jq | |
mkdir .instap | |
cd .instap |
import annotation.tailrec | |
import collection.parallel.mutable.ParSeq | |
def factorize(n: Long): List[Long] = { | |
@tailrec | |
def factors(tuple: (Long, Long, List[Long], Int)): List[Long] = { | |
tuple match { | |
case (1, _, acc, _) => acc | |
case (n, k, acc, _) if (n % k == 0) => factors((n / k, k, acc ++ ParSeq(k), Math.sqrt(n / k).toInt)) | |
case (n, k, acc, sqr) if (k < sqr) => factors(n, k + 1, acc, sqr) |
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(", ")) |
# 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] |
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]))) |
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): |
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
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") |
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 |
object NotNull { | |
def apply[R](n: => R)(f: => R) = try { | |
if (n == null) throw new NullPointerException | |
n | |
} catch { case npe: NullPointerException => f } | |
} |