Skip to content

Instantly share code, notes, and snippets.

View mgroves's full-sized avatar

Matthew D. Groves mgroves

View GitHub Profile
<script type="text/x-dot-template" id="my-dot-template">
<p>Hello {{=it.Name}}!</p>
<p>I see that you are from {{=it.City}} and you wear a {{=it.ShoeSize}} size shoe.</p>
</script>
program HelloWorld(output);
begin
WriteLn('Hello world!')
end.
<script language="JScript" runat="server" src="/Scripts/json2.js"></script>
<%
dim url
url = "http://yoururl/jsonendpoint"
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "POST", url, false
HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpReq.Send("Foo=bar")
'use json2 via jscript to parse the response
<%
dim url
url = "http://yoururl/jsonendpoint"
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "POST", url, false
HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpReq.Send("Foo=bar")
%>
using System;
using System.Net;
using System.Web.Mvc;
using Mvc.Jsonp;
namespace My.Controllers
{
[AuthFilter]
public class SomeController : JsonpControllerBase
{
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://exampleapi.com/jsonp",
dataType: 'jsonp',
crossDomain: true // forcing a cross domain request for demonstration, you can omit this
})
.done(function(content) {
console.log(content);
});
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://www.google.com",
dataType: 'json',
crossDomain: true // forcing a cross domain request for demonstration, you can omit this
})
.done(function(content) {
console.log(content);
});
Establish context = () =>
{
};
Because of = () =>
{
};
// while I'm not actually relying on
// PostSharp or any of my real service classes anywhere in my unit tests
// I still need a service class to stand in and receive errors
// that I can test assertions against
public class FakeService : ServiceBase
{
public List<string> Errors { get; private set; }
public FakeService()
{
Errors = new List<string>();
[Serializable]
[MulticastAttributeUsage(MulticastTargets.Method, TargetMemberAttributes = MulticastAttributes.Public)]
public class ServiceErrorInterceptor : MethodInterceptionAspect
{
[NonSerialized]
ServiceErrorConcern _concern;
public static bool On = true;
public override bool CompileTimeValidate(MethodBase method)