Convert a SID to String with Java

A security identifier (SID) is an unique identifier, commonly used in Microsoft’s systems. For example, it’s used to identify users within Windows, or, more generally, within an Active Directory.

The SID is a binary value, with a variable length, that can be also be represented as a string. This conversion is implemented by the function called ConvertSidToStringSid, provided by the library Advapi32.dll, available only in Windows.

Hence, if you need to perform this conversion, you can procede with one of these two paths:

  • Use Advapi32 (only in Windows)
  • Rewrite the conversion
Thus, it’s very useful to have that implementation in a particular language (in our case Java), to be used everywhere. I noticed that, after a research in Internet, all the implementations are wrong, despite they work in general. Therefore, I decided to write my own implementation, thoroughly tested to prove you its correctness.

Continue reading

Integrating PeerSim with Eclipse

PeerSim, if you don’t know it, is a famous P2P networks simulator, written in Java. You can find its home clicking this link.

Surely, when you are writing in Java, it’s convenient to use Eclipse. In this article I will talk about how to configure eclipse to work with PeerSim. I decide to write this article mainly because I’ve founded some articles that talk about this integration; but I disagree with their solutions.

Continue reading

Ruzzle Solver Algorithm

With the success of Ruzzle Solver, a lot of users have asked me to publish more informations about it. Some of them were interested to know more about it for an university exam. In this post, I will talk about some methods to realize this type of algorithms. Surely, in the future, I will talk more about its implementation.

The following tests have been executed with algorithms written in C, and with a MacBook Pro with an Intel Core i5 at 2.3 Ghz; with other implementation the results may obviously change, but I expect that the ratios between them will be the same.

Continue reading

Artificial Intelligence: Markov Decision Process

In AI, sometimes, you need to plan a sequence of action that lead you to your goal. In stochastic environment, in those situation where you can’t know the outcomes of your actions, a sequence of actions is not sufficient: you need a policy.

Markov Decision Process is a mathematical framework that helps to build a policy in a stochastic environment where you know the probabilities of certain outcomes.

In this post, I give you a breif introduction of Markov Decision Process. Then, I’ll show you my implementation, in python, of the most important algorithms that can help you to find policies in stocastic enviroments. You can fine a more detailed description of the Markov Decision Process in my my slides that I’ve used for a seminar at University.

Continue reading

Flickr Photostream and the Justified Gallery

A common problem, for people who create sites, is to create an elegant image gallery that manages the various sizes of images. Flickr and Google+ manage this situation in an excellent way, the purpose of this plugin is to give you the power of this solutions, with a new fast algorithm.

Some month ago, I wrote a WordPress plugin that shows a Flickr photostream with a justified grid. Now, I decided to do a more abstract plugin (jquery plugin) that can be used everywhere!

See all the documentation in its project page. Or download it from github.

Miro Rubix comes back!

Hi! I just put online again the Miro Rubix game for PC and for PSP! A simple puzzle inspired by the famous game called Rubik’s Cube. The puzzle starts with two equal pictures where only the left one is mixed in various boxes. Moving the columns and the rows of the left one, you just have to form the picture on the right. The game comes with few puzzles. Some puzzles are classic, they contains only boxes with few colors; the other was created using various photos. But, you can create your own puzzle with your own photos!

Continue reading

Flickr Photostream

My first WordPress Plugin has just been released!
Plugin that allows you to show your Flickr Photostream in your blog. Awesome thumbnails disposition with a justified grid, with a Javascript algorithm, for a fast redraw. Various settings to configure the height of the rows and the behaviour of the last. You can show photos with a lightbox, or with a link to Flickr. You can configure the number of photos per page, then, you can navigate between various pages. You can configure the plugin to create fixed height rows or to create rows where the height depends on the images. The plugin chooses the right resolution for the image, using the Flickr size suffixes.

See it in the official page.

Network Time Protocol request in C#

I’m writing an application in C# that needs to know if the system time is not fake (only if the network is on). For this reason, I make a class that retrieves the time from a NTP server. The class is written to prevent that the same servers are called too often using a simple circular array. For the data returned by the servers, I invite you to see the RFC-2030.

Continue reading