Skip to content

Instantly share code, notes, and snippets.

View ElderMael's full-sized avatar
🏠
Working from home

Miguel Enriquez ElderMael

🏠
Working from home
View GitHub Profile
@ElderMael
ElderMael / SprayTestCase.scala
Created January 12, 2014 01:54
Trying to use Hamcrest Matchers in Scala
private def checkHttpStatus(response: Future[HttpResponse]) {
val statusCode = Await.result(response, 10 seconds).status
println(s"Status code: ${statusCode.intValue}")
assertThat(s"Expected 200 OK or 304 Not Modified, received ${statusCode.intValue}",
statusCode.intValue,
CoreMatchers.anyOf(CoreMatchers.equalTo(200), CoreMatchers.equalTo(304)))
#!/bin/bash
# by http://github.com/jehiah
# this prints out some branch status (similar to the '... ahead' info you get from git status)
# example:
# $ git branch-status
# dns_check (ahead 1) | (behind 112) origin/master
# master (ahead 2) | (behind 0) origin/master
tot_diff=0
@ElderMael
ElderMael / Permutations.java
Created October 8, 2014 14:37
Permutations of a String in Java
static class Permutations {
public static void main(String... args) {
System.out.println("Permutations of 'abcd'");
System.out.println(Permutations.of("abcd"));
}
public static List<String> of(String string) {
if (string == null) {
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
@ElderMael
ElderMael / module.ceylon
Last active November 13, 2015 20:26
Ceylon HTTP Server
native ("jvm") module io.codexarcana.web "1.0.0" {
import ceylon.net "1.2.0-2";
}
@ElderMael
ElderMael / run.ceylon
Last active April 1, 2016 18:21
Try with Ceylon
shared class Try<out Result> given Result satisfies Anything {
late Result|Exception computationResult;
shared new (Result() computation) {
try {
this.computationResult = computation();
} catch (Exception e) {
this.computationResult = e;
}
module test.io.eldermael.utils.tryal "1.0.0" {
import ceylon.test "1.2.2";
import io.eldermael.utils.tryal "1.0.0";
}
native("jvm") module example.ws "1.0" {
import javax.jaxws "8";
import maven:"org.springframework:spring-web" "4.3.2.RELEASE";
import maven:"org.springframework:spring-core" "4.3.2.RELEASE";
import maven:"org.springframework:spring-beans" "4.3.2.RELEASE";
import maven:"org.springframework:spring-context" "4.3.2.RELEASE";
import maven:"org.springframework:spring-context-support" "4.3.2.RELEASE";
}
plugins {
id 'com.athaydes.ceylon' version '1.3.0'
}
ceylon {
module = 'io.eldermael.ceylon.boot'
}
repositories {
jcenter()
import org.springframework.boot { ... }
import org.springframework.boot.autoconfigure { ... }
import org.springframework.stereotype { ... }
import org.springframework.web.bind.annotation { ... }
import java.lang { JString=String }
import ceylon.interop.java { javaClass, javaString }
controller
enableAutoConfiguration