Skip to content

Instantly share code, notes, and snippets.

View DavyLandman's full-sized avatar

Davy Landman DavyLandman

View GitHub Profile
public static OrderState AsOrderState(this int i)
{
return (OrderState)i;
}
public static OrderState GetState(this Order self)
{
return (OrderState)self.State;
}
public class BrowserCacheAttribute : ActionFilterAttribute
{
/// <summary>
/// Gets or sets the cache duration in seconds.
/// The default is 10 seconds.
/// </summary>
/// <value>The cache duration in seconds.</value>
public int Duration
{
get;
@DavyLandman
DavyLandman / gist:823100
Created February 11, 2011 21:45
I love it when a plan comes together. :) using rascal-dotnet to generate 90% of the source for rascal-csharp
data AstNode =
usingAliasDeclaration(AstType import, str alias, NodeType nodeType)
| typeParameterDeclaration(str identifier, VarianceModifier variance, NodeType nodeType)
| arraySpecifier(int dimensions, NodeType nodeType)
| caseLabel(Expression expression, NodeType nodeType)
| comment(str content, NodeType nodeType, bool startsLine, CommentType commentType)
| namespaceDeclaration(str fullName, str name, list[AstNode] members, list[Identifier] identifiers, NodeType nodeType)
| cSharpModifierToken(ICollection allModifiers, Modifiers modifier, NodeType nodeType)
| parameterDeclaration(str name, Expression defaultExpression, ParameterModifier parameterModifier, AstType type, list[AttributeSection] attributes, NodeType nodeType)
| constructorInitializer(ConstructorInitializerType constructorInitializerType, list[AstNode] arguments, NodeType nodeType)
@DavyLandman
DavyLandman / gist:842956
Created February 24, 2011 21:47
Nice, improved the fact extraction for my rascal-csharp AST, looks pretty clean now.. next up, escape rascal keywords and add java, c# and protobuf support :)
module CSharp
public alias CSharpFile=list[Ast];
data AstNode = comment(CommentType commentType, str content, bool startsLine)
| namespaceDeclaration(str name, list[AstNode] identifiers, list[AstNode] members, str name)
| constraint(list[AstType] baseTypes, str typeParameter)
| queryOrdering(QueryOrderingDirection direction, Expression expression)
| attribute(list[Expression] arguments)
| cSharpModifierToken(list[Modifiers] allModifiers, list[Modifiers] modifier)
| variablePlaceholder(str name, str name)
// Add support for an alternative (second) dateFormat to the jQuery datepicker
(function () {
var oldMethod = $.datepicker.parseDate;
$.datepicker.parseDate = function () {
var dateValue = Date.parseExact(arguments[1], 'ddMMyyyy');
if (dateValue) {
return dateValue;
}
return oldMethod.apply(this, arguments);
};
@DavyLandman
DavyLandman / gist:2634811
Created May 8, 2012 13:08
Turing L2 Bitflipper
L Restart
REP 10 {
L Start
J1 Unset
W1
J_ Move
L Unset
W0
L Move
MF
@DavyLandman
DavyLandman / gist:2634816
Created May 8, 2012 13:09
Turing L1 Bitflipper
J14
W1
J_5
W0
MF
J19
W1
J_10
W0
MF
@DavyLandman
DavyLandman / new_bashrc.sh
Created August 11, 2012 15:59 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@DavyLandman
DavyLandman / Output.txt
Created September 23, 2012 15:41
URI encoding stuff in Java
project://name/path
auth: name host: name port: -1
project://name%20space/path
auth: name space host: null port: -1
project://name:200/path
auth: name:200 host: name port: 200
project://name%20space:200/path