Skip to content

Instantly share code, notes, and snippets.

View bjornharrtell's full-sized avatar

Björn Harrtell bjornharrtell

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
function consolidateImageWMSLayers (layers) {
let i, j
const layersProcessed = [] // need to record processed layers to only process once
const layersToConsolidate = [] // intended to contain arrays of layer that are to be consolidated
const otherIndices = [] // indices of unconsolidated layers, will be used when assembling new layers
const isImageWMS = layer => layer.type === 'Image' && layer.source.type === 'ImageWMS'
const isProcessed = layer => layersProcessed.indexOf(layer) !== -1
const isCandidate = (l1, l2) => l1.source.url === l2.source.url && !(l1.metadata.unconsolidated === true || l2.metadata.unconsolidated === true)
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
@bjornharrtell
bjornharrtell / osm.land_polygons.sql
Last active August 29, 2015 14:24
Rectangular cut out of OSM land_polygons subdivided to contain at most 1000 vertices
-- source is in 4326
drop table osm.land_polygons_3006;
create table osm.land_polygons_3006 (gid serial primary key, geom geometry(Polygon,3006));
with transformed_subset1 as (
select ST_Transform(ST_ClipByBox2D(geom, ST_MakeEnvelope(0, 40, 50, 75, 4326)), 3006) as geom from osm.land_polygons
), subset2 as (
select ST_ClipByBox2D(geom, ST_MakeEnvelope(-350000, 5600000, 1870000, 7980000, 3006)) as geom from transformed_subset1 where ST_IsEmpty(geom) is false
)
insert into osm.land_polygons_3006 (geom) select (ST_Dump(ST_SubDivide(geom, 1000))).geom from subset2 where ST_IsEmpty(geom) is false;
@bjornharrtell
bjornharrtell / split_polygon.sql
Last active August 29, 2015 14:24
split_polygon
CREATE OR REPLACE FUNCTION osm.split_polygon(polygon geometry, level integer)
RETURNS SETOF geometry AS
$BODY$
DECLARE
num_points int;
mid double precision;
envelope geometry;
b1 geometry;
b2 geometry;
geom1 geometry;
@bjornharrtell
bjornharrtell / cleanpolys.sql
Last active August 29, 2015 14:13
cleanpolys
-- Function: gkdb.repairgeom(geometry)
-- DROP FUNCTION gkdb.repairgeom(geometry);
CREATE OR REPLACE FUNCTION gkdb.repairgeom(polygon geometry)
RETURNS geometry AS
$BODY$
DECLARE
linework geometry;
@bjornharrtell
bjornharrtell / ArcdesPlugin.scala
Last active December 21, 2015 15:39
bukkit test code
package org
import org.bukkit.plugin.java.JavaPlugin
import com.mchange.v2.c3p0.ComboPooledDataSource
class ArkdesPlugin extends JavaPlugin {
val cpds = new ComboPooledDataSource()
cpds.setDriverClass("org.postgresql.Driver")
cpds.setJdbcUrl("jdbc:postgresql:test")
@bjornharrtell
bjornharrtell / java.java
Last active November 23, 2022 18:38
Java vs. Scala example of callback implementation to animate on touch then do something when animation is finished (AndEngine SDK). I suggest that Java callback API and usage is boring because it requires a design pattern (Observer) and interfaces to define the API and classes to implement at all times...
// bad/lazy Java, too nested... should implement callback classes separately, but that also feels like overkill and leads to macaroni code
// other crap parts is that all interface methods needs implementation and ugly override annotations.
scene.setOnAreaTouchListener(new IOnAreaTouchListener() {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) {
if (pSceneTouchEvent.isActionDown()) {
scene.registerEntityModifier(new DelayModifier(1.0f, new IEntityModifierListener() {
@Override
public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
}
@bjornharrtell
bjornharrtell / One.js
Created January 25, 2013 18:26
Using files in this gist as input to jsbuild will result in dependency order test.js, One.js, Two.js which will fail since Two.js is needed when defining One.js. The circular dependency is silly but valid.... Two.js should have higher precedence than One.js when ordering because it is used as a base class, Two.js only needs One.js when invoking …
/*
* @requires two/Two.js
*/
function One() { }
Two.prototype = new Two();
@bjornharrtell
bjornharrtell / twolist.scala
Created September 8, 2012 10:57
Filter a with c?
val a = Vector.fill(64){true}
val b = Vector.fill(64){false}
val c = b.updated(10, true)
a zip c foreach { case (ae, ce) => if (ce) ae = false }