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 / 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 ( 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
(map #(zipmap header %))
View list_of_digits.clj
(defn number-of-digits
"Calculates the number of digits in an integer"
(int (Math/ceil (Math/log10 (inc n)))))
(defn get-nth-digit
"Gets the nth digit (zero based) from integer x"
SneakyPeet / rld.clj
Last active Mar 11, 2019
run length encode decode clojure puzzle from newsletter
View rld.clj
(defn rle
(rle [] coll))
([result coll]
(if (empty? coll)
(let [current (first coll)
n (count (take-while #(= % current) coll))]
(cons [n current] (rle result (drop n coll))))))))
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 / 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
(ns rsa-id-number
[clojure.string :as string]
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.