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 / 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 / youtube2mp3.py
Last active May 3, 2022 05:39
Youtube to MP3 Downloader Script
#!/bin/env python
# Requires: youtube_dl module
# Requires: ffmpeg
# Usage:
#
# python youtube2mp3.py <URL>, ...
#
# Example:
#
# python youtube2mp3.py https://www.youtube.com/watch?v=dQw4w9WgXcQ
;; In response to blog post:
;; https://medium.com/@kasperpeulen/10-features-from-various-modern-languages-that-i-would-like-to-see-in-any-programming-language-f2a4a8ee6727
;; Run with lumo
;; https://github.com/anmonteiro/lumo
;;
;; # npm install -g lumo-cljs
;; lumo clojurescript-feature-examples.cljs
@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 / 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 / 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]:
@benzap
benzap / event.clj
Created September 5, 2015 13:05
Simple keyboard event tracking code in use for 2d games
(ns event
"Macros for event.cljs")
(defmacro on-keydown [key & body]
`(set-on-keydown ~key (fn [] ~@body)))
(defmacro on-keyup [key & body]
`(set-on-keyup ~key (fn [] ~@body)))
@benzap
benzap / array2.cljs
Created September 5, 2015 12:55
Simpler 2d Array manipulation in clojurescript for 2d games
(ns array2
"Simple and helpful functions for manipulating 2d arrays. This is a set
of functions for manipulating a mutable js/Array instance, and
treats it like a 2d array. This is useful for the domain of 2d games.
Examples:
(def array1 (aa 1 2))
(def array2 (aa 3 4))
@benzap
benzap / git-rebase-with-master
Created June 19, 2015 14:25
Useful shell commands for dealing with git
#!/bin/bash
#allows you to perform a rebase on your current branch with the master
#branch
#turn off the proxy
#. unsetproxy
CURRENT_BRANCH="`git rev-parse --abbrev-ref HEAD`"