Skip to content

Instantly share code, notes, and snippets.

View chapmanjacobd's full-sized avatar
🥅
goal_net

Jacob Chapman chapmanjacobd

🥅
goal_net
View GitHub Profile
@chapmanjacobd
chapmanjacobd / geo_update_trigger.sql
Created February 2, 2019 07:38 — forked from mmohiudd/geo_update_trigger.sql
Update geometry and geography data with a trigger for PostgreSQL(PostGIS)
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table(
id bigserial NOT NULL,
latitude double precision,
longitude double precision,
geom geometry,
geog geography,
updated_ts double precision,
CONSTRAINT test_table_unique_key UNIQUE (id)
);
@chapmanjacobd
chapmanjacobd / extract coordinates from geojson
Created March 16, 2019 01:46
removes properties from geojson. import into database SQL
UPDATE wof
SET body = substring(body, '(?<=geometry": ).*$');
@chapmanjacobd
chapmanjacobd / make_areas_distinct.R
Last active May 28, 2019 06:35
slow way to tease out distinct areas from overlapping areas
### =delete overlapping buffers= ###
options("scipen"=100)
require(varhandle)
require(data.table)
require(tidyr)
require(tidyverse)
require(dplyr)
require(DBI)
@chapmanjacobd
chapmanjacobd / make_areas_distinct_fast.R
Last active October 10, 2022 03:10
remove XY points to find which points provide the most coverage without moving cluster location (2D LIDAR)
require(raster)
require(sf)
require(dplyr)
require(data.table)
shiftReduceRaster = function (x, y) {
r <- raster::shift(r, x*xres(r), y*yres(r))
# get cell numbers
cells <- cellFromXY(r, pts)
# pick one point per cell
@chapmanjacobd
chapmanjacobd / ctf_insects.sh
Last active July 14, 2019 12:43
run file after start
#!/bin/bash
# create new user
adduser -m --disabled-password --gecos "" bluehat
usermod -aG sudo bluehat
#usermod -aG wheel bluehat
echo "bluehat ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
su bluehat
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
#generate your RSA keys: ssh-keygen -t rsa -b 4096 -f cinsects
@chapmanjacobd
chapmanjacobd / fish_greeting
Created August 13, 2019 00:27
a custom cowsay
function fish_greeting
cat /proc/loadavg | cut -d' ' -f 2
shuf -n 4 ~/mdrive/notes/(ls -p ~/mdrive/notes/ |grep -v / | shuf -n 1) | cowsay -W 52 -f tux
end
@chapmanjacobd
chapmanjacobd / functions.fish
Last active August 8, 2020 10:35
fish functions
function sponge
/usr/bin/mkdir -p (dirname "$argv")
/usr/bin/sponge "$argv"
end
function tee
/usr/bin/mkdir -p (dirname "$argv")
/usr/bin/tee "$argv"
end
@chapmanjacobd
chapmanjacobd / html.elm
Created November 16, 2019 13:21
html docs elm examples HTML to Html
import Html
import Html.Attributes as Attributes
--Tags
Html.a [ Attributes.href "http://www-db.stanford.edu/~evtimov/midas/demos.html", Attributes.target "_blank" ] [ text "Open in a new window!" ]
<a href="http://www-db.stanford.edu/~evtimov/midas/demos.html" target="_blank">Hello World!</a>
largestDivisible : Maybe Int
largestDivisible divideBy maxInt =
let
p x = x % divideBy == 0
in
List.head (List.filter p List.reverse (List.range 0 maxInt))
// function
(() => 0)()
((room, board) => room + board)(800, 150)
// function/block
(() => {})()
((room, board) => {return room + board})(800, 150)