Skip to content

Instantly share code, notes, and snippets.

View JamesMaroney's full-sized avatar

James Maroney JamesMaroney

View GitHub Profile
@JamesMaroney
JamesMaroney / TemplateViewRenderOverride
Created April 29, 2011 13:04
overriding render of TemplateView
PolicyManagement.UpsertPolicyView = SC.View.design({
childViews: [ "header", "body" ],
header: SC.TemplateView.extend({
templateName: "upsert_policy_header",
render: function(){
return "<h1>blah</h1>";
}
App -> Controllers -> Views -> Templates
\------- Javascript --------/ \- HTML - /
App: The App bootstraps the application environment, defines application routes and orchestrates controller transitions.
It provides controllers with an outgoing interface to communicate with the application.
Controllers: Controllers define islands of functionality in the application. They instantiate models and bootstrap views.
They provide views with an outgoing interface to communicate with the controller.
Views: Views bootstrap templates and nested views and translate user events into view method calls.
@JamesMaroney
JamesMaroney / gist:969473
Created May 12, 2011 21:19
jasmine with requirejs
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
<title>Jasmine suite</title>
<link rel="stylesheet" href="/__JASMINE_ROOT__/lib/jasmine.css" type="text/css" media="screen"/>
@JamesMaroney
JamesMaroney / gist:1250688
Created September 29, 2011 13:01
pre-process leading to method_missing
@validator << myMethod param1, param2
@validator[' __invoke_message__ '] 'myMethod', param1, param2
@JamesMaroney
JamesMaroney / gist:1259778
Created October 3, 2011 18:00
proposed payload structure for validation messages
{
isValid: false
payload: [
{ field: "field 1", message: "message 1" },
{ field: "field 2", message: "message 2" }
]
}
{
"Raven-Entity-Name": "LinkLibraries",
"Raven-Clr-Type": "TNW.PolicyManagement.Entities.LinkLibrary, TNW.PolicyManagement-Core"
}
=============
@JamesMaroney
JamesMaroney / StandardTransformations
Created October 26, 2011 13:20
specflow transformations
[StepArgumentTransformation]
public static DateTime GetDateTime(string match)
{
return DateTime.Parse(match);
}
[StepArgumentTransformation(@"(.*) (?:to|-|through) (.*)")]
public static Range<DateTime> DateRange(string lowerBound, string upperBound) {
return new Range<DateTime> { Lower = DateTime.Parse(lowerBound), Upper = DateTime.Parse(upperBound) };
}
@JamesMaroney
JamesMaroney / gist:1319699
Created October 27, 2011 14:31
get enum val by string
fileType = Enum.Parse(typeof(ArtifactStore.ArtifactFileType), fileExtension.ToUpper());
fileType = Enum.GetValues(typeof (ArtifactStore.ArtifactFileType))
.Cast<ArtifactStore.ArtifactFileType>()
.Where(m => m.ToString() == fileExtension.ToUpper()).SingleOrDefault();
@JamesMaroney
JamesMaroney / gist:1367121
Created November 15, 2011 13:54
Serializer
public static class Serializer
{
private static JsonSerializer ServerToServerInstanceBacker;
private static JsonSerializer ServerToClientBacker;
private static JsonSerializer ClientToServerBacker;
public static JsonSerializer ServerToServerInstance { get { return ServerToServerInstanceBacker = ServerToServerInstanceBacker ?? Get(); } }
public static JsonSerializer ServerToClientInstance {
@JamesMaroney
JamesMaroney / gist:1401690
Created November 28, 2011 19:39
Guid Combine
public static Guid Combine(params Guid[] guids) {
const int BYTECOUNT = 16;
byte[] destByte = new byte[BYTECOUNT];
var listOfByteArrays = guids.Select(guid => guid.ToByteArray()).ToArray();
for (int i = 0; i < BYTECOUNT; i++) {
destByte[i] = listOfByteArrays.Aggregate<byte[], byte>(0, (current, array) => (byte) (current ^ array[i]));
}
return new Guid(destByte);
}