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
/* Incomplete un-tested buffered implementation designed to accomodate 1 write thread and 1 read thread only | |
* Not implemented yet, but is expected to be pooled. | |
*/ | |
public class NonBlockingReadBufferedStream | |
: Stream, IEnumerable<Action<Action<object>, Action<Exception>>>, IDisposable | |
{ | |
private const int MtuAppSize = 1450; | |
private const int BufferAllocationSize = 32 * 1024; | |
internal int ResetClearsBufferOfMaxSize = 4 * 1024 * 1024; //4MB |
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; | |
using System.Text; | |
using ServiceStack; | |
using ServiceStack.Common; | |
using ServiceStack.Common.Extensions; | |
using ServiceStack.Common.Utils; | |
using ServiceStack.Redis; | |
using ServiceStack.Redis.Generic; |
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
#!/bin/bash | |
## DOWNLOADS | |
sudo curl -OL h ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz > /usr/local/src/pcre-8.12.tar.gz | |
sudo curl -OL h http://nginx.org/download/nginx-0.9.5.tar.gz > /usr/local/src/nginx-0.9.5.tar.gz | |
## Install PCRE | |
sudo mkdir -p /usr/local/src | |
cd /usr/local/src | |
tar xvzf pcre-8.12.tar.gz |
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 hasScriptEngine = 'ScriptEngine' in window; | |
var HAS_JSCRIPT = hasScriptEngine && window['ScriptEngine']() == 'JScript'; | |
var IS_IE = HAS_JSCRIPT; | |
var StringBuffer = function(opt_a1, var_args) { | |
this.buffer_ = HAS_JSCRIPT ? [] : ''; | |
if (opt_a1 != null) { | |
this.append.apply(this, arguments); | |
} |
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
/* | |
* Faster jQuery DOM traversal for <= IE7. | |
* Usage: | |
* $Q() is a drop-in replacement for $(). Returns same jQuery object. | |
* | |
* //$Q = $; //Un-comment, to switch to use jQuery for benchmark comparisons | |
* My avg benchmarks in IE7 for traversing a 20x30 table was: | |
* 786ms vs 6140.67ms - Chrome can do it natively in 28ms | |
* | |
* Limitations: |
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 fromDtoDate = function(dateStr) { | |
if (!dateStr) return null; | |
return new Date(parseFloat(/Date\(([^)]+)\)/.exec(dateStr)[1])); | |
} | |
var formatDtoDate = function(dateObj) { | |
if (!dateObj) return ""; | |
if (dateObj != typeof "date") dateObj = fromDtoDate(dateObj); | |
var day = dateObj.getDate(), month = dateObj.getMonth() + 1; | |
if (day < 10) day = "0" + day; |
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
# CoffeeScript With Mixins | |
$ -> | |
template = _.templateFor '#meal-template' | |
meal = new Meal | |
_.focusOn '#entry' | |
_.onSumbitOf '#entry_form', -> | |
meal.add new Dish _.valOf '#entry' | |
_.setHtmlOf 'ul#meal', template meal.toJSON() |
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
class Dish | |
constructor: (rawDescription="") -> | |
[all, @title, @price] = @parseRawDescription rawDescription | |
@price = new Money @price | |
parseRawDescription: (rawDescription) -> | |
pattern = /// | |
([^$]+) #Title | |
(\$\d+\.\d+) #Price | |
/// |
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
# Generate a sequence of numbers: | |
# - ordered with the highest values | |
# - has a sum of 1 | |
# - has an optional multiplier to alter the decreasing rate | |
sequence = (n,m=0) -> | |
f = (p,multiplier) -> p * p + multiplier | |
s = "" |