-
Expressive They say something about the purpose and result of the iteration.
-
Contained They don't have side effects if used properly. All relevant stuff occurs within the callback.
-
Scoped They provide automatic function scope for each iteration which eliminates a common type of error.
/* Hacker News Search Script | |
* | |
* Original Script by Kristopolous: | |
* https://gist.github.com/kristopolous/19260ae54967c2219da8 | |
* | |
* Usage: | |
* First, copy the script into your browser's console whilst on the Hacker News | |
* jobs page. Then, you can use the query function to filter the results. | |
* | |
* For example, |
(require '[clojure.core.async :as async] | |
'[clj-http.client :as client] | |
'[clojure.data.json :as json]) | |
(def concurrency 5) | |
(let [in (async/chan) | |
out (async/chan) | |
request-handler (fn [url out*] | |
(async/go |
(ns favila.async-util | |
"Some missing pieces of core.async. | |
as-transducer: Make a transducer function easily without Clojure 1.7. | |
go-pipe: async/pipe, but returns the go-loop. | |
fast-pipeline-blocking: faster than async/pipeline-blocking, but unordered results. | |
blocking-consumer: consume a channel with multiple worker threads." | |
(:require [clojure.core.async :as async | |
:refer [go go-loop <! >! <!! >!! close! take! put! chan]])) |
class Regex { | |
let pattern: String | |
let options: NSRegularExpressionOptions! | |
private var matcher: NSRegularExpression { | |
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil) | |
} | |
required init(pattern: String, options: NSRegularExpressionOptions = nil) { | |
self.pattern = pattern |
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.
var Fluxxor = require('fluxxor'); | |
var request = require('superagent'); | |
var AuthStore = Fluxxor.createStore({ | |
actions: { | |
"LOGIN_AUTH": "onLoginAuth", | |
}, | |
initialize: function() { | |
this.currentUser = {}; |
I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.
I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.
This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.
As configured in my dotfiles.
start new:
tmux
start new with session name:
cd ~ | |
sudo yum update | |
sudo yum install java-1.7.0-openjdk.i686 -y | |
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |