Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
public abstract class HttpSession : IHttpSession
{
protected IKeyValueStore storage;
public virtual int UserId
{
get { return Get<int>("user_id"); }
set { storage["user_id"] = value; }
}
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);
.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);
}
};
}]);
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Defining Instantiatable Classes In AngularJS
</title>
</head>
<body>
@mahizsas
mahizsas / Example
Created August 23, 2013 13:04 — forked from jgauffin/Example
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()))
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 =
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() {
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
{
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()
};
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",