Skip to content

Instantly share code, notes, and snippets.

View johanmynhardt's full-sized avatar
♻️
Upgrade to MySQL 8 would be fun they said...

Johan Mynhardt johanmynhardt

♻️
Upgrade to MySQL 8 would be fun they said...
View GitHub Profile
@johanmynhardt
johanmynhardt / user.clj
Created April 9, 2022 22:34
Simple Zipper-based Syndication XML Extractor to navigate the "What's New?" AWS Feed.
(ns user
"Simple Syndication XML Extractor to navigate the available AWS Feed."
(:require [clojure.data.xml :as xml]
[clojure.java.io :as io]
[clojure.pprint :refer [pprint]]
[clojure.string :as str]
[clojure.zip :as z]))
(def aws-feed-url "https://aws.amazon.com/about-aws/whats-new/recent/feed/")
@johanmynhardt
johanmynhardt / new_clj.clj
Last active March 30, 2022 20:16
Create a new bb.edn or deps.edn skeleton project.
#!/usr/bin/env bb
(ns new-clj
"Utility to create new deps or bb projects."
(:require [clojure.tools.cli :as cli]
[clojure.pprint :refer [pprint]]
[clojure.java.io :as io]
[clojure.string :as str]))
(def cli-opts-spec
[["-t" "--target TARGET"
@johanmynhardt
johanmynhardt / html5fetch_api.cljs
Created August 4, 2019 13:43
ClojureScript HTML5 FetchAPI usage
;; This works easiest using the thread-first macro ( -> )
;; I couldn't get it to work with fetch().then().then()[...].catch() for error handling.
(fn []
(->
(js/fetch "/weather-data.json")
(.then
(fn [resp]
(println "status: " (.-status resp))
(when (= 200 (.-status resp))
(->
const renderTSV = input => input
.split('\n')
.map(r => r.replace(/\t/g, ' __ '))
.join('\n');
const parseIDs = input => input
.split(/(\d{4,})/)
.map(x => x.trim())
.filter(x => new RegExp(/\d+/).exec(x))
.map(Number)
@johanmynhardt
johanmynhardt / addDays.js
Created December 5, 2017 18:54
Add number of days to given date.
/**
* Add the specified number of days to the date provided.
*/
var addDays = (date, days) => {
var newDate = new Date(date);
newDate.setDate(newDate.getDate() + days);
return newDate;
}
// example:

Keybase proof

I hereby claim:

  • I am johanmynhardt on github.
  • I am johanmynhardt (https://keybase.io/johanmynhardt) on keybase.
  • I have a public key whose fingerprint is 0B69 29B9 7384 016E 327F 0AEF 097E 2F0B A14A 6C4E

To claim this, I am signing this object:

@johanmynhardt
johanmynhardt / dd2dms.js
Created January 10, 2017 09:54
Decimal to DMS converter
const dd2dms = (latOrLong) => {
latOrLong = (typeof latOrLong === 'number') ? ''+latOrLong : latOrLong; //convert to string
const nan2S = (input) => (isNaN(input) || 'NaN' === input) ? '0' : `${input}`;
const result = {
sign: '',
deg: '0',
min: '0',
sec: '0'