Ahmad Masykur

Share your knowledge although one function!

About the author

Ahmad Masykur is a Software Architecture Engineer at PT. Freeport Indonesia Jakarta Indonesia.
In this blog, I share things of interest to me. Most topics are likely to be related to software development, but don't hold me to it.

Certificates



Awards


Powered by

Prayer Time

September 11, 2010
الفجر/Dawn 04:31:04
الشروق/Sunrise 05:48:05
الظهر/Noon 11:49:36
العصر/Afternoon 15:05:22
المغرب/Sunset 17:51:07
العشاء/Dusk 19:00:05
Jakarta  Indonesia
Prayer time widget created by
Ahmad Masykur

Page List

Validators


Ahmad Masykur

Updating Prayer Widget due to Previous IP to Geo Service was Unavailable

I was developed Prayer Time widget a month ago. I was used IP to geo service that not available anymore. This update using hostip.info service instead. The hostip.info service is not reliable enough for all IP world wide. Some IPs are not covered yet but more stable than previous service.

Here’s core of my code to retrieve geographic information from hostip.info.

WebClient webClient = new WebClient();
string responseString = null;
try
{
    responseString =
        webClient.DownloadString(string.Format("http://api.hostip.info/get_html.php?ip={0}&position=true",
                                               ipAddress));
}
catch (WebException)
{
    responseString = string.Empty;
}
catch (Exception)
{
    responseString = string.Empty;
}
Regex regex = new Regex("Country\\:\\s(?<Country>[A-Za-z0-9]+)\\s\\((?<CountryId>[A-Z]{2})\\)\\nCity\\:\\s(?<City>[A-Za-z0-9]+)\\nLatitude\\:\\s(?<Latitude>\\-?[0-9\\.]+)\\nLongitude\\:\\s(?<Longitude>\\-?[A-Za-z0-9\\.]+)");
if (!string.IsNullOrEmpty(responseString))
{
    Match m = regex.Match(responseString);
    if (m.Success)
    {
        city = m.Groups["City"].Value;
        country = m.Groups["Country"].Value;
        countryId = m.Groups["CountryId"].Value;
        longitude = m.Groups["Longitude"].Value;
        latitude = m.Groups["Latitude"].Value;
    }
}

The complate source code can be downloaded here.

I hope this update will be more reliable that previous version.


Categories: BlogEngine
Permalink | Comments (3) | Post RSSRSS comment feed

Prayer Time Widget for BlogEngine.NET 1.4.x

Prayer Time is time schedule for moslem prayer. This widget shows the daily prayer time based on user location. Thispicture below shows prayer time at January 11, 2009 in Jakarta. If you are from outside of Jakarta, the prayer time will automatically calculate base on your location.

image

I’m using prayer time algorithm from here and previous post here. This widget use Shafii and Muslim World League calculation except Indonesia and Malay use custom calculation.

Complete source code can be downloaded from here. The installation is very easy, follow installation steps below:

  1. Extract the zip file to widget folder of your BlogEngine.NET site
  2. Login as Administrator
  3. Goto buttom of page
  4. Select “Prayer Time” from available widgets in combo box as picture below.
  5. Click Add.
  6. You can also move the widget to another location by refreshing the browser and drag n drop “Prayer Time” widget to desired location.

image

 

I hope this widget be useful for moslem blogger.


Categories: BlogEngine
Permalink | Comments (15) | Post RSSRSS comment feed