Skip to content
January 22, 2011 / dranaxum

Topology problem

Given a planar weighted graph in a metric space (X,d), does the ordering of the areas of the faces preserve (i.e. remains the same) for any continuous mapping f:(X,d)->(Y,d’) where (Y,d’) is some metric space?

November 20, 2010 / dranaxum

filter in Haskell vs filterING in C#

If you are both a Haskell and C# programmer then you should be familiar to the filter function in Haskell and the filtering functions in C# (Find,FindAll etc).

Example of filter in Haskell

-- the type of filter is : filter :: (a->Bool)->[a]->[a] which means that
-- filter takes a function as an argument and a list and aplies the function to all the elements of the list
-- when the function returns true then the element will be added to the resulting list.
findAllOddElements :: [Int] -> [Int]
findAllOddElements ls
  = filter odd ls

The same code which does the exact same thing in C# would look like this

List<int> findAllOddElements(List<int> a)
{
  return a.FindAll(
    delegate(int elem) {
      return elem%2==1;
    });
}

We can see that the two functions are very similar, both requiring a function passed as a parameter. However, internally, they work different because Haskell is a functional programming language.
Hence filter is defined like this:

filter:: (a->Bool) -> [a] -> [a]
filter f [] = []
filter f (l:ls)
  | f l = l : filter f ls
  | otherwise = filter f ls

There is a nicer way to define findAllOddElements in C# using Linq like this:

List<int> findAllOddElements(List<int> a)
{
  return a.Where(elem => elem%2==1).ToList();
}

Assuming the resulting list is not empty then the function Find in C# should be equivalent to the following function in Haskell:

findAllOddElements :: [Int] -> Int
findAllOddElements ls
  = head (filter odd ls) 

Of course you can use function composition and partial application:

findAllOddElements :: [Int] -> Int
findAllOddElements
  = head . (filter odd) 

Also we can rewrite the Find function in C# using the Where prototype:

int findAllOddElements(List<int> a)
{
  return a.Where(elem => elem%2==1).ToList()[0];
}

Hopefully you will find this post usefull!

November 20, 2010 / dranaxum

Using WinPcap in C# (Packet capture)

WinPcap is a very useful tool which can enables users to capture windows packets. On their website they offer a development pack but only for C/C++ programmers. So this is why I decided to write my own (simple) class for capturing packets in C# importing the wpcap.dll . Before showing the code, you must know that in order for your program to run as it should in Windows Vista/7 you must run it as administrator, otherwise it won’t even find the (network) devices.

In order to import the functions we must first define some structures:

        [StructLayout(LayoutKind.Sequential)]
        struct pcap_if
        {
            public IntPtr next;
            public string name; //name of device
            public string description; //description of device
            public pcap_addr addresses;
            public int flags;
        }

        [StructLayout(LayoutKind.Sequential)]
        struct pcap_addr
        {
            public IntPtr next;
            public IntPtr addr;
            public IntPtr netmask;
            public IntPtr broadaddr;
            public IntPtr dstaddr;
        }

        [StructLayout(LayoutKind.Sequential)]
        struct sockaddr
        {
            public Int16 sa_family;
            public string sa_data;
        }

        [StructLayout(LayoutKind.Sequential)]
        struct pcap_pkthdr
        {
            public timeval ts;
            public int caplen; //captured length
            public int len; //packet length
        }

        [StructLayout(LayoutKind.Sequential)]
        struct timeval
        {
            public int tv_sec;
            public int tv_usec;
        }

        //some credentials if we want to capture packets remotely
        //CAN BE VERY USEFUL!!
        [StructLayout(LayoutKind.Sequential)]
        struct pcap_rmtauth
        {
            public int type;
            public string username;
            public string password;
        };

Read more…

November 14, 2009 / dranaxum

FM Radio Player

I’m back with a new tool I’ve made. :)

FM Radio Player is a small application designed to play radio stations through plugins. This means any coder can extend the program with new radio stations.

Note: Recording works only on the stations which don’t require AAC+ codec.
You can find information about how to create a plugin in the readme.txt file.

Here are some key features of “FM Radio Player”:

· Add to startup
· View last ten songs/shows played
· Record radio station
· View information about songs (including lyrics, youtube link and itunes link)
· Pluginable
· Upload/Download plugins from a centralized server (you must create an account in order to upload)
· Song notification
· Auto update
· Tray icon
· Send feedback

Read more…

June 21, 2009 / dranaxum

Further details on TOI

There is much chance that the launch of TOI (aka Training for Olympiad in Informatics see main article here) will be postponed for Tuesday or Wednesday if we don’t finish the articles I considered to be vital. However, we are trying hard to launch it tomorrow. Anyhow, I guarantee it will be worth the wait!

Some insight on SOME articles we are currently writing or we’ve already finished: the Dijkstra algorithm, AVL Trees, Kruskal & Prim, Miller Rabin, Pollard rho, RMQ. The list of the articles goes on and on. :)

Hopefully this project will be a success because we’ve worked very hard on it until now. Many students, teachers and senior software developers from different parts of Romania contributed to its development.

June 20, 2009 / dranaxum

Training for Olympiad in Informatics

Hy there!! I had some problems with my ISP and because of this wordpress blogs would not load correctly and so I was deprived of writing here.

What’s up?

Some members of Hackpedia and I are working hard to launch by Monday, 22nd of June 2009, a section on the Hackpedia community entitled: Training for Olympiad in Informatics.

More details please..?

This project started in March 2009. Being one of its founders, through this project I wanted to help every participant in the Olympiad no matter if they are competing locally, regionally or nationally and internationally. We are building a complete set of articles which are helpful for the beginners in algorithms but also for those who want to expand their knowledge.

In addition, we will regularly public sets of problems for each level of the competition and also for each grades (9,10,11,12). One or two weeks after each problem was posted the staff will make a complete solution for it (implementation and text). If the user could benefit from the implementation in C/C++ we will write it this way, if not we will provide pseudo code.

Facing problems?

Yes, some. I hope Hackpedia will be up, again, shortly or we will have to postpone the launching. It went down last night. Moreover, in the launch day I don’t think all the articles will be done (6 or 7 will be for us to write in the future). Oh! All the content will be in Romanian. Maybe in the future we will translate some of it in English.

Later edit: Hackpedia is back online. :)

Conclusions?

Hopefully, this section will help some users become better in algorithms. :)

Will be back with updates when we launch!

January 31, 2009 / dranaxum

Generalized Array

Did you ever think about declaring a multi-dimensional array dynamically? If so, I have created a class in C++ just for this.

So the problem goes like this: let an array a of type T, declare an array with n dimensions where n was inputted by the user.

The key is to think about a tree.

Both the implementation and an example can be found here:
Generalized Array

January 23, 2009 / dranaxum

Braincode: Personalized Mass Mailer

As I promised, I am keeping you in touch with Braincode.
We created a new section (Brainshare) where we will put our work which does not have the same level of complexity as the work in the Products section.

The first program posted here, which I developed by the way, is named Personalized Mass Mailer and it’s built in C#. Here is the description:

Personalized Mass Mailer

Personalized Mass Mailer (PMM for short) is a software created with the purpose of one being able to send e-mails, personalized, to many people, without being needed to write to each and every one. In other words: although e-mail services offer one the option to send the same e-mail to various people at once, it doesn’t offer one the option to make it personalized, without the person to see all the addresses one has added to the CC or TO field but, PMM does all of this and more.

Main features:

  • Regular expressions so one can benefit from the full experience of e-mail personalization (see the readme file for more information on how to use it)
  • Add attachment files
  • SSL secure connection
  • HTML e-mail
  • Real-time status visualization of the e-mails which are to be sent.
  • Connect and sign in on the SMTP and test the connection (this is compulsory if one wants to send e-mails)

Note: Add a ; after each written e-mail in the Address textbox!

Download link:
Click here to download Personalized Mass Mailer

Please report any bug encountered!

Later edit: Download link updated. Braincode website is down.

January 8, 2009 / dranaxum

Braincode Website Released

…. it’s here!

After many struggles with writing content, developing software and organizing events … it’s here! Our work published in one single place… the Braincode Team Website.

Click here:  http://www.braincode.ro

December 31, 2008 / dranaxum

Braincode, BrainIT & Hackpedia

The BrainIT competition is over. Hope that on 5th of January 2009 we will begin sending the prizes throughout the country. Thanks to all our sponsors and parteners and especially to Programare.org and the Software Developers’ Association (Asociatia Programatorilor de Soft).

I am now looking forward to finishing some projects for Braincode and finally post the website with the help of my team. Although I will be very busy, I won’t forget about BrainIT and I hope Braincode will be able to organize a new edition most probably in the summer of 2009.

What about this blog? I will continue posting some news about Braincode projects and as for the research, tutorials and “mini tools”, please visit the Hackpedia Ethical Hacking and Programming Community where I am one of the administrators (you can use Google Translate on that site). I will think about keeping you up to date with the articles I write for Hackpedia. :)

PS: Glad to have Page Rank 3!

Follow

Get every new post delivered to your Inbox.