This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class HttpSession : IHttpSession | |
{ | |
protected IKeyValueStore storage; | |
public virtual int UserId | |
{ | |
get { return Get<int>("user_id"); } | |
set { storage["user_id"] = value; } | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void GoogleGeoCode(string address, out double lat, out double lon) | |
{ | |
string url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" + address; | |
var req = (HttpWebRequest)WebRequest.Create(url); | |
var reader = new StreamReader(req.GetResponse().GetResponseStream()); | |
var body = reader.ReadToEnd(); | |
lat = double.Parse(Regex.Match(body, @"""lat\"" : ([\d\.]+)").Groups[1].Value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('ngInitial', ['$parse', function ($parse) { | |
return { | |
require: 'ngModel', | |
restrict: 'A', | |
link: function link(scope, element, attr, model) { | |
var val = attr.ngInitial || attr.value || element.text(); | |
$parse(attr.ngModel).assign(scope, val); | |
} | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="Demo"> | |
<head> | |
<meta charset="utf-8" /> | |
<title> | |
Defining Instantiatable Classes In AngularJS | |
</title> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class Program | |
{ | |
private static void Main() | |
{ | |
// runs the app as a console application if the command argument "-console" is used | |
if (WindowsServiceHelper.RunAsConsoleIfRequested<Service1>()) | |
return; | |
// uses "-install" and "-uninstall" to manage the service. | |
if (WindowsServiceHelper.ManageServiceIfRequested(Environment.GetCommandLineArgs())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Nancy.ModelBinding; | |
public class DynamicModelBinder : IModelBinder | |
{ | |
public object Bind(NancyContext context, Type modelType, object instance, BindingConfig configuration, params string[] blackList) | |
{ | |
var data = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace EntityExtensions { | |
public class FakeDbSet<T> : System.Data.Entity.IDbSet<T> where T : class { | |
private readonly List<T> list = new List<T>(); | |
public FakeDbSet() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chartData = from log in _contextProvider.Context.Logs | |
group log by new | |
{ | |
ApplicationName=log.Application.Name, | |
Year= SqlFunctions.DatePart("Year", log.Timestamp), | |
Month= SqlFunctions.DatePart("Month",log.Timestamp) | |
} | |
into logsPerApplication | |
select new | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = from order in context.Orders | |
group order by new { order.Customer , order.OrderDate } into ordersForCustomer | |
select | |
new | |
{ | |
Key1 = ordersForCustomer.Key.Customer, | |
Key2=ordersForCustomer.Key.OrderDate, | |
Count=ordersForCustomer.Count() | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
//Extra ignores to support WCF in ASP.NET MVC | |
routes.IgnoreRoute("{resource}.svc/{*pathInfo}"); | |
routes.IgnoreRoute("{resource}.svc"); | |
routes.MapRoute( | |
name: "Default", |