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.
This file contains 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 org.scalatest.Assertions | |
import org.scalatest.concurrent.ScalaFutures | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
trait FutureExceptions { | |
self: Assertions with ScalaFutures => | |
def getExceptionFromFuture(future: Future[Any]): Throwable = { |
This file contains 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
sbt "issues/test:testOnly stepdefs.RunIssuesCucumber" | |
This file contains 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
/** | |
* repeats a check until the check is true or the timeout is reached | |
* returns a promise that we can return to mocha | |
*/ | |
function promisePoller(condition, | |
interval = 10, | |
timeout = 1000, | |
onTimeout = new Error("Timed out")) { | |
return new Promise(function (resolve, reject) { | |
function check() { |
This file contains 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
"test:alex": "mocha --watch 'modules/issues/test/unit/javascript/**/IssueDetailTest.js' --compilers js:babel-core/register --require ignore-styles --require ./modules/issues/test/unit/util/jsdom-setup", |
This file contains 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
Docker MySQL | |
docker run -p 3306:3306 --name local-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:latest --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | |
mysql -h $(docker-machine ip) -uroot -ppassword |
This file contains 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
killall ssh-agent gpg-agent | |
unset GPG_AGENT_INFO SSH_AGENT_PID SSH_AUTH_SOCK | |
eval $(gpg-agent --daemon --enable-ssh-support) |
This file contains 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
# Looping through an array to form a new array | |
# non functional (imperative) way | |
my_array = [1,2,3,4,5] | |
new_array = [] # requires us to create a structure then modify it using push | |
my_array.each { | element | | |
new_array.push("number " + element.to_s) | |
} |
This file contains 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
students = [ | |
{ name: "Bob", cohort: "Nov"}, | |
{ name: "Barry", cohort: "Nov"}, | |
{ name: "Anna", cohort: "Dec"}, | |
{ name: "Igor", cohort: "Dec"}, | |
{ name: "Natalia", cohort: "Feb"} | |
] | |
my_hash = {} |
This file contains 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
package com.ajk; | |
import clojure.lang.IFn; | |
import java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import static clojure.java.api.Clojure.read; | |
import static clojure.lang.RT.loadResourceScript; | |
import static clojure.lang.RT.var; |