Using Parallel LINQ in C#

The snippets below illustrate Parallel LINQ in C# by crawling a web page in parallel. The Crawler class is responsible for crawling a web page (only one level deep) and returning a list of documents. The Document class represents an HTML document.

Read More »

→ Continue Reading

GZip compression and decompression in C#

The snippets below illustrate GZip compression and decompression using the GZipStream classes.

Read More »

→ Continue Reading

Using PhantomJS to request a web page

PhantomJS is a very nice headless browser which uses the WebKit browser engine. It can be used for many purposes. However, I’m going to illustrate PhantomJS by performing a Bing search query and also executing JavaScript code on the page. Libraries such as jQuery can be injected into the page to perform all kinds of operations.

Read More »

→ Continue Reading

Parsing (X)HTML into a DOM tree in C#

As a quick alternative to the Html Agility Pack, HTML can be parsed into a DOM tree using the built-in XmlDocument class. The following snippets illustrate HTML parsing in C#.

Read More »

→ Continue Reading

Alphanumeric/natural sorting in C# using IComparer

These snippets illustrate the natural sorting order. Suppose you’re using numbers within your file names. For example:

  • file1.png
  • file2.png
  • file10.png
  • file11.png
  • file12.png

You’d expect to see them in the above order. However,  they are (by default) sorted as follows.

  • file1.png
  • file10.png
  • file11.png
  • file12.png
  • file2.png

Read More »

→ Continue Reading

(JavaScript) Augment Storage Prototype with getObject, setObject

Provides getter/setter functionality for objects in local storage. Utilizes JSON.stringify and JSON.parse.

Read More »

→ Continue Reading

(C#) C# LINQ & Extension method continued

Also extended C# LINQ and Extension method (simple) to include the last (MAX) Date Created property, added a new Folder class (model) with properties and included them in a List. Also, amended the LINQ statement to get the MAX(Date Created) .

Read More »

→ Continue Reading

Play a movie in fullscreen (Objective-C)

Hi,

In reply to http://snipd.net/objective-c-play-a-video-in-full-screen#comment-290 . The following snippets show how to play a movie in fullscreen.

Read More »

→ Continue Reading

(Java) Operational System Validator

Check which operating system the program is running. The program explains itself.

Read More »

→ Continue Reading

(PHP) PHP Miles to Latitude and Miles to Longitude Converter

There are tons of functions out there to calculate the distance between two points, but what if you know one point and want to calculate the latitude (“vertical”) or longitude (“horizontal”) equivalent of a fixed distance, in miles? An example application would be in generating a minimum & maximum latitude and longitude bounding box around an area to limit the results of a database query that uses distance from a fixed point.

Read More »

→ Continue Reading