Skip to content

Instantly share code, notes, and snippets.

View bjornharrtell's full-sized avatar

Björn Harrtell bjornharrtell

View GitHub Profile
@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 / Coffeescript ctags
Created June 9, 2012 17:14 — forked from yury/Coffeescript ctags
ctags definitions for coffeescript. Detects classes, static/class methods, fields, static fields, plain functions, variables.
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z.]+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z.]+):[^->\n]*$/\1/f,field/
--regex-coffee=/(constructor: \()@([A-Za-z.]+)/\2/f,field/
@bjornharrtell
bjornharrtell / HOWTO.md
Created July 5, 2012 15:47
How to configure and use JBoss AS 7 with Hibernate Spatial and PostGIS

How to configure and use JBoss AS 7 with Hibernate Spatial and PostGIS

This is in the scenario where you want JBoss to handle the datasource and transactions, for example when using injected @PersistenceContext in a @Stateless resource. I like it especially when writing REST services with JAX-RS (example code included below).

Create dir:

/modules/org/postgresql/main
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Net.Http.Headers;
namespace DAI.Edit.Backend.WebApi.Controllers
{
[Authorize]
@bjornharrtell
bjornharrtell / smallbuild
Last active November 26, 2019 21:50
gdal
CCACHE_CPP2=yes CC='ccache gcc' CXX='ccache g++' LDFLAGS='-lstdc++' ./configure --disable-all-optional-drivers --enable-driver-flatgeobuf --enable-driver-shape --enable-driver-gpkg --enable-driver-gml --enable-driver-pds --with-pg=no --with-libkml=no --without-lerc --without-libtool
CCACHE_CPP2=yes make USER_DEFS=-Werror -j4
# sanitize...
export LD_LIBRARY_PATH=/usr/lib/llvm-9/lib/clang/9.0.0/lib/linux
CFLAGS="-DMAKE_SANITIZE_HAPPY -fsanitize=undefined -fsanitize=address -fsanitize=unsigned-integer-overflow" CXXFLAGS="-DMAKE_SANITIZE_HAPPY -fsanitize=undefined -fsanitize=address -fsanitize=unsigned-integer-overflow" CCACHE_CPP2=yes LDFLAGS='-fsanitize=undefined -fsanitize=address -lstdc++' ./configure --disable-all-optional-drivers --enable-driver-flatgeobuf --enable-driver-shape --enable-driver-gpkg --enable-driver-gml --enable-driver-pds --with-pg=no --with-libkml=no --without-lerc --without-libtool --enable-debug
sed -i "s/-fsanitize=address/-fsanitize=address -shared-libasan/g" GDALmake.opt
sed -i "s/-fs
@bjornharrtell
bjornharrtell / populate_geometry_columns_table.sql
Created June 20, 2019 09:36 — forked from christippett/populate_geometry_columns_table.sql
MS SQL stored procedure to populate `geometry_columns` table. This table is used by QGIS to identify tables with spatial data.
-- =============================================
-- Author: Chris Tippett
-- Create date: 2014-08-12
-- Description: Detect columns with geometry datatypes and add them to [dbo].[geometry_columns]
-- =============================================
CREATE PROCEDURE [dbo].[Populate_Geometry_Columns] @schema VARCHAR(MAX) = '', @table VARCHAR(MAX) = ''
AS
BEGIN
SET NOCOUNT ON;
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[macro_use] extern crate serde_derive;
extern crate rocket_contrib;
use rocket_contrib::json::{Json};
#[derive(Serialize)]
pub struct User {
@bjornharrtell
bjornharrtell / Dockerfile
Last active October 15, 2017 08:24
postgis-asmvt
FROM debian:stretch
RUN apt-get update -qq && apt-get install -y \
postgresql-9.6 postgresql-server-dev-9.6 \
build-essential autoconf libtool \
libproj-dev libgdal-dev libgeos-dev \
libprotobuf-c-dev curl
RUN service postgresql start && su -l postgres -c "createuser -s `whoami`"
RUN curl --silent -L \
find ~/.steam/root/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" -o -name "libgpg-error*" \) -print
@bjornharrtell
bjornharrtell / components.my-component.js
Last active November 23, 2016 21:29
inline-template
import Ember from 'ember';
export default Ember.Component.extend({
layout: Ember.HTMLBars.compile("<div class='my-decorative-class'>before-yield{{yield}}after-yield</div>"),
template: function() {
return Ember.HTMLBars.compile("I got wrapped")
}
});