Skip to content

Instantly share code, notes, and snippets.

@adilmughal
adilmughal / blog.web.config
Last active September 14, 2023 17:56 — forked from anonymous/blog.web.config
Web.config URL rewriting rules for hosting WordPress (PHP) on IIS
<?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 / CSharp6NewFeatures
Last active June 28, 2016 08:58
C# 6 new features
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static System.Console;
namespace PlayingWithCSharp6
{
class Program
{
@adilmughal
adilmughal / GenericControlBinder
Created October 29, 2012 06:10
A generic method to bind data source with several asp.net control
//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 August 29, 2012 06:41
Android Http Client Usage To Access JSON Service
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 July 15, 2012 17:34
This code snippet demostrates the usage of AsyncTask to perform HttpPut request asynchrously and avoiding NetworkOnMainThread exception in android
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;
@adilmughal
adilmughal / gist:9798916
Created March 27, 2014 02:38
MVVM_ContactForm_WP_Model
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 August 29, 2015 13:57
MVVM_ContactForm_WP_View
<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 August 29, 2015 13:57
MVVM_ContactForm_WP_ViewModels
public class ContactPageViewModel : INotifyPropertyChanged
{
private readonly IContactRepository _contactRepository;
private readonly IValidator _requiredFieldValidator;
private ObservableCollection<Category> _categories;
private string _email;