Skip to content

Instantly share code, notes, and snippets.

@adilmughal
adilmughal / CSharp6NewFeatures
Last active Jun 28, 2016
C# 6 new features
View CSharp6NewFeatures
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static System.Console;
namespace PlayingWithCSharp6
{
class Program
{
@adilmughal
adilmughal / gist:9798916
Created Mar 27, 2014
MVVM_ContactForm_WP_Model
View gist:9798916
public class Category : INotifyPropertyChanged
{
private string _title;
public event PropertyChangedEventHandler PropertyChanged;
public int Id { get; set; }
public string Title
{
@adilmughal
adilmughal / ContactPage.xaml
Last active Aug 29, 2015
MVVM_ContactForm_WP_View
View ContactPage.xaml
<phone:PhoneApplicationPage
x:Class="DemoMvvm.WP.View.ContactPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
@adilmughal
adilmughal / ContactPageViewModel.cs
Last active Aug 29, 2015
MVVM_ContactForm_WP_ViewModels
View ContactPageViewModel.cs
public class ContactPageViewModel : INotifyPropertyChanged
{
private readonly IContactRepository _contactRepository;
private readonly IValidator _requiredFieldValidator;
private ObservableCollection<Category> _categories;
private string _email;
@adilmughal
adilmughal / blog.web.config
Last active Apr 26, 2020 — forked from anonymous/blog.web.config
Web.config URL rewriting rules for hosting WordPress (PHP) on IIS
View blog.web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove html" stopProcessing="true">
<match url="(.*).html$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@adilmughal
adilmughal / GenericControlBinder
Created Oct 29, 2012
A generic method to bind data source with several asp.net control
View GenericControlBinder
//Solution 1
public void BindDataToControl<T>(BaseDataBoundControl control, IEnumerable<T> dataSource)
{
if (control == null)
throw new ArgumentNullException("control");
control.DataSource = dataSource;
control.DataBind();
}
@adilmughal
adilmughal / AndroidHttpClientUsage.java
Created Aug 29, 2012
Android Http Client Usage To Access JSON Service
View AndroidHttpClientUsage.java
DefaultHttpClient client = new DefaultHttpClient();
// http get request
HttpGet request = new HttpGet(EMPLOYEE_SERVICE_URI + evEmployeeId.getText());
// set the hedear to get the data in JSON formate
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
// get the response
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
// if entity contect lenght 0, means no employee exist in the system with these code
@adilmughal
adilmughal / AsyncTask-NetworkOnMainThreadException.java
Created Jul 15, 2012
This code snippet demostrates the usage of AsyncTask to perform HttpPut request asynchrously and avoiding NetworkOnMainThread exception in android
View AsyncTask-NetworkOnMainThreadException.java
package samples.android;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;