(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| For each Ruby module/class, we have Ruby methods on the left and the equivalent | |
| Clojure functions and/or relevant notes are on the right. | |
| For clojure functions, symbols indicate existing method definitions, in the | |
| clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
| be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
| ruby-to-clojure.*/* functions can be obtained from the source files in this | |
| gist. | |
| If no method symbol is given, we use the following notation: |
| (defn flatten-sets | |
| "Like flatten, but pulls elements out of sets instead of sequences." | |
| [v] | |
| (filter (complement set?) | |
| (rest (tree-seq set? seq (set v))))) |
| # Copyright Mathieu Blondel December 2011 | |
| # License: BSD 3 clause | |
| import numpy as np | |
| import pylab as pl | |
| from sklearn.base import BaseEstimator | |
| from sklearn.utils import check_random_state | |
| from sklearn.cluster import MiniBatchKMeans | |
| from sklearn.cluster import KMeans as KMeansGood |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| # Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key | |
| # that enables you to choose a character from a menu of options. If you are on Lion | |
| # try it by pressing and holding down 'e' in any app that uses the default NSTextField | |
| # for input. | |
| # | |
| # It's a nice feature and continues the blending of Mac OS X and iOS features. However, | |
| # it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode, | |
| # as it means you cannot press and hold h/j/k/l to move through your file. You have | |
| # to repeatedly press the keys to navigate. |
| var list = $$("#item-page-wrapper .list-items table tbody .lineItemMainInfo .lineItemPart strong"); | |
| var total=0; | |
| for(i=0; i<list.length;i++){ | |
| total += parseFloat(list[i].innerText.replace("$","")); | |
| } | |
| alert(list.length+" items for a total of: $"+total.toFixed(2)); |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| # gap.py | |
| # (c) 2013 Mikael Vejdemo-Johansson | |
| # BSD License | |
| # | |
| # SciPy function to compute the gap statistic for evaluating k-means clustering. | |
| # Gap statistic defined in | |
| # Tibshirani, Walther, Hastie: | |
| # Estimating the number of clusters in a data set via the gap statistic | |
| # J. R. Statist. Soc. B (2001) 63, Part 2, pp 411-423 |
| var obj = { | |
| id: 1, | |
| whoami: function() { | |
| return this.id; | |
| } | |
| }; | |
| function callExternally(callback) { | |
| this.id = 99; | |
| return callback(); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.