Re-attach an existing screen session Fri, 8 Oct 2010 23:31:19 -0400

Add this to the end of your ~/.bashrc and it will re-attach your screen session.

if [ "x$TERM" != "x" ]; then

        if [ "x$TERM" != "xdumb" ]; then

                if [ "x$TERM" != "xscreen" ]; then

                        screen -rx

                fi

        fi

fi

1 comments. More...
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?

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

  • About The Author
  • This is the definitive blog for the musings of Brian Smith. I've been a programmer / sys admin for most of my life. I don't have much to say, I work, I enjoy my family, and every once in awhile I'll dump a little something I want to keep track of here.

    Currently I am the CTO of DNS.com where we provide geolocation based authoritative DNS services for the masses. I also have been working on drafts that are submitted to the IETF to the dnsext working group.

    In the past I have been involved with organizing various user groups, including an off and on again 2600 group. Also I have been involved with the development of Seclude, an open source secure instant messaging platform as well as Sliker, a project that later developed into plasma for the KDE desktop environment.

    Additionally I am an avid home brewer making my own beer. Everything else should be below or to the left.

  • 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.

:= RSS =: