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
document.getElementById('element').innerHTML = ""; | |
console.log = function(...m) { | |
document.getElementById('element').innerHTML += m.reduce((_m, _a) => _m + _a, ""); | |
document.getElementById('element').innerHTML += "<br />"; | |
} |
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
type Process<'a> = | |
| Value of 'a | |
| Message of string | |
let quad a = a * a | |
let add a b = a + b | |
let print m = | |
match m with | |
| Value n -> printf "Number: %d\n" n |
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
Table of contents: | |
[TOC] | |
Functional Programming | |
=================== | |
Why are we so fussed about Functional Programming? Is it really better than Object Oriented programming? Can it solve our problems? | |
If you are like me you'll have heard a lot of buzz about functional programming these last few years you might be wondering how this "functional programming" fits into your day to day work and how it affects your code. | |
The answer is quite simple, yes, functional programming will make you a better programmer. Yes, functional programming will solve a lot of problems arising from complexity; but most of all functional programming is the only way to leverage the power of multi-core chip-sets. |
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
/// Promise.js | |
function Promise() { | |
this.then = function (handler) { | |
this.thenHandler = handler; | |
return this; | |
}; | |
this.error = function (handler) { |
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
define(function () { | |
var self = this; | |
self.notifyPropertyChanged = function (obj) { | |
// initialize the local variables | |
var args = Array.prototype.slice.call(arguments), | |
skipList = []; |
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
app.run(function ($http) { | |
$http.get('/api/menu').then(function (routes) { | |
routes.data.forEach(function (route) { | |
rpv.when(route, { | |
controller: '<controller name>', | |
templateUrl: '<tempalte name>', | |
reloadOnSearch: false | |
}); | |
}); | |
}); |
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
// imagine a factory with the following code somewhere in the factory: | |
app.factory('asyncFactory', function($q, $timeout) { | |
// a factory always needs to return a value | |
return { | |
getAsyncValue: function () { | |
var deferred = $q.defer(); | |
$timeout(function () { | |
deferred.resolve('This is an item'); | |
}, 2000); | |
return deferred.promise; |
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
using System; | |
using System.IO; | |
using System.Web; | |
namespace test01 | |
{ | |
public static class Logger | |
{ | |
public static void Log(string message) |
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
// a jQuery extension for an image rotator with options | |
(function ($) { | |
$.fn.rotate = function (options) { | |
// initialize the options object if it's null. | |
var o = options || { images: [] }, | |
that = this, | |
index = 0, | |
length = o.images.length; | |
if (!o.images) o.images = []; |
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
// When getting somehting from the chrome storage you | |
// need to keep in mind that these items are returned | |
// as objects compared to the localStorage in the browser | |
// which returns the items als string literals. | |
// In combination with angularJS you need to keep in mind | |
// that you need to apply the result of this async call | |
// the the $scope of the controller. This will trigger | |
// the refresh. |
NewerOlder