> var male=false;
undefined
> var salutation;
undefined
> if (male) {
... salutation = 'Mr.';
... } else {
... salutation = 'Mrs.';
... }
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 tmp; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
/** <p> | |
* Find the lucky numbers amongst natural numbers from 1 to n. |
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
/** | |
* http://web.stanford.edu/class/cs9/lectures/Coding%20Drill%203.pdf | |
* Problem One: Array Rotation | |
* Your job is to write a function | |
* void rotateArray(int* array, size_t n, size_t amount) | |
* that accepts as input an array and a “rotation amount.” You should then “rotate” the array | |
* by cyclically shifting all of the elements in the array to the left by a number of steps | |
* given by the rotation amount. As an example, suppose we have this array: | |
* 103 106 107 108 109 110 140 161 | |
* Rotating it to the left by three steps would yield this array: |
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
// based on http://syntx.io/basic-symmetric-encryption-example-with-java/ | |
import java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.security.InvalidAlgorithmParameterException; | |
import java.security.InvalidKeyException; | |
import java.security.Key; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.SecureRandom; | |
import java.sql.SQLException; |
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
// can I implement an object that demonstrates cascading? | |
"use strict"; | |
var getElement = function() { | |
var element = { | |
left_bottom: { x: 0, y: 0}, | |
area: {x: 0, y: 0}, | |
color: 'red' | |
}; | |
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
Function.prototype.method = function(name, func) { | |
this.prototype[name] = func; | |
} | |
Number.method('integer', function () { | |
return Math[this < 0 ? 'ceil' : 'floor'](this); | |
}); | |
console.log((20/6).integer()); |
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 hanoi = function (disks, src, aux, dst) { | |
if (disks > 0) { | |
hanoi(disks-1, src, dst, aux); | |
console.log("Move disk: " + disks + " from: " + src + " to: " + dst); | |
hanoi(disks-1, aux, src, dst); | |
} | |
} | |
//hanoi(3, "1", "2", "3"); | |
/* | |
var stack = []; |
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
<html> | |
<head> | |
<script type="text/javascript"> | |
function foo(response) { | |
var meta = response.meta; | |
var data = response.data; | |
console.log(meta); | |
console.log(data); | |
} |
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
speakingjs-md |
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
class ToString { | |
public static void main(String[] args) { | |
System.out.println("Unscientific benchmark, but out of curiosity"); | |
long t1, t2; | |
java.util.Random r = new java.util.Random(); | |
long i = r.nextLong(); | |
t1 = System.nanoTime(); | |
String s = "" + i; | |
t2 = System.nanoTime(); | |
System.out.println(s + " using + on string: " + (t2-t1)); |