Skip to content

Instantly share code, notes, and snippets.

@pborissow
pborissow / JTS.md
Last active July 23, 2020 14:02
How to create PostGIS HEXEWKB formatted geometry

How to create PostGIS HEXEWKB formatted geometry

When copying geometry data into PostgreSQL using COPY FROM STDIN it is a good idea to use the PostGIS HEXEWKB format. Here's how to create HEXEWKB using Java and JTS:

import com.vividsolutions.jts.geom.*;
import com.vividsolutions.jts.io.WKBWriter;
import com.vividsolutions.jts.io.WKTReader;
import com.vividsolutions.jts.io.ByteOrderValues;
@pborissow
pborissow / line2Polygon.md
Last active July 23, 2020 14:06 — forked from kekscom/Thick Line to Polygon JS
A JavaScript method to turn thick lines into polygons

Line2Polygon

Creates a polygon around a linestring. Provides an option to vary the thickness. Usage:

    var path = [ [0, 0], [25, 25], [13, 13] ];
    var width = 5; //or an array for each line segment [ 5, 10, 15 ]
    var poly = line2Polygon(path, width);

Credit: https://gist.github.com/kekscom/4194148

@pborissow
pborissow / OpenLayers.md
Last active July 23, 2020 14:07
OpenLayers Stuff

OpenLayers Notes

  //**************************************************************************
  //** getTiles
  //**************************************************************************
  /** Demostrates how to iterate through all the tiles in a layer
   */
    var getTiles = function(layer){
        var renderer = layer.getRenderer();
@pborissow
pborissow / D3.md
Last active January 21, 2022 20:02
D3 Stuff
@pborissow
pborissow / JSClass.md
Last active March 16, 2021 21:05
Old School JavaScript

Introduction

Old school way of creating classes in JavaScript

Example

if(!my) var my={};
if(!my.namespace) my.namespace={};

//******************************************************************************
@pborissow
pborissow / JConsole.md
Created September 17, 2021 07:34
JConsole Notes

JConsole is a free program that is part of the JDK distribution that you can use to debug performance issues. It is especailly useful with the topthreads plugin.

To launch JConsole with topthreads:

"C:\Program Files\Java\jdk-11.0.12\bin\jconsole.exe" -pluginpath C:\temp\topthreads-1.1.jar

https://bitbucket.org/pjtr/topthreads/downloads/

VI Basics

Everything I ever needed from vi/vim are here

Editing a file

vi /path/to/file.txt

Once inside, use shift+i to insert or edit text Press esc to exit :q :q! :w :wq are common options after esc

@pborissow
pborissow / Nashorn.md
Last active May 20, 2023 14:06
Nashorn Notes

Nashorn used to be bundled with Java between versions 8 to 14. It no longer ships starting with Java 15 and needs to be downloaded as a seperate JAR via OpenJDK.

https://github.com/openjdk/nashorn

Migrating to the OpenJDK version of Nashorn is pretty straightforward.

Old Way

//Scripting includes
@pborissow
pborissow / Netbeans.md
Last active April 13, 2024 12:54
Netbeans

Netbeans Config

I've been using Netbeans for longer than I care to admit. I use it almost everyday for Java and JavaScript development. Here are some small tweaks I use to make Netbeans a little easier to use.

Set Main Project

When I first started using Netbeans, there was an option to select a project as a "Main Project". Visually, the main project is highlighted in bold in the Projects tree. When you have a main project selected, the build buttons in the main toolbar will apply to the selected project.

Newer versions of Netbeans don't have a "Set as Main Project" menu option when you right click on a project in the Projects tree.

To re-enable this feature, simply go to Run -> Set Main Project -> Select a project

Months Between

Prototype code used to compute fractional month difference between two dates.

Tests

    String[][] tests = {
        {"2024-04-14", "2024-04-04"}, //<1 month (10 days or 0.333)
        {"2024-04-04", "2024-04-14"}, //<1 month (10 days or 0.333)