Skip to content

Instantly share code, notes, and snippets.

View manuel-palacio's full-sized avatar

Manuel Palacio manuel-palacio

  • Cambio Healthcare Systems
  • Stockholm
View GitHub Profile
@manuel-palacio
manuel-palacio / people.groovy
Created May 2, 2018 12:17
Given a group of people with their birth years and death years, find the year/s with the highest population
class Person {
def birth
def death
}
def people = [
new Person(birth: 1960, death: 1971),
new Person(birth: 1960, death: 1972),
new Person(birth: 1960, death: 1972),
new Person(birth: 1965, death: 1971),
@manuel-palacio
manuel-palacio / recursion.java
Created May 7, 2014 14:39
Reverse a string with and without accumulator
public class Recursion {
public static String reverse(String str) {
if (null == str || str.length() <= 1) {
return str;
}
return reverse(str.substring(1)) + str.charAt(0);
}
mkdir -p web-app
unzip -o frontend/target/app.zip -d web-app
export DISPLAY=:1
Xvfb :1 &
#
# Fetch node if we don't have it already
#
node_version=v0.10.16
install_name=node-$node_version-linux-x64
node_home=$PWD/$install_name
export DISPLAY=:1
Xvfb :1 &
#
# Fetch node and testacular if we don't have it already
#
node_version=v0.10.16
install_name=node-$node_version-linux-x64
node_home=$PWD/$install_name
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-resources</id>
<phase>generate-resources</phase>
<configuration>
@manuel-palacio
manuel-palacio / Noise
Created December 19, 2013 13:16
Code with less noise 2 (blogger)
private List findProductsWithTotal(Invoice[] invoices, int total) {
List result = new LinkedList();
for (Invoice invoice : invoices) {
if(invoice.total() > 7000){
result.add(invoice);
}
}
return result;
}
@manuel-palacio
manuel-palacio / Invoice
Last active December 31, 2015 20:18
Code with less noise (blogger)
class Invoice {
List items
Date date
}
class Product {
String name
int dollar
}
@manuel-palacio
manuel-palacio / reverse.groovy
Last active December 15, 2015 17:19
Reverse string tokens
def text = "The return of the thin white duke"
def reverse(String text) {
text.split("\\s+").collect { it.reverse() }.join(' ')
}
assert reverse(text) == "ehT nruter fo eht niht etihw ekud"
@manuel-palacio
manuel-palacio / gist:f9146fe9bf9771ce621b
Last active December 2, 2016 09:35
Url shortener The shortened urls would look like: http://www.domain.com/pehgAN
import com.google.gson.Gson;
import org.apache.commons.codec.binary.Base64;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.HashMap;