Skip to content

Instantly share code, notes, and snippets.

@wcmatthysen
wcmatthysen / rotate-libgdx-trig.txt
Last active February 19, 2019 10:51
libgdx: rotate a rectangle shape (manual math calculation).
Rectangle rectangle = (Rectangle)shape;
Vector2 center = new Vector2();
rectangle.getCenter(center);
float centerX = center.x - rectangle.x;
float centerY = center.y - rectangle.y - rectangle.height;
float cos = MathUtils.cosDeg(rotation);
float sin = MathUtils.sinDeg(rotation);
float x = centerX * cos + centerY * sin;
@wcmatthysen
wcmatthysen / rotate-libgdx-matrix-math.txt
Last active February 19, 2019 10:51
libgdx: rotate a rectangle shape (matrix math calculation).
Rectangle rectangle = (Rectangle)shape;
Vector2 center = new Vector2();
rectangle.getCenter(center);
Affine2 transform = new Affine2();
transform.translate(rectangle.x, rectangle.y + rectangle.height);
transform.rotate(-rotation);
transform.translate(-rectangle.x, -rectangle.y - rectangle.height);
transform.applyTo(center);
@wcmatthysen
wcmatthysen / rm-eq-files.sh
Last active October 5, 2016 17:15
Remove all files in directory that are copies of given file.
#!/bin/sh
find "$2" -type f -exec sh -c 'cmp --silent "{}" "$1"; if [ $? -eq 0 ]; then rm "{}"; fi' \;
@wcmatthysen
wcmatthysen / import-osm-data.txt
Last active February 19, 2019 10:49
Import OSM-data into Postgres-database.
# Normal command on a country-file.
osm2pgsql --create --hstore --slim -U postgres -d osm-country -H localhost --style openstreetmap-carto.style country.osm.pbf
# Command for planet-wide import.
osm2pgsql --create --number-processes 6 --flat-nodes /tmp/flat_nodes.bin --cache 8000 --hstore --slim -U postgres -W -d osm-world -H localhost --style openstreetmap-carto.style ~/planet-latest.osm.pbf
@wcmatthysen
wcmatthysen / fix-osm-data.sql
Last active February 19, 2019 10:50
Fix up OSM Data to work with stylesheets.
/* Create missing columns */
alter table planet_osm_line drop column if exists name_en;
alter table planet_osm_line rename column "name:en" to name_en;
update planet_osm_line set name_en = name where name_en is null and name is not null;
alter table planet_osm_point drop column if exists population;
alter table planet_osm_point add column population text;
update planet_osm_point set population = tags->'population' where tags->'population' is not null;
alter table planet_osm_point drop column if exists capital;
@wcmatthysen
wcmatthysen / TreeViewTest.java
Created November 21, 2019 19:04
TreeView Test Application
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.MultipleSelectionModel;
import javafx.scene.control.SelectionMode;
@wcmatthysen
wcmatthysen / TreeTableViewTest.java
Created November 21, 2019 19:41
TreeTableView Test Application
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
/*****************************************
* Read QSee/Zmodo cameras *
* Forward stream to FIFO pipe *
* Author: Daniel Osborne *
* Based on IP Cam Viewer by Robert Chou *
* License: Public Domain *
*****************************************/
/* Version history
* 0.43 - 2015-06-12
@wcmatthysen
wcmatthysen / ComponentUtils.java
Created February 19, 2020 11:08
Set heavyweight tooltip popups for any component in Swing.
public final class ComponentUtils {
private ComponentUtils() { }
public static void forceHeavyWeightPopups(JComponent component) {
try {
Class<?> clazz = Class.forName("javax.swing.ClientPropertyKey");
Field field = clazz.getDeclaredField("PopupFactory_FORCE_HEAVYWEIGHT_POPUP");
field.setAccessible(true);
component.putClientProperty(field.get(null), Boolean.TRUE);
@wcmatthysen
wcmatthysen / pocketchip_first-run.md
Last active September 22, 2020 12:47 — forked from boogah/pocketchip_first-run.md
PocketCHIP: First Run!

My suggested list of terminal commands for your brand new PocketCHIP.

First off, edit your /etc/apt/sources.list file to look like this:

deb http://deb.debian.org/debian/ jessie main contrib non-free
deb-src http://deb.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free