Skip to content

Instantly share code, notes, and snippets.

@istupakov
istupakov / ShuntingYardParser.cs
Created September 29, 2016 18:39
C# realization of Shunting-yard algorithm
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace ShuntingYardParser
{
enum TokenType { Number, Variable, Function, Parenthesis, Operator, Comma, WhiteSpace };
@Ciantic
Ciantic / ModelStateValidationFilter.cs
Created April 21, 2016 06:19
Model state validation filter ASP.NET Core
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Example
{
public class ModelStateValidationFilter : Attribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
@beyond-code-github
beyond-code-github / Config
Last active December 14, 2015 15:18
We have two different kinds of route at present, /Api/{AppId}/{Controller}/{Id} and /Api/{Controller}/{Id}. The Linked route provider ensures that if we PATCH or PUT to either of these that we also invalidate the cache for the same route without the {Id} parameter
config.MessageHandlers.Add(new CachingHandler
{
UriTrimmer = (uri) => uri.LocalPath,
LinkedRoutePatternProvider = LinkedRoutePatternProvider
});
public static IEnumerable<string> LinkedRoutePatternProvider(string s, HttpMethod httpMethod)
{
var appAware = new Regex("/Api/[0-9]+/([a-z]|[A-Z])+/[0-9]+");
if (appAware.IsMatch(s))
@johnnyreilly
johnnyreilly / GlobalizeUrls.cs
Last active October 10, 2015 06:58
A monkey patch for jquery.validate.js that allows validation to be internationalised
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Hosting;
using System.IO;
using System.Globalization;
namespace My.Helpers
{
@scttnlsn
scttnlsn / README.md
Created July 30, 2012 22:16
Pub/sub with MongoDB and Node.js

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
// From http://stackoverflow.com/questions/931207/is-there-a-jquery-autogrow-plugin-for-text-fields
(function ($) {
$.fn.autoGrowInput = function (o) {
o = $.extend({
maxWidth:1000,
minWidth:0,
comfortZone:70
}, o);
@fat
fat / Tokenahead.less
Created April 18, 2012 04:01
Tokenahead - ghetto typeahead with facebook-like tokens 4 @couch <3
// Tokenahead.less
// ---------------
.tokenahead {
cursor: text;
overflow: hidden;
height: auto;
padding-bottom: 0;
border-color: @inputBorder;
}