As I want to kickstart javascript development very fast, I have found those roadmaps. They are freshly updated with latest stuff. I will complete my learning with SPA course from [http://singlepageappbook.com/][spa-url]:
Notes are actually on:
- callbacks
- objects
- prototype
- namespaces
var thing = require('./thing.js'); | |
/***************************************************** | |
* CLASS DEFINITION | |
****************************************************/ | |
function someManager() { | |
this.thing = thing; | |
this.otherThing = {}; | |
}; |
;; Fix for the compiling problem on IntelliJ with La-Clojure: | |
;; Settings -> Compiler -> Clojure Compiler -> Copy Clojure source files to output... | |
(filter odd? [1 2 3 4 5 6]) ;; => 1 3 5 | |
(first(filter odd? [1 2 3 4 5 6])) ;; => 1 | |
(first '(1 2 3)) ;; => 1 | |
(first [1 2 3]) ;; => 1 | |
;(first (1 2 3)) ;; => error ! because (1 2 3) is not interpreted as a list here |
Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.
To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.
- elasticsearch
We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.
;; SCENARIO: Be able to detect high heap pressure on service. | |
;; -> If during the last x minutes, "heap.usage" values are > 0.70, then alert... | |
;; Riemann API http://riemann.io/api.html | |
(defn slack-this-shit [message] | |
(slack slack-alert-channel {:username "Not so friendly Riemann bot", | |
:formatter (fn [ev] {:text (str "*"(:service ev)"*" " is in *" (:state ev) "* state on hosts: *" (:host ev) "*. " message), | |
:icon ":x:"})})) | |
(def tracking-jvm-pressure-stream |
(defn compute-percentile | |
; This function compute a percentile over a sequence of numbers. | |
[percentile coll] | |
{:pre [(number? percentile) (> percentile 0) (< percentile 1) (not (empty? coll))]} | |
(let [sorted (sort coll) | |
length (count coll) | |
index (* percentile length)] | |
(if (== (int index) index) | |
(let [first (nth sorted (- index 1)) | |
second (nth sorted index)] |
/** | |
* https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#how-to-manage-a-local-order-book-correctly | |
* @param asset | |
* @param getSnaptshot | |
*/ | |
class OrderBookFlow( | |
asset: Asset, | |
getSnaptshot: Asset => Future[OrderBook] | |
) extends GraphStage[FlowShape[OrderBookUpdateEvent, OrderBook]] { |