Enlaces con otros ficheros compartidos en los comentarios:
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
/* | |
* draw a multiline string rotated in a canvas | |
* | |
* @param ctx (M) context of the canvas | |
* @param text (M) string may contain \n | |
* @param posX (M) horizontal start position | |
* @param posY (M) vertical start position | |
* @param textColor color | |
* @param rotation in degrees (by 360) | |
* @param font must be installed on client use websafe |
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
// ------------------------------------------------------------------------------------------------ | |
/** | |
* Why CLOSURES are great! | |
* | |
* Think of Closures as Functions within Functions... where nested functions have access to parent function variables | |
* and arguments. So, you may ask? | |
* | |
* Closures allow developers to temporarily cache data! | |
* Closures can simplify recursion or iterations (aka visitors pattern) | |
* Closures can solve real-world `callback` problems; especially powerful for asynchronous callbacks. |
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 Something | |
{ | |
public function doSomething(index:int) : void | |
{ | |
// Async closure for timer completion event | |
function onComplete_doSomething(evt:TimerEvent) : void | |
{ | |
// Always clean up 1st, then notify listeners | |
timer.removeEventListener(TimerEvent.TIMER, onComplete_Timer ); | |
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
// Example usage: | |
// | |
// int[] numbers = {1, 2, 3, 4, 5, 6, 7}; | |
// int[][] chunks = chunkArray(numbers, 3); | |
// | |
// chunks now contains [ | |
// [1, 2, 3], | |
// [4, 5, 6], | |
// [7] | |
// ] |
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
<!doctype html> | |
<html> | |
<head> | |
<script type="text/javascript" src="vcard2.js"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
// With helper methods | |
var fooBar = vCard.create(vCard.Version.FOUR) | |
fooBar.addFormattedname("Mr Foo Bar") |
Problem During Load because of wrong ss:ExpandedRowCount
.
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
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been | |
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax. | |
// Array literal (= []) is faster than Array constructor (new Array()) | |
// http://jsperf.com/new-array-vs-literal/15 | |
var array = []; | |
// Object literal (={}) is faster than Object constructor (new Object()) | |
// http://jsperf.com/new-array-vs-literal/26 |
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 characters = document.querySelector('.characters'); // div with text | |
var charactersText = characters.textContent; | |
var charAtIndex = 25; | |
var offsetPosition; | |
characters.textContent = ''; | |
for (var i = 0; i < charactersText.length; i++) { | |
var textNode = document.createTextNode(charactersText[i]); | |
characters.appendChild(textNode); | |
if (i === charAtIndex) { |
OlderNewer