⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multipartToJsonString(req: Option[MultipartFormData[Files.TemporaryFile]]): String = { | |
val jsFields = req.head.dataParts.flatMap { | |
case (key, values) => values.map { value => | |
if (key == "product_id" || !isAllDigits(value)) s""" "$key": "$value" """ // treat product_id as a string | |
else s""" "$key": ${value.toInt} """ | |
} | |
} | |
s"{${jsFields.mkString(",")}}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import slick.lifted.Rep | |
import slick.ast.Ordering.Direction | |
import slick.ast.Ordering | |
import slick.lifted.Query | |
import slick.lifted.ColumnOrdered | |
import slick.lifted.Ordered | |
import scala.util.control.NoStackTrace | |
case class PageRequest(offset: Int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate server.xml with the following command: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost:4443 | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.slick.lifted.CanBeQueryCondition | |
// optionally filter on a column with a supplied predicate | |
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = { | |
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
} | |
} | |
// example use case | |
import java.sql.Date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Generates a populated Job Card PDF using the data in the supplied array and returns an application file path to the newly generated PDF. | |
Requires the inclusion of the util function: 'generateJobCardFDF($inputData)' | |
*/ | |
function generatePopulatedJobCardPDF($jobCardData){ | |
//Format the form data | |
$formData['Job_Number']=$jobCardData['']; | |
$formData['Customer']=$jobCardData['']; | |
$formData['Description']=$jobCardData['']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
.clear{ | |
clear:both; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# All the things I can install from the command line when I set up a new Mac | |
# This can be executed by copying and pasting the following at a shell prompt | |
# curl https://raw.github.com/gist/2993226/initial_setup.sh | sh | |
# Install Homebrew | |
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" | |
# Homebrew packages | |
brew install python25 python26 python python32 python3 pypy |