View gist:744701
public static IPAddress GetIpAddress(System.ServiceModel.OperationContext context) | |
{ | |
var prop = context.IncomingMessageProperties; | |
if (context.IncomingMessageProperties.ContainsKey(System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name)) | |
{ | |
var endpoint = prop[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] | |
as System.ServiceModel.Channels.RemoteEndpointMessageProperty; | |
if (endpoint != null) | |
{ | |
return IPAddress.Parse(endpoint.Address); |
View gist:750202
var createTableWithCaption = function (id, caption, tableStyle) | |
{ | |
var sb = "<div class='sd-info'><table id='" + id + "' class='itfa_sectionbody' style='" + tableStyle + "'>"; | |
if (caption) sb += "<caption>" + caption + "</caption>"; | |
return sb; | |
} | |
var createTableFn = function (id, fieldNames, caption, tableStyle, tfoot) | |
{ |
View AsyncServiceClientTests
[TestFixture] | |
public class AsyncServiceClientTests | |
{ | |
private const string ListeningOn = "http://localhost:82/"; | |
ExampleAppHostHttpListener appHost; | |
[TestFixtureSetUp] | |
public void OnTestFixtureSetUp() | |
{ |
View NonBlockingReadBufferedStream alpha
/* 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 |
View Working Redis Example
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; |
View gist:844885
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; |
View install_nginx.sh
#!/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 |
View StringBuffer.js
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); | |
} |
View FastJQueryForIE7
/* | |
* 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: |
View js-utils.js
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; |
OlderNewer