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 sseq ["many" "functional" "languages" "are" "tied" "to" "mathematical" "calculation" "tools"]) | |
| (def iseq [1 7 2 5 20 13 2 1] ) | |
| (defn drop-nth [n l] | |
| (concat (subvec l 0 n) (subvec l (+ n 1) (count l)))) | |
| (defn qsort [l] | |
| (if (<= (count l) 1) l | |
| (let [ pivot-pos (quot (count l) 2) | |
| pivot (nth l pivot-pos) |
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
| var _ = require("underscore"), | |
| async = require("async"); | |
| var l = _.range(20), | |
| batch_size = 5, | |
| batches = _.map(_.range(l.length / batch_size), function(i){ | |
| return l.slice(i*batch_size, i*batch_size + batch_size); | |
| }); | |
| async.eachSeries(batches, function(batch, callback){ |
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
| ^(\s*)"([^"]*)"\s*\+ | |
| $1$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
| var _ = require("underscore"); | |
| function hanoi(numPieces) { | |
| var stacks = [ _.range(1, numPieces + 1).reverse(), [], [] ]; | |
| function findOtherStackNo(one, two) { | |
| return _.without([0, 1, 2], one, two)[0]; | |
| } |
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
| ;quicksort | |
| (defn remove* [n l] | |
| (concat (subvec l 0 n) (subvec l (+ n 1) (count l)))) | |
| (defn qsort [l] | |
| (if (<= (count l) 1) | |
| l | |
| (let [ length (count l) | |
| pivot-pos (quot length 2) | |
| pivot (nth l pivot-pos ) |
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 tconj [v t] | |
| (cond (nil? t) | |
| {:value v :left nil :right nil} | |
| (< v (:value t)) | |
| {:value (:value t) :left (tconj v (:left t)) :right (:right t) } | |
| (> v (:value t)) | |
| {:value (:value t) :left (:left t) :right (tconj v (:right t) ) } | |
| :else t ;no dupes | |
| )) |
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
| mvn clean install -DskipTests=true -Dpmd.skip=true -Dcobertura.skip=true -T 1.0C | |
| if [ $? -eq 0 ]; then | |
| notify-send "Build Success" -i /home/dawid/build_status/success.jpg | |
| else | |
| notify-send "Build Failure" -i /home/dawid/build_status/failure.jpg | |
| fi |
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
| sleep 3m; xmessage -nearmouse "Your tea is ready" |
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
| #!/bin/bash | |
| #Search for classes/files in jars | |
| SEARCH_DIR=$1 | |
| SEARCH_PHRASE=$2 | |
| if [ -d $SEARCH_DIR ]; then | |
| echo "Searching in $SEARCH_DIR ..." | |
| else | |
| echo "Please provide a directory to search as the first argument" |
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
| DBRef.fetch = function(obj, refname, callback){ | |
| if(_.isArray(obj[refname])){ | |
| if(obj[refname].length){ | |
| var ids = _.pluck(obj[refname], "oid"); | |
| db.collection(obj[refname][0].namespace).find({_id: {$in : ids}}, function(err, objs){ | |
| obj[refname] = objs; | |
| callback(null,obj); | |
| }); | |
| } else { | |
| obj[refname] = []; |
NewerOlder