Skip to content

Instantly share code, notes, and snippets.

@mchericoni
mchericoni / Empty.java
Last active August 29, 2015 14:18
Java 8 Lazy Lists
import java.util.function.Predicate;
public class Empty<T> implements LazyList<T> {
@Override
public T head() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@mchericoni
mchericoni / geolocation_ipinfo.html
Created March 25, 2015 08:57
Geolocation and redirect depending on Country
<!DOCTYPE html>
<html>
<head>
<title>Geolocation</title>
<meta charset="utf-8">
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.get("http://ipinfo.io", function(response) {
@mchericoni
mchericoni / ScalaWorksheet.sc
Created February 27, 2015 11:33
Breadth-first search problem in Scala
object SumProblem {
// States
type State = Int
val initialState: State = 5 //> initialState : SumProblem.State = 5
val target: State = 23 //> target : SumProblem.State = 23
// Moves
class Move(addend: Int) {
def change(state: State): State = state + addend
override def toString = addend.toString
@mchericoni
mchericoni / Dockerfile
Created February 26, 2015 13:33
Dockerfile to build an image with Oracle Java 8
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN apt-get install oracle-java8-installer -y
RUN apt-get install oracle-java8-set-default