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
/* | |
cache.set(<key>, <value>) | |
cache.set({ <key1> : <value1>, <keyN> : <valueN> }); | |
cache.get(<key>, <optional|defaultvalue>) => <value> | |
Example: | |
cache.set({ foo : 'bar' }); | |
cache.get('foo'); //'bar' |
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.Collections.Generic; | |
using System.Linq; | |
namespace Utils.Extensions | |
{ | |
public static class FilterExtensions | |
{ | |
/// <summary> | |
/// Remove null values from the collection. |
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.Collections.Generic; | |
using System.Linq; | |
namespace Utils.Lab.Mapping | |
{ | |
/// <summary> | |
/// Mapper class converts a collection with the given predicate. | |
/// </summary> | |
public class CollectionMapper |
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.Collections.Generic; | |
namespace Cache | |
{ | |
/// <summary> | |
/// Generic cache. Should be wrapped in a singelton. | |
/// - Some issues with reloading, see http://stackoverflow.com/questions/8403782/c-sharp-reload-singleton-cache/ for more info. | |
/// </summary> |
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 just a simple function I wrote to be be able | |
to right click a link on Facebook and select "Save as". | |
Link.append('http://dl.dropbox.com/1.avi') | |
.append('http://dl.dropbox.com/2.mp3') | |
.append('http://dl.dropbox.com/3.jpg') | |
*/ | |
var Link = (function(w, d, undefined) { |
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
/*! | |
I can have reinvented the wheel...But it is good to do so, just for the education :) | |
Anyway! | |
Finds a item in an array, by the given search string and/or matching function. | |
Usage: | |
------------------ |
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
/*! | |
Written for education purpose. | |
Could use Array.filter / Array.map instead. | |
Example: | |
//Returns an array with one object: {name:'foo'} | |
var result = { packages : [{name:'foo'}, {name:'bar'}, {name:'baz'}] }; | |
result.packages.where(function() { | |
var name = this.name; |
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
Array.prototype.where = Array.prototype.where || function(predicate) { | |
var results = [], | |
len = this.length, | |
i = 0; | |
for(; i < len; i++) { | |
var item = this[i]; | |
if (predicate(item)) { | |
results.push(item); | |
} |
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(d, url) { | |
var h = d.getElementsByTagName('head')[0], | |
s = d.createElement('script'); | |
s.src = url; | |
s.onload = function() { | |
console.log('loaded %s', url); | |
}; | |
h.appendChild(s); |
OlderNewer