This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Don't care about return value | |
| // If it's needed you must do it in your code by callbacks | |
| _.throughput = function(func, delay) { | |
| var lock = false, | |
| queue = []; | |
| function try_next() { | |
| if (queue.length === 0) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git log --shortstat --since "5 months ago" | gawk 'BEGIN { | |
| printf "\n%-10s %-10s %-10s %-10s %-40s %-5%%s\n", "total", "insert", | |
| "deleted", "changed f", "author", ""; | |
| total_changed=0; | |
| total_insert=0; | |
| total_del=0 | |
| } | |
| $1 ~ /^Author:/ { | |
| cur_author=substr($0, index($0,$2)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns find-pin) | |
| (defn ^String to-pin | |
| [^Integer x] | |
| (let [v (str x)] | |
| (.concat (apply str (repeat (- 4 (count v)) 0)) v))) | |
| (defn ^java.lang.Boolean valid-pin? | |
| [^String v] | |
| (and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # put into lib/arel_back.rb | |
| module ArelBack | |
| module ActiveRecord | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| POSTGRESQL_VERSION="9.2.1" | |
| # Installing DB (one-time) | |
| cd $OPENSHIFT_DATA_DIR | |
| wget http://ftp.postgresql.org/pub/source/v${POSTGRESQL_VERSION}/postgresql-${POSTGRESQL_VERSION}.tar.gz | |
| tar xf postgresql-${POSTGRESQL_VERSION}.tar.gz | |
| rm postgresql-${POSTGRESQL_VERSION}.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (import '(java.lang Math)) | |
| (defn palindrome? [n] | |
| (= (->> n str reverse (apply str)) | |
| (str n))) | |
| (defn test-for-products [n pmax pmin] | |
| (some #(let [p (/ n %)] | |
| (and (<= p pmax) (>= p pmin))) | |
| (for [i (range pmin (inc pmax)) :let [m (mod n i)] :when (= m 0)] i))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn factors-sorted-by-product [start end] | |
| (map rest (let [r (reverse (range start end))] | |
| (reverse (sort-by first (for [x r y r :when (>= x y)] | |
| (list (* x y) x y) | |
| ) | |
| )) | |
| ) | |
| )) | |
| (defn get-diff-factors [vals] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ from range(1, 18) with 3 rows and 4 columns it's create like this: | |
| 4 columns | |
| ############# | |
| 1 4 7 10 # | |
| 2 5 8 11 # 3 rows | |
| 3 6 9 12 # | |
| 13 16 | |
| 14 17 | |
| 15 | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_flatten(fl_types=None): | |
| if fl_types is None: | |
| fl_types = (list, tuple) | |
| def flatten(x): | |
| for i in x: | |
| if isinstance(i, fl_types): | |
| for a in flatten(i): | |
| yield a | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ", ".join(["%s: %s" % (k,v) for k,v in filter(lambda k,v: v, some_hash.items())]) |