Skip to content

Instantly share code, notes, and snippets.

Martin Klepsch martinklepsch

Block or report user

Report or block martinklepsch

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
@levelsio
levelsio / btc-eth-dca-buy.php
Last active Aug 6, 2019
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
View btc-eth-dca-buy.php
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
View build.boot
(require '[clojure.java.io :as io])
(deftask demo []
(let [tmp (tmp-dir!) ; Anonymous, boot-managed temp directory.
prev-fs (atom nil)] ; Atom where the previous fileset is stored.
(with-pre-wrap [fs]
(let [diff (fileset-diff @prev-fs (reset! prev-fs fs)) ; Fileset containing only changed files.
inputs (->> (input-files diff) ; Sequence of [String, java.io.File]
(by-ext [".c"]) ; pairs, the classpath path and File
(map (juxt tmp-path tmp-file)))] ; for files with given extensions.
@swannodette
swannodette / inference.md
Last active Nov 28, 2019
Externs Inference
View inference.md

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen

@attentive
attentive / leaflet.cljs
Last active Sep 16, 2017
Adapting React components in Rum
View leaflet.cljs
(ns project.leaflet
(:require-macros [project.macros :as m])
(:require [rum.core :as rum]
cljsjs.react-leaflet)) ;; js/ReactLeaflet
(m/adapt-react leaflet-map js/ReactLeaflet.Map)
(m/adapt-react tile-layer js/ReactLeaflet.TileLayer)
(m/adapt-react marker js/ReactLeaflet.Marker)
(m/adapt-react popup js/ReactLeaflet.Popup)
@ohpauleez
ohpauleez / interceptor.clj
Last active Jun 19, 2018
An example of how to make conditional interceptors that enqueue new interceptors
View interceptor.clj
;; Let's start with a simple conditional interceptor that works with functions...
(defn conditional-context
"Given a keyword name and any variable predicate and terminator function pairs,
return an interceptor that will apply the terminator function paired to the first
truthy predicate. Predicates and terminators are both given the context as
the only argument.
If all predicates fail, the original context is returned."
[name-kw & pred-terms]
@mhuebert
mhuebert / cljs-js-analysis-cache-usage.md
Last active Jan 19, 2018
Using existing namespaces from cljs.js
View cljs-js-analysis-cache-usage.md

Let's say you want to use cljs.js to eval code using functions declared in your project.

Expressions that only use core functions are simple to evaluate:

(ns foo.try-eval
  (:require [cljs.js :as cljs]))

(def compiler-state (cljs/empty-state))
@noprompt
noprompt / complies.clj
Created Mar 16, 2015
complies? macro for ClojureScript. Verifies than an object not only satisfies a protocol but implements all of it.
View complies.clj
(ns example.macros
(:require
[cljs.analyzer :as a]
[cljs.compiler :as c]))
(defmacro complies?
"True if x satisfies and implements all methods of a protocol.
Ex.
@mrb
mrb / abstint.md
Last active Sep 13, 2019
"Programs that eat programs" Works cited/bibliography
View abstint.md
@jpthomson
jpthomson / gist:d7c36805ebe24d07428f
Created Feb 3, 2015
Run CLJX code after (cljx)
View gist:d7c36805ebe24d07428f
(deftask start []
(let [f (delay (do
(require 'fy.core) ;; cljx file
((resolve 'fy.core/start-system!))))]
(with-post-wrap fileset @f fileset)))
@Deraen
Deraen / angular-filesize.js
Last active Jul 5, 2017 — forked from thomseddon/gist:3511330
Humanize filesize
View angular-filesize.js
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
var number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
};
});
You can’t perform that action at this time.