Announcing DNSQuery Mon, 30 Nov 2009 22:04:42 -0500

Announcing a new DNS Query toolkit developed exclusively for the Android mobile platform. I have released it in relation to my company Comwired.com  The github presence can be found here http://github.com/pingwin/DNSQuery

0 comments. More...
Current Projects Wed, 25 Nov 2009 16:16:44 -0500

Currently am working on a number of DNS specific applications, hopefully a couple I can release.

The first being an IO event handler in C, sorta like libevent but without the threading issues, also can discover interfaces for udp handling. Will be helpful for a league of users.

The second project is the next generation of an Android application for testing DNS resolution against a configurable list of resolvers. Will later evolve into being able to run predefined lists of queries and checking responses, sorta like a typical monitoring setup (read nagios) but not as automated.

0 comments. More...
Being Away Thu, 3 Sep 2009 12:58:07 -0400

Sorry for the emptiness, I have been quite busy lately. Having relocated the family to Berea, Kentucky has been very taxing on my time and energy. I have some cool stuff I'm working on in erlang and I hopw to be able to make a post about that soon. As well as maybe a C network event driven library for TCP/UDP over IPv4 and IPv6 soon.

0 comments. More...
Getting Around ODBC slow connection pooling in Erlang Mon, 10 Aug 2009 10:32:03 -0400

If your like me you use SQL quite a bit, or least for some form of data source. One of the most portable methods for SQL interfacing is to use some form of abstraction, this adds portability as well as some support (sometimes). In this case I'm using Erlang to query a bunch of data out of a database and I want to do this very very quickly and efficiently

I've read only that ODBC v3 is supposed to support connection pooling by default, however on my PC (ubuntu hardy) is slow as heck and has a long latency time for initializing connections. However I was able to come up with a way around this by creating a process that does nothing but SQL functions. The below example should be all you need to start using this yourself.


-module(fetcher).
-author("Brian Smith").
-export([start, loop0/0, loop0/1, query/1]).

-define(DSN, "dsn=myodbc3").

start() ->
    register(fetcher_pid, spawn(?MODULE, loop0, [])).

loop0() ->
    {ok, DbConn} = odbc:connect(?DSN, []),
    loop0(DbConn).
loop0(DbConn) ->
    receive
        {sql, From, SqlStmt} ->
             From ! odbc:sql_query(DbConn, SqlStmt),
             loop0(DbConn);
        quit ->
             odbc:disconnect(DbConn),
             quit
    end.

query(SqlStmt) ->
   fetcher_pid ! {sql, self(), SqlStmt},
   receive
        _Results ->
                 _Results
   end.

To use you just need to run fetcher:start().. I'm still trying to figure out how to block the pid for receiving SQL queries until odbc:connect() is complete, so any ideas on this is appreciated.

1 comments. More...
DJB2 String Hashing Algorithm Implemented in Erlang Wed, 29 Jul 2009 15:53:45 -0400

Erlang is a very interesting functional programming language that has been receiving a fair amount of attention lately. So I've been playing with it off and on as my little fun project for educating myself. So to give back here is a simple DJB2 hashing algorithm implemented in Erlang.

Something I have had problems with before when implementing DJB2 in those languages (such as Python) is the native infinite precision integers of those languages. However by bitwise AND logic the result of the hash against the maximum value of a C unsigned long negates that by truncating the result buffer so we remain using the proper number of bits for the hashing.


-module(djb2).
-author('Brian Smith http://www.modernninja.com/').
-export([hash/1, djb2/2]).

-define(INIT_HASH, 5381).

hash(String) -> djb2(String, ?INIT_HASH).

djb2([], Hash) -> Hash;
djb2([Head|Rest], Hash) -> djb2(Rest, (((Hash bsl 5) + Hash) + Head) band 16#FFFFFFFF).

10 comments. More...
  • Disclaimer
  • The ideas and opinions expressed here are mine.
  • I'm a Linux and BSD user, and lean heavily toward the use of OSS vs certain other commercial solutions.

View the Ninja's profile on LinkedIn

:= RSS =: