Skip to content

Instantly share code, notes, and snippets.

csv2json () {
ruby -r csv -r json -e 'CSV.new(STDIN, headers: true).each { |r| puts r.to_h.to_json }'
}
@worace
worace / example.scala
Created August 27, 2021 21:45
Cats Effect Cancellation Testing
import cats.effect.Clock
import cats.effect.{IOApp, Resource, IO, ResourceApp, ExitCode}
import scala.concurrent.duration._
object Dummy extends IOApp {
val resource = Resource.make(IO(System.currentTimeMillis)){ start =>
IO.sleep(3.seconds) >> IO.println(s"Exiting -- ${System.currentTimeMillis - start}")
}
def run(args: List[String]) = resource.use { ctx =>
val interruptible = IO.never
@worace
worace / with_stringified_values.sql
Created April 18, 2021 17:14
stringify non-string values in jsonb
-- migrate:up
CREATE OR REPLACE FUNCTION with_stringified_values(input jsonb)
RETURNS jsonb
LANGUAGE plpgsql AS
$func$
DECLARE
_key text;
_value text;
_vals text[] := '{}'::text[];
_output jsonb := '{}'::jsonb;
@worace
worace / apache-spark.rb
Created February 7, 2020 00:13 — forked from eddies/apache-spark.rb
Apache Spark 2.2.0 Homebrew
class ApacheSpark < Formula
desc "Engine for large-scale data processing"
homepage "https://spark.apache.org/"
url "https://archive.apache.org/dist/spark/spark-2.2.0/spark-2.2.0-bin-hadoop2.7.tgz"
version "2.2.0"
sha256 "97fd2cc58e08975d9c4e4ffa8d7f8012c0ac2792bcd9945ce2a561cf937aebcc"
head "https://github.com/apache/spark.git"
bottle :unneeded
@worace
worace / fixed_ish.geojson
Last active January 26, 2020 18:34
PostGIS tutorial red hook neighborhood example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Geoq - (yet another) GIS command line tool

  • Problem - ad-hoc manipulation + inspection of piles of textual GIS data
  • Replacing copy-paste workflows
  • Most work is already in the terminal, so unix tools are a plus
    • integrate with other tools
    • streaming enables processing large datasets
    • fast startup + executable binaries are nice
    • Easy, cross-platform install (rust)
  • README - https://github.com/worace/geoq
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@worace
worace / test.geojson
Last active July 13, 2018 19:53
GeoJSON Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@worace
worace / command_line.md
Created December 22, 2017 21:12
Command Line Tools and Unix I/O

Intro: Command Line Tools

  • Types of programs: Side-effect-y (mkdir, touch) vs Function-y (cat, grep, wc) -- Produce output
  • Basic Unix "contract": Take in text stream and output text stream
  • Somewhat janky but works fairly well

Examples

  • head - show me first lines of a file