Skip to content

Instantly share code, notes, and snippets.

View wlievens's full-sized avatar

Wouter Lievens wlievens

  • Flywheel Software
  • Belgium
View GitHub Profile
import numpy as np
import time
kernel_cols = 2
kernel_rows = 3
rows = 180
cols = 160
data = np.array(np.arange(0, cols * rows).reshape((rows, cols)))
print('DATA')
print(data)
@wlievens
wlievens / rename-unique.sql
Created June 20, 2018 20:04
Automatically generated SQL for renaming single-column unique constraints
SELECT
constraint_type,
tc.constraint_name,
tc.table_name,
kcu.column_name,
format('ALTER TABLE "%s" RENAME CONSTRAINT %s TO unq_%s_%s;',
tc.table_name, tc.constraint_name, tc.table_name, kcu.column_name)
FROM
information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
@wlievens
wlievens / rewirte-fk.sql
Created June 20, 2018 19:58
Automagically rewrite postgresql foreign keys to properly structured names
SELECT
tc.constraint_name,
tc.table_name,
kcu.column_name,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name,
format('ALTER TABLE "%s" RENAME CONSTRAINT %s TO fk_%s_%s;',
tc.table_name, tc.constraint_name, tc.table_name, kcu.column_name)
FROM
information_schema.table_constraints AS tc
@Getter
@Setter
@AllArgsConstructor
private static class GeometryHandle
{
Geometry geometry;
}
public static Collector<Geometry, GeometryHandle, Geometry> collectorUnion(@NonNull GeometryFactory factory)
{
@wlievens
wlievens / gist:2d367eaf4a52e25e1b6aceeaa4d73169
Created October 24, 2017 13:22
Spring MVC - Getting a hold of all endpoint patterns and converting them to regexps
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
List<String> urlPatterns = requestMappingHandlerMapping.getHandlerMethods().keySet().stream()
.map(info -> info.getPatternsCondition().getPatterns().iterator().next())
.filter(pattern -> pattern.contains("{"))
.distinct()
.collect(toList());
endpoints = new Endpoint[urlPatterns.size()];
for (int index = 0; index < urlPatterns.size(); index++)
@wlievens
wlievens / verify-i18n-json.groovy
Created December 6, 2016 21:00
How to validate consistency of angular-translate (or other) json i18n files with groovy-maven-plugin
import groovy.json.JsonSlurper
log.info("Verifying JSON translation files ...")
def root = new File(sprintf('%s/src/main/resources/static/i18n/', project.basedir))
def slurper = new JsonSlurper()
def allKeys = [] as Set
def tables = [:]
root.listFiles().each {
final double maxDistance = Util.distance(centerX, chief, 0, 0);
final float[] hsb = new float[3];
for (int y = 0; y < size; ++y)
{
for (int x = 0; x < size; ++x)
{
final int oldARGB = image.getRGB(x, y);
final int oldA = (oldARGB >> 24) & 0xFF;
final int oldR = (oldARGB >> 16) & 0xFF;
final int oldG = (oldARGB >> 8) & 0xFF;