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
public static String invert(String invertMe) { | |
StringBuilder output = new StringBuilder(); | |
for (int i=invertMe.length(); i>0; i--) { | |
output.append(invertMe.charAt(i-1)); | |
} | |
return output.toString(); | |
} |
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
[SeatDefaults] | |
greeter-session=lightdm-gtk-greeter | |
user-session=xubuntu |
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
public class Test { | |
class Parent {} | |
class Child extends Parent {} | |
public void accept(Parent[] parent) { | |
System.out.println("accepted"); | |
} | |
public static void main(String[] args) { |
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
// The `quickEach` method will pass a non-unique jQuery instance | |
// to the callback meaning that there will be no need to instantiate | |
// a fresh jQuery instance on each iteration. Most of the slow-down | |
// inherent in jQuery's native iterator method (`each`) is the constant | |
// need to have access to jQuery's methods, and so most developers | |
// see constructing multiple instances as no issue... E.g. | |
// $(...).each(function(){ $(this)... $(this)... $(this)... }); | |
// A better approach would be `quickEach`. | |
jQuery.fn.quickEach = (function(){ |
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
jQuery.fn.quickEach = (function() { | |
var jq = jQuery([1]); | |
return function(c) { | |
var i = -1, el, len = this.length; | |
try { | |
while (++i < len && (el = jq[0] = this[i]) && c.call(jq, i, el) !== false); | |
} catch (e) { | |
delete jq[0]; | |
throw e; | |
} |
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
public class Complex { | |
private Complex() {} | |
public static void main(String[] args) { | |
new ComplexBuilder() | |
.setFirst("first") | |
.setSecond("second") | |
.setThird( "third" ) | |
.build(); |
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
(global-set-key (kbd "C-c C-r") 'run-mocha) | |
(defun run-mocha() | |
"Runs all the tests in the current buffer" | |
(interactive) | |
(let* (command result exit-value) | |
(setq command (concat "mocha -r should " (buffer-name))) | |
(setq exit-value (shell-command command)) | |
(color-modeline exit-value))) |
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
request({ | |
method: "POST", | |
uri: "http://example.com/action", | |
json: { | |
foo: "foo", | |
bar: "bar" | |
} | |
}, function (error, response, body) { | |
if(response.statusCode === 201){ | |
console.log("posted"); |
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
//I've launched my app as so: NODE_ENV=development nodemon server.js | |
var Log = new require("log"), | |
log = new Log(process.env.NODE_ENV === "production" && | |
"error" || "debug"); |
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
(defun mocha-run(test-file) | |
"Runs all the tests in the passed file" | |
(interactive "b") | |
(let* (command result exit-value) | |
(setq command (concat "mocha -r should --globals i --timeout 10000 " test-file)) | |
(setq exit-value (shell-command command)) | |
(color-modeline test-file))) | |
(defun color-modeline(test-file) | |
"Colors the modeline, green success red failure" | |
(interactive) |