Skip to content

Instantly share code, notes, and snippets.

View benzap's full-sized avatar
🏠
Working from home

Benjamin Zaporzan benzap

🏠
Working from home
View GitHub Profile
@benzap
benzap / edn_linter.cljc
Created August 4, 2018 01:29
EDN Linter Example Use Case
(ns edn-linter
;; require name of edn linter
(:require [the-name :refer [parse-with-info]]
(def input-string "[:a :b
{:test 123}]")
(def parsed-edn (parse-with-info input-string))
;; {:line 0
;; :type :vector
@benzap
benzap / higher-order-fizzbuzz.fif
Created May 28, 2018 07:22
Higher Order fizzbuzz from reddit post
;; From reddit comments
;; https://www.reddit.com/r/Clojure/comments/8lizcb/rclojure_fizz_buzz_contest_hardmode/
$clear-stack
doc higher-fizzbuzz
"( map seq -- seq ) Returns modified seq with map target factors."
fn higher-fizzbuzz
*xs <> setl
*m <> setl
@benzap
benzap / fizzbuzz.fif
Last active May 28, 2018 07:20
Fizzbuzz in fif langauge github.com/benzap/fif
fn fizz-buzz
*n <> setl
n 3 mod zero?
n 5 mod zero? and if "FizzBuzz" else
n 3 mod zero? if "Fizz" else
n 5 mod zero? if "Buzz" else
n
then then then
endfn
@benzap
benzap / fif-repl.cljs
Last active May 28, 2018 04:49
Fif Interactive Repl Used in blog posts
(ns website.fif-repl
(:require
[clojure.string :as str]
[rum.core :as rum]
[fif.core :as fif]
[fif.stack-machine :as stack]
[fif.stack-machine.error-handling :refer [set-error system-error]]
;; Nothing to see here
[website.repl-imports :refer [import-super-secret-words]]))
@benzap
benzap / middleware.clj
Created April 2, 2018 10:57
Middleware Implementation using less side-effects and mutable values
(ns middleware)
(def default-response
{:status :init
:done false
:value nil})
(def default-request
@benzap
benzap / jsonp-example.cljs
Last active January 24, 2018 11:23
Working JSONP example using goog.net Jsonp returning async channels
(ns redditv.jsonp
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [put! chan <! close!]])
(:import [goog.net Jsonp]
[goog Uri]))
(defn send-jsonp [url]
(let [success-channel (chan)
error-channel (chan)
success-handler (fn [result] (if-not (nil? result)
@benzap
benzap / org-style.css
Created October 13, 2016 00:23
org-mode stylesheet
@import 'https://fonts.googleapis.com/css?family=Droid+Serif|Inconsolata';
* {
font-family: 'Droid Serif', serif;
}
#content {
margin: 20px auto;
padding: 20px;
max-width: 800px;
@benzap
benzap / appearance.el
Created May 14, 2016 07:04
emacs appearance
(if (not (window-system))
(progn
(package-require 'color-theme)
(color-theme-initialize)
(color-theme-tty-dark))
(progn
(package-require 'waher-theme)
(load-theme 'waher t t)))
@benzap
benzap / swiss.py
Created January 6, 2016 21:01
Clojure Threading in Python
from types import (
ListType,
TupleType,
FunctionType,
LambdaType
)
def thread_first(expr, *exprs):
for expression in exprs:
if type(expression) in [ListType, TupleType]:
(require 'iimage)
(autoload 'iimage-mode "iimage" "Support Inline image minor mode." t)
(autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
(add-to-list 'iimage-mode-image-regex-alist '("@startuml\s+\\(.+\\)" . 1))
;; Rendering plantuml
(defun plantuml-render-buffer ()
(interactive)
(message "PLANTUML Start rendering")
(shell-command (concat "java -jar ~/Downloads/plantuml.jar "