Skip to content

Instantly share code, notes, and snippets.


bartuka wandersoncferreira

View GitHub Profile
wandersoncferreira / complex_business_process_example.clj
Last active Aug 9, 2021
Example of a complex business process to implement in Clojure. Alternative implementation using State Machine. Link to didibus original
View complex_business_process_example.clj
(ns didibus-example.core
"A stupid example of a more complex business process to implement as a flowchart."
(:require [tilakone.core :as tk :refer [_]]))
;;;; Config
(def config
"When set to :test will trigger the not-boosted branch which won't write to db.
When set to :prod will trigger the boosted branch which will try to write to the db."
wandersoncferreira /
Created Jun 14, 2021
pgFormatter installer for Fedora 34
#!/usr/bin/env bash
# 1. Download pgFormatter Release
# 2. Unzip
# 3. Install Perl Dependencies
sudo dnf install perl-ExtUtils-MakeMaker perl-autodie perl-open perl-FindBin
wandersoncferreira / pomegranate-and-clj-refactor.el
Last active Mar 20, 2021
Integration of Pomegranate with clj-refactor to bring back hot-reload of new dependencies
View pomegranate-and-clj-refactor.el
;; Experimental configuration to hotload refactor
;; using Pomegranate from Cemerick
;; From
;; and integrated into clj-refactor.
(defun bk/send-to-repl (sexp eval ns)
(cider-switch-to-repl-buffer ns)
(goto-char cider-repl-input-start-mark)
(delete-region (point) (point-max))
View fold-clojure-setup.el
;;; fold-clojure-setup --- provide dwim folding for Clojure buffers
;;; Commentary:
;; Based on this great work from Alpaphapha
;;; Code:
(defcustom bk/clj-outline-regexp "\\(;;;?\\{1,8\\} \\|\\((\\w+\\)\\)"
wandersoncferreira / setup-git.el
Last active Dec 19, 2020
Open magit-diff-buffer using other-window
View setup-git.el
(defun bk/magit-display-diff-other-window (buffer)
"Display BUFFER in same-window but for magit-diff use other-window instead."
buffer (if (with-current-buffer buffer (derived-mode-p 'magit-diff-mode))
(setq magit-display-buffer-function
wandersoncferreira / setup-minibuffer.el
Last active Dec 8, 2020
Select candidates from minubuffer using M-{number} (up to 10 candidates)
View setup-minibuffer.el
(use-package general
:ensure t)
(defun selectrum-define-keys ()
(dotimes (i (min selectrum-num-candidates-displayed 10))
:keymaps 'selectrum-minibuffer-map
(format "M-%d" (mod (1+ i) 10))
`(lambda ()
View demangle.clj
(defmacro demangle [sym]
(let [prefix# (str (gensym))
name# (symbol (str prefix# sym))
fn# `(defn ~name# [] (str (quote ~sym)))]
`(-> ~fn#
(clojure.string/split (re-pattern ~prefix#))

Data Readers

I've read about the subject, but I want to look closer. The following analysis will be ECA (Exploratory Clojure Analysis) on data readers and I hope more people can benefit from it.

What are data readers?

Functions used to read specific tagged literals. For example, #inst "2020-10-05" is a built-in literal in Clojure and if you


Clojure assertion

Discussing with a colleague about some issues with dynamic programming languages and I quickly run into the rationale that programming with assertions is a common practice around this world. The idea would be to protect your function from a bad input or output state.

I am not entirely sure on that, and by far I can't speak for the industry, and I found fews posts about the subject such as Life with dynamic typing from David Nolen, but nothing too concrete. Anyway, I want to dig

View test-check.contracts.clj
(ns secland.gen-contract
(:require [cadastro-de-pessoa.cnpj :as cnpj]
[clojure.test.check.generators :as gen]
[java-time :as java-time])
(:import java.time.ZoneId))
(defn date-converter [date]
(.atStartOfDay date (ZoneId/systemDefault)))))