This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn parse-fnb [path] | |
(let [fnb-csv-rows | |
(as-> (slurp (clojure.java.io/file path)) x | |
(clojure.string/split x #"\n") | |
(drop 6 x) | |
(map #(clojure.string/split % #", ") x)) | |
header (->> fnb-csv-rows first (map keyword)) | |
rows (->> fnb-csv-rows | |
rest | |
(map #(zipmap header %)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; https://purelyfunctional.tv/issues/purelyfunctional-tv-newsletter-319-tip-shebang-scripting-with-the-clojure-cli/?__s=qn1vfepzj2qsgce6ughs | |
(defn number-of-digits | |
"Calculates the number of digits in an integer" | |
[n] | |
(int (Math/ceil (Math/log10 (inc n))))) | |
(defn get-nth-digit | |
"Gets the nth digit (zero based) from integer x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn rle | |
([coll] | |
(rle [] coll)) | |
([result coll] | |
(if (empty? coll) | |
coll | |
(lazy-seq | |
(let [current (first coll) | |
n (count (take-while #(= % current) coll))] | |
(cons [n current] (rle result (drop n coll)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns date-select.core | |
(:require [rum.core :as rum] | |
[cljs-time.core :as time])) | |
(defn initial-date | |
([] (let [selected (time/now)] | |
{:year (time/year selected) | |
:month (time/month selected) | |
:day (time/day selected)})) | |
([year] (initial-date year 1 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Validates an RSA Identity Number | |
;; compatible With Clojure and Clojurescript | |
;; Requires clj-time for clojure and cljs-time for clojurescript | |
;; Based on the validator by Evan Knowles | |
;; http://knowles.co.za/generating-south-african-id-numbers/ | |
(ns rsa-id-number | |
(:require | |
[clojure.string :as string] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get all rows from all sheets in a excel doc as json array | |
// Assumes sheets have header rows | |
const XLSX = require('xlsx'); | |
const jsonfile = require('jsonfile'); | |
const R = require('ramda'); | |
const getWorkbook = () => XLSX.readFile('./data/test.xlsx'); | |
const pickSheetsByName = (workbook) => R.pick(workbook.SheetNames, workbook.Sheets); |