Skip to content

Instantly share code, notes, and snippets.

View jmparsons's full-sized avatar

Jonathan Parsons jmparsons

View GitHub Profile
@jmparsons
jmparsons / twttr-date.coffee
Created June 21, 2013 22:46
Simple coffeescript method to convert a unix timestamp to a twitter date.
twd = (time) ->
date = new Date(time * 1e3)
diff = ((+new Date - date.getTime()) / 1e3)
ddiff = Math.floor(diff / 86400)
d = date.getDate()
m = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[date.getMonth()]
y = date.getFullYear().toString().slice(2)
return if isNaN(ddiff) or ddiff < 0
ddiff is 0 and (diff < 60 and Math.floor(diff) + "s" or diff < 3600 and Math.floor(diff / 60) + "m" or diff < 86400 and Math.floor(diff / 3600) + "h") or ddiff < 365 and d + " " + m or ddiff >= 365 and d + " " + m + " " + y
@jmparsons
jmparsons / Pages.scala
Last active December 18, 2015 09:39
Pages model difference between anorm and slick.
package models
import java.util.Date
import play.api.db._
import play.api.Play.current
import play.api.db.slick.DB
import play.api.db.slick.Config.driver.simple._
case class Page(id: Option[Long] = None, title: String, slug: String, content: String, posted_at: Date)
@jmparsons
jmparsons / Shell
Created February 6, 2013 20:37
Install Play 2.1.0 on OSX
brew install https://raw.github.com/gist/4725583/play.rb
brew switch play 2.1.0
brew which play
@jmparsons
jmparsons / Shell
Last active December 12, 2015 02:59
Install Play 2.1-RC4 on OSX
brew install https://raw.github.com/gist/4703352/play.rb
brew switch play 2.1-RC4
brew which play
@jmparsons
jmparsons / Shell
Last active December 11, 2015 22:38
Install Play 2.1-RC3 on OSX
brew install https://raw.github.com/gist/4670809/play.rb
brew switch play 2.1-RC3
brew which play
@jmparsons
jmparsons / Shell
Last active December 11, 2015 05:38
Install Play 2.1-RC2 on OSX
brew install https://raw.github.com/gist/4553175/play.rb
brew switch play 2.1-RC2
brew which play