Author Archives: Ferhat

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.

Posted in C# | Tagged , , , , , , , , , , | Leave a comment

GZip compression and decompression in C#

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

Posted in C# | Tagged , , , , , , , , , , , | Leave a comment

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 [...]

Posted in Bash, JavaScript | Tagged , , , , , , , , , , | Leave a comment

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#.

Posted in C# | Tagged , , , , , , , , , , | Leave a comment

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 …

Posted in C# | Tagged , , , , , , , , | Leave a comment

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.

Posted in Objective-C | Tagged , , , , , , , | Leave a comment

Custom prolog and epilog for a function in C++

Traditionally, the compiler is responsible for creating the prolog and epilog of a function. However, custom prolog and epilog code can be written if a function has been declared with the naked attribute. The snippet below demonstrates a naked function with custom prolog and epilog code. __declspec(naked) void foo(){ // Prolog __asm { push ebp [...]

Posted in Assembler, C++ | Tagged , , , , , , , , , , , , , , | Leave a comment

Hooking with the Microsoft Detours library in C++

The DLL Injection example described how to inject a DLL into an existing process. The snippets below demonstrate a combination of hooking and DLL injection in C++ with the Microsoft Detours library. Quote: In computer programming, the term hooking covers a range of techniques used to alter or augment the behavior of an operating system, [...]

Posted in C++ | Tagged , , , , , , , , , , , , , , , , | 5 Comments

Assembling with nasm and disassembling with ndisasm

The following commands demonstrate assembling with nasm and disassembling with ndisasm. $ cat example.s mov eax,0 test eax,eax $ nasm example.s $ ndisasm example 00000000 66B800000000 mov eax,0×0 00000006 6685C0 test eax,eax The first column of the disassembly contains the file offset, the second column contains the opcodes and the third contains the assembly instructions. [...]

Posted in Assembler, Bash | Tagged , , , , , , | Leave a comment

Basic client/server communication in C++ using the RakNet networking engine

Quote: RakNet is a cross-platform C++ and C# game networking engine. It is designed to be a high performance, easy to integrate, and complete solution for games and other applications. The snippets below demonstrate basic client/server communication using the RakNet library.

Posted in C++ | Tagged , , , , , , , , , , , | Leave a comment