Skip to content

Instantly share code, notes, and snippets.

View fringedgentian's full-sized avatar

Rebecca Grenier fringedgentian

View GitHub Profile
@fringedgentian
fringedgentian / gist:0f43e2c9672095891d18
Last active August 29, 2015 14:10
left join in Slick
case class File(id: Int, path: String, fileType: String, size: Int, uid: Int)
class Files(tag: Tag) extends Table[File](tag, "files") {
def id = column[Int]("fid", O.PrimaryKey)
def path = column[String]("filepath")
def fileType = column[String]("filemime")
def size = column[Int]("filesize")
def uid = column[Int]("uid")
def * = (id, path, fileType, size, uid) <> (File.tupled, File.unapply _)
}
In Controller:
def articleDetail(article: Article, page: Int)(implicit request: play.api.mvc.Request[Any]): Result = {
Ok(views.html.mobile.article(article, page))
}
In article template:
@(article: drupalslick.data.Article, page: Int)(implicit request: play.api.mvc.Request[Any])
from math import sqrt, pow
def distance(a, b):
return sqrt(pow(a[0] - b[0],2) + pow(a[1] - b[1],2))
def bruteMin(points, current=float("inf")):
if len(points) < 2: return current
else:
head = points[0]
del points[0]
This does not work, please do not use this if you get to this via search
object Node {
import Connector.db
def apply(nid: Int): Option[Node] = {
db withSession {
val ntype = Query(NodeMap).filter(_.nid is nid).map(_.ntype).firstOption
ntype.map { typestring =>
@fringedgentian
fringedgentian / application.html.erb
Created December 29, 2011 16:36
issues with including javascript and css
<!DOCTYPE html>
<html>
<head>
<title>IApp</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>