Skip to content

Instantly share code, notes, and snippets.

View benhardy's full-sized avatar

benhardy benhardy

View GitHub Profile
@benhardy
benhardy / WebConfig.scala
Created November 18, 2012 03:22
Spring/Scala web config
@Configuration("springConf")
@EnableWebMvc
@ComponentScan(Array("skellybones"))
@PropertySource(Array("classpath:/app.properties", "${runtime.properties.file}"))
class WebConfig {
@Autowired
var environment: Environment = null
/**
@benhardy
benhardy / PersonController.scala
Created November 18, 2012 02:25
the Person controller
package skellybones.web.controller
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation._
import org.springframework.web.servlet.ModelAndView
import org.springframework.beans.factory.annotation.Autowired
import skellybones.service.PersonService
import skellybones.web.ResourceNotFoundException
import skellybones.bo.Person
@benhardy
benhardy / demo-fragment.html
Created November 18, 2012 02:18
fragment of demo.jsp
<html>
<body>
<p>
Person:
<p>
ID: ${person.id} <br>
Name: ${person.name} <br>
DOB: ${person.dob} <br>
Phone: ${person.phone} <br>
<p>
@benhardy
benhardy / Person.scala
Created November 17, 2012 17:07
Person model
/**
* an example model
*/
case class Person(@BeanProperty id: Int,
@BeanProperty name: String,
@BeanProperty phone: String,
@BeanProperty dob: DateMidnight) {
}
@benhardy
benhardy / vagrant-bombing-out.txt
Created October 23, 2012 16:23
vagrant bombing out. hm.
ben@mac:~/scala/lascale> vagrant box add lascale https://dl.dropbox.com/u/4080054/la-scale.box
[vagrant] Downloading with Vagrant::Downloaders::HTTP...
[vagrant] Downloading box: https://dl.dropbox.com/u/4080054/la-scale.box
[vagrant] Extracting box...
[vagrant] Cleaning up downloaded box...
/Applications/Vagrant/embedded/gems/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb:493:in `read': undefined method `size' for nil:NilClass (NoMethodError)
from /Applications/Vagrant/embedded/gems/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb:740:in `block (2 levels) in extract_entry'
from /Applications/Vagrant/embedded/gems/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb:739:in `loop'
from /Applications/Vagrant/embedded/gems/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb:739:in `block in extract_entry'
from /Applications/Vagrant/embedded/gems/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar.rb:738:in `open'
@benhardy
benhardy / spring-di-java-conf-hadoop.java
Created May 17, 2012 22:31
Perform Spring based DI in Hadoop 0.18.x api without XML, and using supplied JobConf.
/**
* say you'd like to have a Hadoop Mapper inject its dependencies via a constructor
* instead of that super annoying post-construction configure call. e.g.
*
* Obviously Hadoop won't be able to instantiate this by itself, but we'll
* help it out below.
*
*/
public class TestMapper implements Mapper<IntWritable, Text, IntWritable, Text> {
private final NumberService numbers; // immutable goodness