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 saveToFile() { | |
var canvasData = document.getElementById('sampleCanvas').msToBlob(); | |
var windowsStorage = Windows.Storage; | |
var inputStream, outputStream; | |
windowsStorage.KnownFolders.picturesLibrary.createFileAsync('sample.png', windowsStorage.CreationCollisionOption.replaceExisting) | |
.then(function (file) { | |
return file.openAsync(windowsStorage.FileAccessMode.readWrite); | |
}).then(function (out) { | |
inputStream = canvasData.msDetachStream(); | |
canvasData.msClose(); |
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.then = function(callback) { | |
var branches = { false:function() {}, true:callback }; | |
var that = this; | |
return function() { | |
var r = that.apply(that, arguments); | |
branches[r].apply(that, arguments); | |
return r; | |
} | |
} |
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(max) { | |
var counter = 0 | |
, theEnd = function() { | |
console.log(max); | |
} | |
, count = function() { | |
console.log(counter); | |
counter++; | |
countOperations[counter] = count; | |
countOperations[counter % max](); |
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
// This fails with ["a,,", "b"] Do you know how to fix it? We'll see how to in class | |
var concatenator = function(arr, optSeparator) { | |
if(!arr || typeof(arr.join) != 'function') | |
return; | |
var separator = typeof(optSeparator) == 'string' ? optSeparator : ','; | |
var r = arr.join(); | |
if(separator != ',') | |
r = r.replace(/,/g, separator); | |
return r; | |
} |
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 concatenator = function(arr) { | |
if(!arr || typeof(arr.join) != 'function') | |
return; | |
return arr.join(); | |
} |
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
public class AuditorTransferenciasMonetarias { | |
/* Ahora la clase implementa lógica de negocio "pura" | |
* y es independiente de la plataforma (a.k.a. framework) | |
*/ | |
private DirectorioEmpleados directorioEmpleados; | |
private SistemaMensajeriaCorporativa mensajero; | |
private PlantillasCorporativas almacenDePlantillas; | |
/* No se muestra todo el código */ | |
public void transferenciaRealizada(Transferencia transferencia) { |
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
module FizzBuzzGame | |
class Number | |
def initialize(number) | |
@value= number | |
end | |
def answer_for | |
return FIZZBUZZ if divisible_by?(3) and divisible_by?(5) | |
return FIZZ if divisible_by?(3) | |
return BUZZ if divisible_by?(5) |
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
# StringCalculator in Ruby 1.8.x | |
class StringCalculator | |
DEFAULT_DELIMITER_DETECTOR = /\,|\n/ | |
CUSTOM_DELIMITER_PARSERS = [/^\/\/(.)\n/, /^\/\/((?:\[[^\]]+\])+)\n/] | |
def initialize(numbers) | |
@numbers=numbers | |
@result=nil | |
@errors='' |