Skip to content

Instantly share code, notes, and snippets.

View tkachenko1503's full-sized avatar

Sergey Tkachenko tkachenko1503

View GitHub Profile
(function() {
Backbone.Events.autorun = function(f, context) {
if (!this.__autorunHandles) this.__autorunHandles = [];
var backboneContext = this;
var handle = Tracker.autorun(function() {
Tracker.currentComputation.__backboneContext = backboneContext;
f();
});
this.__autorunHandles.push(handle);
return handle;
@city41
city41 / gist:aab464ae6c112acecfe1
Last active January 19, 2021 12:51
ClojureScript secretary client side navigation without hashes

This is the example that comes with the reagent template converted to use HTML5 based history. This means there are no # in the urls.

I just got this working, so there might be better approaches

The changes are

  • use goog.history.Html5history instead of goog.History
  • listen to clicks on the page, extract the path from them, and push them onto the history
  • listen to history changes, and have secretary do its thing in response
@vvvvalvalval
vvvvalvalval / gist:c6c2d991bdc96cce4c14
Last active February 11, 2024 19:34
Asynchronous map function with clojure.core.async
(require '[clojure.core.async :as a])
(defn- seq-of-chan "Creates a lazy seq from a core.async channel." [c]
(lazy-seq
(let [fst (a/<!! c)]
(if (nil? fst) nil (cons fst (seq-of-chan c)) ))))
(defn map-pipeline-async "Map for asynchronous functions, backed by clojure.core.async/pipeline-async .
From an asynchronous function af, and a seq coll, creates a lazy seq that is the result of applying the asynchronous function af to each element of coll.
@kordano
kordano / url-param.cljs
Last active September 12, 2022 12:14
URL parameter parsing with clojurescript
(defn parse-params
"Parse URL parameters into a hashmap"
[]
(let [param-strs (-> (.-location js/window) (split #"\?") last (split #"\&"))]
(into {} (for [[k v] (map #(split % #"=") param-strs)]
[(keyword k) v]))))
@akiatoji
akiatoji / Clojure_on_RaspberryPi_OSX.md
Last active December 3, 2022 21:15
Running Clojure on Raspberry Pi with OS X

Clojure on Raspberry Pi with OS X

"Clojure running on Raspberry Pi" sounded so cool that I just had to give it a try.

Install JDK

  • Download ARM JDK from Oracle and instlal on Raspberry Pi
  • Change visudo to contain the following
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@staltz
staltz / introrx.md
Last active May 18, 2024 05:17
The introduction to Reactive Programming you've been missing
@arnaudsj
arnaudsj / Clojure.sublime-settings
Last active January 18, 2021 19:00 — forked from jamesmacaulay/Clojure.sublime-settings
Sublime Text 3: Clojure
// installed Clojure packages:
//
// * BracketHighlighter
// * lispindent
// * SublimeREPL
// * sublime-paredit
{
"word_separators": "/\\()\"',;!@$%^&|+=[]{}`~?",
"paredit_enabled": true,
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@julionc
julionc / 00.howto_install_phantomjs.md
Last active April 26, 2024 09:13
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev