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
/* This is a silly simple attempt at having a object that is always | |
* instantiated whenever it is called directly or with the `new` keyword. | |
* | |
* It relies on `constructor`, basically. But since it uses the | |
* context inside the function and simply compares it's constructor with the | |
* current function, you can't be sure it's always going to be an | |
* auto-instantiation when called directly (without the new keyword), since the | |
* object used as context could have the same constructor as the current | |
* 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
var sDate = new Date() | |
, today = new Date() | |
, str = "" | |
, node; | |
sDate.setFullYear(2011, 0, 1); | |
if (sDate > today) { | |
str = sDate.getFullYear() } | |
else { |
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
function Counter(str) { | |
var filter_instance = this; // keep a reference to this object's instance | |
this.char_count = 0; // number of unique chars found | |
/* return a table mapping each char to it's number of occurrences */ | |
function count_chars() { | |
var array = str.split(""); | |
var table = {}; | |
array.map(function(elm, index, a) { | |
/* this function is called in the context of `array`. Which means |
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
// your function | |
function calcDistance (start, end) { | |
var distance=9999999; | |
var request = { | |
origin:start, | |
destination:end, | |
travelMode: google.maps.DirectionsTravelMode.DRIVING | |
}; | |
directionsService.route(request, function(result, status) { | |
if (status == google.maps.DirectionsStatus.OK) { |
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
For each `quote` in `Quotation` do: | |
Create a new DOM Node as `node`; | |
Set `node`'s value to `quote`; | |
Insert `node` in the document; |
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
var element = document.getElementById("sum-div"); | |
(function() { | |
var timer_id; | |
function check_visible() { | |
// you have access to timer_id here :3 | |
if (element.style.display != "none") | |
clearInterval(timer_id); | |
} |
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
function flatten(list) { | |
var i = 0, len = list.length; | |
while (i++ < len) | |
if (list[i] && list[i].length) | |
list.splice.apply(list, [i, 1].concat(flatten(list[i]))); | |
return list; | |
} |
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
HAI | |
WEN I SEZ CRAMPZ (LOLOBJ, URTHINGY) U | |
LOLOBJ DEN push(URTHINGY) | |
KTHX | |
WEN I SEZ RUNG (BUCKETZ, STARTZ, ENDZ) U | |
U GOTZ A GURL | |
IM IN UR STARTZ PIMPIN UR GURL | |
IZ GURL LIEK ENDZ | |
GTFO KTHX |
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
function classOf(obj) { | |
return Object.prototype.toString.call(obj).slice(8, -1) | |
} | |
// sanitize the arguments for the `_foo` function | |
function foo() { | |
var args = [].slice.call(arguments) | |
, bar, baz | |
// get bar if it's a String |
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
Página 1: | |
<form id="frmData" method="GET"> | |
<input type="hidden" id="post-data" name="data" value=""> | |
</form> | |
<script type="text/javascript"> | |
document.getElementById("post-data").value = JSON.stringify([1,2,3]) | |
</script> |