Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Sargent wsargent

View GitHub Profile
@wsargent
wsargent / gist:1492419
Created Dec 18, 2011
results of package
View gist:1492419
[20:57:05] wsargent:Play20 git:(master) $ git submodule init
Submodule 'documentation/manual' (git@github.com:playframework/Play20.wiki.git) registered for path 'documentation/manual'
[20:57:08] wsargent:Play20 git:(master) $ git submodule update
Cloning into documentation/manual...
remote: Counting objects: 1995, done.
remote: Compressing objects: 100% (1824/1824), done.
remote: Total 1995 (delta 1350), reused 498 (delta 149)
Receiving objects: 100% (1995/1995), 1.50 MiB | 602 KiB/s, done.
Resolving deltas: 100% (1350/1350), done.
Submodule path 'documentation/manual': checked out '82c6d05375fad4c1afaccf259f22b964d3c25deb'
@wsargent
wsargent / JsonSpec.scala
Created Dec 19, 2011
Modified JsonSpec
View JsonSpec.scala
package play.api.json
import org.specs2.mutable._
import play.api.json._
object JsonSpec extends Specification {
case class User(id: Long, name: String, friends: List[User], skills: Map[String, Int])
implicit object UserFormat extends Format[User] {
@wsargent
wsargent / export_wp.rb
Created Feb 13, 2012
Export typo comments to disqus using Nokogiri
View export_wp.rb
# RAILS_ENV=production bundle exec rails runner ./script/wp_export.rb >! blog.wxr
# Require nokogiri in Gemfile here
site_link = "http://tersesystems.com/"
site_name = "Terse Systems"
builder = Nokogiri::XML::Builder.new do |xml|
xml.rss('version' => "2.0",
'xmlns:content' => "http://purl.org/rss/1.0/modules/content/",
'xmlns:wfw' => "http://wellformedweb.org/CommentAPI/",
@wsargent
wsargent / export_typo.rb
Created Feb 16, 2012
Exporting Typo to Disqus
View export_typo.rb
# Require nokogiri in Gemfile here
site_link = "http://tersesystems.com/"
site_name = "Terse Systems"
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.rss('version' => "2.0",
'xmlns:content' => "http://purl.org/rss/1.0/modules/content/",
'xmlns:dsq' => "http://www.disqus.com/",
'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
@wsargent
wsargent / ActionHandler.scala
Created Jul 7, 2012
ActionHandler for Remember Me cookie based authentication
View ActionHandler.scala
/**
* Remember me cookie based authentication using Action Composition in Play 2.0.
*
* Code based on blog post from http://jaspan.com/improved_persistent_login_cookie_best_practice
*
* Create an object or class with this trait, and put it in your Global.onRouteRequest like so:
*
* <pre>
override def onRouteRequest(request: RequestHeader): Option[Handler] = {
super.onRouteRequest(request).map {
View Netty ByteBuf leak on AkkaHttpWebSocketSpec
> testOnly play.it.http.websocket.AkkaHttpWebSocketSpec
[info] AkkaHttpWebSocketSpec
[info]
[info] Plays WebSockets should
[info] allow handling WebSockets using Akka streams
[info] + allow consuming messages
[info] + allow sending messages
[info] + close when the consumer is done
[info] + allow rejecting a websocket with a result
View play.policy
// GeneratePolicyFromDeniedPermissions - timestamp: Thu Dec 17 13:24:58 PST 2015
grant codeBase "file:/home/wsargent/work/activator-play-tls-example/target/universal/activator-play-tls-example-1.0.0/lib/activator-play-tls-example.activator-play-tls-example-1.0.0-sans-externalized.jar" {
permission java.io.FilePermission "certs/clientca.jks", "read";
permission java.io.FilePermission "certs/example.com.jks", "read";
permission java.io.FilePermission "certs/password", "read";
permission java.util.PropertyPermission "play.ssl.needClientAuth", "read";
};
grant codeBase "file:/home/wsargent/work/activator-play-tls-example/target/universal/activator-play-tls-example-1.0.0/lib/ch.qos.logback.logback-classic-1.1.3.jar" {
@wsargent
wsargent / Hello.scala
Last active Dec 17, 2015
Prograde example
View Hello.scala
package com.example
object Hello {
def main(args: Array[String]): Unit = {
val runtime = Runtime.getRuntime
val cwd = System.getProperty("user.dir")
val process = runtime.exec(s"$cwd/testscript.sh") // pick something harmless
println("Process executed without security manager interference!")
}
}
@wsargent
wsargent / gist:6640993
Created Sep 20, 2013
logging dead letter
View gist:6640993
class DeadLetterLogger extends Actor with ActorLogging {
def receive = {
case DeadLetter(message, sender, recipient) =>
log.info("DeadLetter message {}", message)
}
}
val deadLetterLogger = system.actorOf(Props(classOf[DeadLetterLogger]))
system.eventStream.subscribe(deadLetterLogger, classOf[DeadLetter])
View gist:7906205

Setup vagrant vm

vagrant box add precise64 http://files.vagrantup.com/precise64.box
vagrant init precise64
sed -i '.bak' 's/# config.vm.network :private_network/config.vm.network :private_network/' Vagrantfile
vagrant up
vagrant ssh

Install base software and apache (to have something to proxy)