Skip to content

Instantly share code, notes, and snippets.

💭
Doing the Clojures

Pieter Koornhof SneakyPeet

💭
Doing the Clojures
Block or report user

Report or block SneakyPeet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SneakyPeet
SneakyPeet / parse.clj
Created Apr 3, 2019
Parse fnb and ynab exoport csv
View parse.clj
(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 %))
View list_of_digits.clj
;;; 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"
@SneakyPeet
SneakyPeet / rld.clj
Last active Mar 11, 2019
run length encode decode clojure puzzle from purelyfunctional.tv newsletter
View rld.clj
(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))))))))
@SneakyPeet
SneakyPeet / date-select.cljs
Last active Apr 4, 2019
Clojurescript Date Selector
View date-select.cljs
(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))
@SneakyPeet
SneakyPeet / rsa-id-number.cljc
Last active Aug 8, 2017
South African Id Number Validator
View rsa-id-number.cljc
;; 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]
@SneakyPeet
SneakyPeet / excelSheetsToJsonRows.js
Created May 10, 2017
Get all rows from all sheets in a excel doc as json array
View excelSheetsToJsonRows.js
// 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);
You can’t perform that action at this time.