Skip to content

Instantly share code, notes, and snippets.

@aaronlifton3
aaronlifton3 / posts.scala.html
Created December 17, 2012 05:08
play 2.0 scala form helper salat mongodb example
@(posts: List[Post], postForm: Form[Post])(implicit flash: Flash)
@main(Messages("posts.list")) {
<dl class="posts">
@for(post <- posts) {
<dt>
<a href="@controllers.routes.Posts.view(post.id)">@post.name</a>
</dt>
<dd>@post.description</dd>
@aaronlifton3
aaronlifton3 / Post.scala
Created January 8, 2013 19:41
Post model for Play 2.0
package models
import play.api.Play.current
import java.util.Date
import com.novus.salat._
import com.novus.salat.annotations._
import com.novus.salat.dao._
import com.mongodb.casbah.Imports._
import se.radley.plugin.salat._
import mongoContext._
@aaronlifton3
aaronlifton3 / mongoContext.scala
Created January 8, 2013 19:47
mongodb context for Play 2.0
package models
import com.novus.salat.dao._
import com.novus.salat.annotations._
import com.mongodb.casbah.Imports._
import com.novus.salat.{TypeHintFrequency, StringTypeHintStrategy, Context}
import play.api.Play
import play.api.Play.current
package object mongoContext {
@aaronlifton3
aaronlifton3 / server.py
Created January 21, 2013 23:45
simple python server for web development etc.
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
@aaronlifton3
aaronlifton3 / server.erl
Created January 21, 2013 23:53
simple erlang server
-module(hello).
-export([start/1]).
start(Port) ->
spawn(fun () -> {ok, Sock} = gen_tcp:listen(Port, [{active, false}]),
loop(Sock) end).
loop(Sock) ->
{ok, Conn} = gen_tcp:accept(Sock),
Handler = spawn(fun () -> handle(Conn) end),
@aaronlifton3
aaronlifton3 / zend_rest.php
Last active December 11, 2015 12:38
rest ftw bro, zf
<?php
public function indexAction()
{
$this->getResponse()->setBody('List of Resources');
$this->getResponse()->setHttpResponseCode(200);
}
public function getAction()
{
$this->getResponse()->setBody(sprintf('Resource #%s', $this->_getParam('id')));
# ~/.osx — http://mths.be/osx
###############################################################################
# General UI/UX #
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
scutil --set ComputerName "MathBook Pro"
scutil --set HostName "MathBook Pro"
scutil --set LocalHostName "MathBook-Pro"
@aaronlifton3
aaronlifton3 / .slate
Created March 16, 2013 00:23
my .slate file
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
config windowHintsSpread true
// Implementing the publishing Pusher REST API
// @see http://pusher.com/docs/rest_api
// with Play (scala) Framework
// @see http://scala.playframework.org/
class Pusher {
val appId = Play.configuration.getProperty("pusher.appId")
val key = Play.configuration.getProperty("pusher.key")
val secret = Play.configuration.getProperty("pusher.secret")
@aaronlifton3
aaronlifton3 / playpusher.scala
Created March 29, 2013 00:45
Scala 2.10 + Play 2.1 + Pusher
class Pusher {
val appId = Play.configuration.getString("pusher.appId")
val key = Play.configuration.getString("pusher.key")
val secret = Play.configuration.getString("pusher.secret")
import java.security.MessageDigest
import java.math.BigInteger
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec