Verizon Droid 2.2 Update Cannot Stop Me Tue, 24 Aug 2010 10:49:38 -0400

So Verizon has recently pushed the Android 2.2 OS to the original Droid phones. In this update Verizon has crippled the new updates, mobile hotspot was one of the hottest features to be released in Froyo (2.2). However Verizon has allowed USB tethering for the data plan, however this does require an extra charge (of course).

However they have missed one key piece, DNS queries can still be routed through the connection. Once I have a processes hammered out I might post a how to on setting up a TCP over DNS instruction so that you can use your handicapped Froyo to route all of your internet use over DNS.

How Cool huh?

0 comments. More...
Replaying PCAP Dumps Thu, 11 Mar 2010 08:35:40 -0500

Step 1) Collect data.

tcpdump -w logPackets.pcap tcp port 53

Step 2) Statup virtual machine

Step 3) Copy logPackets.pcap to VM.

Step 4) tcpreplay-edit -i eth0 --enet-dmac <your mac address on physical node> logPackets.pcap

 

If your using an older copy tcpreplay or do not have tcpreplay-edit installed, then you can either use tcpprep to write a cache file to separate the client and server instances ... this will also be able to modify the destination mac address. Alternatively you can use macchanger and just change the mac address on your physical ethernet device. Either way works.

0 comments. More...
Erlang Trim Thu, 11 Feb 2010 13:30:13 -0500

This is a nice piece of code that I stumbled upon a few months ago while wanting to string the white space off the end of a string. Thanks go to Steve Davis for his contribution.


-module(trim).
-author('Steve Davis < steven · charles · davis ? gmail · com >').
-export([trim/1]).

trim(Bin) when is_binary(Bin) ->
    list_to_binary(trim(binary_to_list(Bin)));
trim(String) when is_list(String) ->
    String2 = lists:dropwhile(fun is_whitespace/1, String),
    lists:reverse(lists:dropwhile(fun is_whitespace/1, lists:reverse(String2))).

is_whitespace($\s) -> true;
is_whitespace($\t) -> true;
is_whitespace($\n) -> true;
is_whitespace($\r) -> true;
is_whitespace(_Else) -> false.

1 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).

14 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 =: