Skip to content

Instantly share code, notes, and snippets.

@andrewdavey
andrewdavey / gist:704900
Created November 18, 2010 12:02
Potential encoding bug in RavenDB's /static response
static void StaticKeyBug()
{
using (var store = new DocumentStore())
{
store.Url = "http://localhost:8080";
store.Initialize();
store.DatabaseCommands.PutAttachment("test/hello/world", null, new byte[] { 1, 2, 3 }, new JObject());
using (var wc = new WebClient())
@andrewdavey
andrewdavey / gist:700607
Created November 15, 2010 17:05
Extending view model wishlist
class CustomerController : Controller {
public ActionResult List() {
var customers = DB.GetAllCustomers();
ViewModel.Customers = customers;
ExtendViewModel<Customer>("Url", customer => Url.Action("details", new { customer.Id }));
return View();
}
// This won't work as you probably want
for (var i = 0; i < 10; i++) {
handlers.push(function() {
use(i);
});
}
// This won't work due to "var yanking"
for (var i = 0; i < 10; i++) {
var j = i;
jQuery.parseJSON = (function(parse) {
var datePattern = /^\/Date\((\d+)\)\/$/;
return function(data) {
var value = parse(data);
parseDates(value);
return value;
}
function parseDates(obj) {
for (var k in obj) {
ko.bindingHandlers.keyFilter = {
init: function(element, value, allBindings) {
var filter = ko.bindingHandlers.keyFilter[allBindings.keyFilter];
if (!filter) return;
$(element).keypress(function(event) {
if (!filter(event.which)) {
event.stopPropagation();
return false;