Skip to content

Instantly share code, notes, and snippets.

View hlship's full-sized avatar

Howard M. Lewis Ship hlship

View GitHub Profile
@hlship
hlship / feed.clj
Last active March 26, 2023 17:25
(def payment-codes-per-block 4096)
(defn create-payment-code-feed
[db]
(let [payment-code-feed (chan 10)]
(go-loop []
(let [block-id (allocate-block db)
block-start (* block-id payment-codes-per-block)]
(-> (onto-chan payment-code-feed
(->>
@hlship
hlship / jira-tag.user.js
Last active April 8, 2021 18:44
Greasemonkey Script to copy issue number / description to clipboard
// ==UserScript==
// @name Copy JIRA Tag
// @description Copies the text of the JIRA issue number and description to the clipboard
// @version 2
// @grant GM.notification
// @grant GM.setClipboard
// @include https://jira.walmart.com/browse/*
// ==/UserScript==
let key = document.getElementById("key-val")
@hlship
hlship / norad.clj
Last active June 7, 2019 18:40
Sample Joker script
#!/usr/bin/env joker
(ns script
(:require [joker.tools.cli :as cli]
[joker.os :as os]
[joker.strconv :refer [atoi]]))
(def opts
[["-d" "--defcon VALUE" "Set DEFCON level"
:parse-fn atoi
@hlship
hlship / response.json
Created April 12, 2019 21:19
Example useless JSON response
{
"status": "FAIL",
"payload": {
"errors": [
{
"field": "header",
"category": "APPLICATION",
"description": "Error description not available",
"severity": "ERROR",
"code": "org.apache.commons.json.JSONException",
(ns extract-docs
(:require
[medley.core :refer [filter-vals]]
[clojure.java.io :as io]
[clojure.string :as str]
[clojure.edn :as edn])
(:import
(java.io PrintWriter Writer File)))
(defn full-name [k]
(map #(assoc % :full-name (str (:first-name %) " " (:last-name %))) (sort-by :last-name) (filter #(= "97204" (:zip person)) (get-contacts db))
@hlship
hlship / loop.clj
Created May 6, 2016 18:43
looping state
(go-loop [n 0]
(when-let [x (<! input-ch)]
(>! output-ch x)
(recur (inc n))
n))
@hlship
hlship / task.clj
Last active October 28, 2016 22:58
(deftask base-image
"Builds the base image for other images."
[]
(comp (init :dir (io/file "base") :from "anapsix/alpine-java:8")
(add :file ["launch.sh"])
(artifact :dependency '[[org.bouncycastle/bcprov-jdk15on "1.54"]] :target "/opt/jdk/jre/lib/ext/")
(artifact :dependency '[[com.walmartlabs/timestamper "0.1.2"]] :target "/usr/local/java-agents/")
(inst :section :postamble :inst :run :arguments ["chmod a+x launch.sh"])
(build-image :image-name "base" :version default-base-version)))
(deftask init
"First step when building a Docker image. Optionally specifies a directory
of resources that can be added to the image."
[d dir DIR file "Directory to add."
f from IMAGE str "Base image name."]
(assert from "--from is required")
(assert (or (nil? dir)
(is-readable-directory? dir))
"--dir must specify an existing directory")
(with-pre-wrap fs
> boot pom --project example --version 0.1 -- jar -- install
Writing pom.xml and pom.properties...
Writing example-0.1.jar...
Installing example-0.1.jar...