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
| function getOrElse(value, _) { | |
| var args = Array.prototype.slice.call(arguments); | |
| for (var i = 0; i < args.length; i++) { | |
| var arg = args[i]; | |
| if(typeof arg != "undefined" && arg != null && !isNaN(arg)) { | |
| return arg; | |
| } | |
| } | |
| return null; | |
| } |
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
| diskpart | |
| list disk | |
| select disk # | |
| clean | |
| create partition primary | |
| select partition 1 | |
| active | |
| format fs=ntfs | |
| assign |
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
| $(document).on('mousedown', 'a', function(e) { | |
| if(($(this).attr('target') == '' || $(this).attr('target') != '_blank') && !new RegExp('/' + window.location.host + '/').test(this.href)) { | |
| $(this).attr('target', '_blank'); | |
| } | |
| }); |
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
| PREF="$HOME/Library/Preferences/" | |
| if [ -r "$PREF/IntelliJIdea13" ]; then | |
| folder="$PREF/IntelliJIdea13" | |
| elif [ -r "$PREF/IntelliJIdea12" ]; then | |
| folder="$PREF/IntelliJIdea12" | |
| else | |
| echo "Pasta do IntelliJ nao encontrada" | |
| exit 1 | |
| 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
| #!/bin/bash | |
| for D in *; do | |
| if [ -d "${D}" ] && [ -d "${D}/.git" ]; then | |
| echo "--> ${D}\n" | |
| pushd "${D}" | |
| git up | |
| popd | |
| fi | |
| done |
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
| window.$ = (function () { | |
| var cbs = []; | |
| return function (callback) { | |
| cbs.push(callback); | |
| window.onload = function () { | |
| while( !window.jQuery ); | |
| cbs.map(function (c) { c(); }); | |
| }; | |
| }; | |
| })(); |
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 | |
| if [ -z $(which boot2docker) ]; then | |
| echo "You must install boot2docker first" | |
| echo "Your PATH: $PATH" | |
| exit 1 | |
| fi | |
| if [ -z $(which VBoxManage) ]; then | |
| echo "You must have VBoxManager in your PATH" |
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 rapture._ | |
| import core._, io._, net._, uri._, json._, codec._ | |
| import jsonBackends.jawn._ | |
| import encodings.`UTF-8` | |
| object Test extends App { | |
| // entities | |
| case class Bands(groups: Seq[Band]) |
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
| // 1: Handler | |
| def handle(req: Request): Response = { | |
| val indexes = req.get("indexes") | |
| service(indexes) | |
| .map(Response(json(_))) | |
| .orElse(Response.badRequest) | |
| } | |
| // 2: Service |
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
| package transactions | |
| import com.twitter.finagle.exp.mysql.{Client, OK, Result} | |
| class Db(mysqlClient: Client) { | |
| val insertOrder = "INSERT INTO orders (ref) VALUES(?)" | |
| val insertOrderItem = "INSERT INTO order_items (order_id, item_id) VALUES(?, ?)" | |
| def persistOrderWithItems[T](order: Order)(whenDone: (OK, Seq[Result]) => T): Future[T] = { |