Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
@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()))
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Defining Instantiatable Classes In AngularJS
</title>
</head>
<body>
.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);
}
};
}]);
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);
public abstract class HttpSession : IHttpSession
{
protected IKeyValueStore storage;
public virtual int UserId
{
get { return Get<int>("user_id"); }
set { storage["user_id"] = value; }
}
@mahizsas
mahizsas / Maybe.cs
Created September 26, 2013 09:37 — forked from rarous/Maybe.cs
using System;
using System.Collections.Generic;
using System.Linq;
public interface Maybe<T> { }
public class Nothing<T> : Maybe<T> { }
public class Just<T> : Maybe<T> {
public T Value { get; private set; }
public static class HtmlExtensions
{
public static IHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, Dictionary<string, IEnumerable<SelectListItem>> selectList)
{
/*
* <select name="tmodel">
* <optgroup title="Items">
* <option value="item">Item</option>
* </select>
*/
@mahizsas
mahizsas / state.js
Created October 17, 2013 14:27 — forked from joladev/state.js
angular.module('services', [])
.factory('State', function ($rootScope) {
'use strict';
var state;
var broadcast = function (state) {
$rootScope.$broadcast('State.Update', state);
};
var update = function (newState) {
public class PackageBinaryInspector : MarshalByRefObject
{
/// <summary>
/// Entry point to call from your code
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dllPath"></param>
/// <param name="errorReport"></param>
/// <returns></returns>
/// <remarks>
@mahizsas
mahizsas / Web.config
Created November 2, 2013 15:23 — forked from BennyM/Web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>