This file contains hidden or 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
/** | |
* 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 |
This file contains hidden or 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
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' |
This file contains hidden or 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
/** | |
* an example model | |
*/ | |
case class Person(@BeanProperty id: Int, | |
@BeanProperty name: String, | |
@BeanProperty phone: String, | |
@BeanProperty dob: DateMidnight) { | |
} |
This file contains hidden or 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> | |
<body> | |
<p> | |
Person: | |
<p> | |
ID: ${person.id} <br> | |
Name: ${person.name} <br> | |
DOB: ${person.dob} <br> | |
Phone: ${person.phone} <br> | |
<p> |
This file contains hidden or 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
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 |
This file contains hidden or 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
@Configuration("springConf") | |
@EnableWebMvc | |
@ComponentScan(Array("skellybones")) | |
@PropertySource(Array("classpath:/app.properties", "${runtime.properties.file}")) | |
class WebConfig { | |
@Autowired | |
var environment: Environment = null | |
/** |
This file contains hidden or 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
/** | |
* Our instance of WebApplicationInitializer. This replaces web.xml for the initial | |
* configuration of the servlet. | |
*/ | |
class WebAppInit extends WebApplicationInitializer { | |
override def onStartup(servletContext: ServletContext) { | |
// Create the 'root' Spring application context | |
val root = new AnnotationConfigWebApplicationContext() |
This file contains hidden or 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
// Generate a broccoli like structure | |
#include "colors.inc" | |
#include "textures.inc" | |
light_source { | |
<-100, 400,-200> | |
color <0.8,0.8,0.8> | |
area_light <50,0,0>, <0,0,50>, 5, 5 | |
adaptive 1 | |
jitter |
This file contains hidden or 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
/** | |
* See bottom for file for example spheres scene | |
*/ | |
import java.awt.Color | |
import java.awt.image.BufferedImage | |
import java.io.File | |
import javax.imageio.ImageIO | |
import math.sqrt | |
import math.min | |
import math.max |
This file contains hidden or 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
public List<String> randomDictionaryWords() throws IOException { | |
try (InputStream is = new FileInputStream(new File("/usr/share/dict/words"))) { | |
BufferedReader br = new BufferedReader(new InputStreamReader(is)); | |
return br.lines() | |
.filter(line -> line.length() >= MIN_WORD_LENGTH && line.length() <= MAX_WORD_LENGTH) | |
.filter(word -> word.equals(word.toLowerCase())) | |
.filter(word -> random() < DICTIONARY_SAMPLING_RATE) | |
.limit(50) | |
.collect(Collectors.toList()); |
OlderNewer