Skip to content

Instantly share code, notes, and snippets.

View aaberg's full-sized avatar

Lars Aaberg aaberg

View GitHub Profile
@aaberg
aaberg / Dockerfile
Created October 25, 2022 14:27
Dockerfile for a svelte kit application
# Base image for
FROM node:16 as dependencies_base
ARG NPM_TOKEN
WORKDIR /app
COPY package*.json ./
RUN npm config set @aaberg:registry https://gitlab.com/api/v4/packages/npm/
RUN npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' "${NPM_TOKEN}"
@aaberg
aaberg / KeyValueListTest.java
Last active August 29, 2015 14:07
Key value list that wraps a org.sql2o.Table instance.
public class KeyValueList <E, V> extends AbstractList<Map.Entry<E, V>> {
private final Table data;
private final Class classOfE;
private final Class classOfV;
public KeyValueList(Table data, Class<E> classOfE, Class<V> classOfV) {
this.data = data;
// It is necessary to specify the class of the key and value,
// as it is not possible to get this information from java generics.
@aaberg
aaberg / gist:933f934db3785ec6d05b
Created June 4, 2014 11:24
Truncate table with sql2o
try (Connection connection = sql2o.open()) {
connection.createQuery("truncate table mytable").executeUpdate();
}
@aaberg
aaberg / postgreSQLTest.java
Last active November 13, 2017 11:28
Shows how to get generated key from Postgres with sql2o
Sql2o sql2o = new Sql2o(url, user, pass);
// Get generated key from SERIAL column
@Test
public void testKeyKeyOnSerial() {
String createTableSql = "create table test_serial_table (id serial primary key, val varchar(20))";
sql2o.createQuery(createTableSql).executeUpdate();
String insertSql = "insert into test_serial_table(val) values ('something')";
@aaberg
aaberg / Security.java
Created November 18, 2012 12:00 — forked from sealskej/Application.java
Login to play20 application with google acount
@SuppressWarnings("serial")
public static final Map<String, String> identifiers = new HashMap<String, String>() {
{
put("google", "https://www.google.com/accounts/o8/id");
}
};
public static Result auth() {
Logger.debug("authenticate");
String providerId = "google";