(C++) Gaussian Elimination

Numerical Methods application for solving system of equation using Gaussian Elimination based on this Wikipedia article: http://en.wikipedia.org/wiki/Gaussian_elimination

Read More »

→ Continue Reading

(C#) Pull Image into Byte Array from a URL

This snippet pulls down an image from a URL into a byte[]. From there you can re-size or save.

Don’t forget the necessary try – catch.

Read More »

→ Continue Reading

(JavaScript) Stack implementation

Simple stack implementation for JS

Read More »

→ Continue Reading

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.

Read More »

→ Continue Reading

DLL injection in C++

DLL injection in Windows can be used to inject a DLL into a process and to take over/extend functionality. For example, the distribution platform Steam uses DLL injection for the game overlay.

Steam game overlay

Read More »

→ Continue Reading

(jQuery) Get Latitude and Longitude using jQuery and Googles Geo Coding Service

Nice ajax function to grab the latitude and longitude of an address or postcode. Don’t forget your google key and address formatting.

Read More »

→ Continue Reading

(C++) Nasdaq IPOs Scrape

This is a C++ program that scrapes IPO data from Nasdaq.com using libcurl for downloading the data and htmlcxx for parsing the html code.

Read More »

→ Continue Reading

Primality testing with Fermat’s little theorem and Miller-Rabin in C#

Prime numbers have many applications. For example, in cryptography. The RSA algorithm for public-key cryptography uses large prime numbers for generating keys. Quote:

The RSA algorithm works as follows: take two large primes, p and q, and compute their product n = pq; n is called the modulus. Choose a number, e, less than n and relatively prime to (p-1)(q-1), which means e and (p-1)(q-1) have no common factors except 1. Find another number d such that (ed – 1) is divisible by (p-1)(q-1). The values e and d are called the public and private exponents, respectively. The public key is the pair (n, e); the private key is (n, d). The factors p and q may be destroyed or kept with the private key.

Large prime numbers can be found with a primality test. A primality test will determine whether a number is prime or composite. The C# console application below is able to check whether a supplied number is prime or composite and able to randomly produce large prime numbers. Two methods for primality testing are used. Namely, Fermat’s little theorem for pseudo primality testing and the Miller-Rabin primality test.

The primality test based on Fermat’s little theorem is probabilistic and will produce errors for numbers such as 341 and 645 whereas the Miller-Rabin primality test is deterministic.

The theory in chapter 31.8 of Introduction to Algorithms has been used for the implementation. Thus, major credits to Thomas H. Cormen, Clifford Stein, Ronald L. Rivest and Charles E. Leiserson.

Read More »

→ Continue Reading

(JavaScript) Observer-Pattern in JavaScript

Could be improved by passing an event instead of a simple payload.

Read More »

→ Continue Reading

(C) Dijkstra’s Shortest Path algorithm

Its Dijkstra’s Shortest Path algorithm written in C. Reads from a file the nodes and the connected edges and implements Dijkstra’s algorithm. I am uploading for your comments in my code. Thank you.

Files content should be in the format:
n N
startNode endNode distance
startNode endNode distance
.
.
.
startNode endNode distance

where n is the total number of Nodes and N is the total number of Acnes.

Read More »

→ Continue Reading