Mar 18 2009

how to count connections on windows command line

Published by jfrank under Uncategorized

At work I am troubleshooting apache/tomcat/coldfusion/magnolia stack on windows. It is the most fun thing you can imagine. I was messing with apache’s configuration on mod_proxy_balancer and I needed to a way to test if my settings were having the desired effect.

I ran into a *nix shell script that did this, but not one for windows. This is super simple way to count connections against your localhost’s port 80, web server. It shows established and waiting connections.

Save this as a  .bat file and it will output them. It could be optimized in a number of ways, but who cares!


echo port 80:
netstat -a -n | find "TCP 127.0.0.1:80 " | find /C "ESTAB"
netstat -a -n | find "TCP 127.0.0.1:80 " | find /C "TIME_WAIT"

No responses yet

Jan 26 2009

util vs utils

Published by jfrank under open source

Dear open source software community,

Utilities are an important part of programming packages. It is commonly held that a utility class be one with static methods; the association that they may hold may be as simple as the type they operate on. 

A utility for manipulating strings may be called StringUtil or StringUtils. There is no consensus on this in the community.

If you hold that each method in the class IS a utility, you would probably assume the class should be named StringUtils. (like apache lucene, apache commons, spring)

If you hold that the class itself is the utility, bound together by its common association. Each method is simply that, a method in the utility that operates on strings, you would probably assume the class should be named StringUtil. (like apache lucene, apache poi or jetty)

Thats right, in lucene they can’t even decide within the same project…

They have packages named util and utils, and utilities name SUBJECTutil and SUBJECTutils.

Kind of like my codebase at work… As soon as you decide.. can you let me know?

- Joshua

Update: At my work developer poll ”util” has it. Three to one with one abstaining.

 

Util 3 Utils 1 Abstain 1

One response so far

Jan 04 2009

my router has a default editor

Published by jfrank under home network

My home network gateway is a busybox (linux) based openWRT router running on linksys wrt54g hardware. I’ve been playing with its many built in and package based features, via ssh and a web based portal. For my next version I think I can dump the web based portal and go strait for the pure ssh only distribution.

My router is actually not a router at all anymore, it is an embedded computer with a wireless adapter (or two?) and a fully configurable switch, set up in client mode, using its wireless adapter to search for open wifi nodes and connect. Then it nats up a wired network (which my 800 foot condo has 14 ports) for the rest of my computers.

I realized just how cool it was when I was adding a crontab entry to do connection detection and reconnect and it opened up vi. I don’t get vi, and don’t care to understand it. I had to go look up how to exit it. I’m not ashamed to say so, its a horrible, horrible invention. Ok so not a horrible invention, but like the telegraph it has served its purpose. Can we move on?

So I cracked open the global profile in zile (light emacs clone) and changed the default editor.

That is when I realized, this is cool. I have not one, but multiple editors on my router. Other packages that are available are traffic shaping, upnp, various kinds of vpn, torrent clients among other things.

Next I am going to move on to my home backup/file server/torrent machine which will probably be an openwrt box as well. This time its running on a 1 watt solid state linksys NSLU2, spinning up a hard drive when I want to stream or backup something, but mostly relying on a large usb flash drive for torrenting. The NSLU2 and the router combined will be a super low power ‘always on’ computer for my home. Yay!

No responses yet

Dec 02 2008

a groovy google calendar

Published by jfrank under groovy

I pushed some buttons and opened up part of my svn repository to share the code from my earlier example:

https://www.joshuafrankamp.com/svn/incubator/simpleGroovyCalendar/src/

I read up on groovy’s site, about google data support but I actually couldn’t find the referenced code anywhere… I’d like to learn more about ‘use’ and other aop/mixin techniques.

No responses yet

Nov 30 2008

svnant 1.2.1 released

Published by jfrank under svnant

I fixed a few bugs in this release. One was dealing with remote info requests against files. A couple others were from updated subversion 1.5, and new svnant dependencies. I added a cleanup task, contributed to Oleg Byelkin.  Writing the tests for that was a little bit of a trick due to the fact that cleanup (in order to be succesful) needs to have a messed up working copy… so I settled for writing a lock file to the .svn/ and calling it succesful if it removed it.

svnant-1.2.1.zip

No responses yet

Nov 29 2008

groovy code needs viagra (it keeps shrinking)

Published by jfrank under groovy

The other day I was talking to some coworkers about a groovy method that I had refactored. It was one that I had pulled the guts out because I needed two forms of the same data. So I added getDaySizeList which contains most of the logic, but I still needed to get a rollup sum from getDuration for another part of the application.

I knew groovy collections supported an “each” function that takes a closure. Groovy syntax allows for omission of parentheses when there is at least one argument, so it can look like this:

myCollection.each{ closure } not myCollection.each({ closure })

it would also allow you do things like:

myCollection.add object  (look no parens!)

which creeps me out right now, so I’m not going to think about it.

I digress… Here is my method, that I thought was a short implementation:

int getDuration(){
	int hours = 0;
	getDaySizeList().each{dayHourMap -> hours += dayHourMap.hours}
	return hours
}

I was excited, no visible loop, just something to do “each” for the members of the collection, drilling down into the hours property of the map in each collection item, summing them into a waiting “hours” int, then returning it. Slick.

Barney then replied that I should have (duh) used the sum closure-taking builtin in groovy… which turns the above method into this:

int getDuration(){
	return getDaySizeList().sum{it.hours}
}

“it” is the default single argument to the closure.  You can see I only kept the end of the closure, to the right of the former +=.

Magic.

One response so far

Nov 28 2008

Vacation ala Google Calendar

Published by jfrank under groovy

I’ve been building a railo-hibernate-groovy fto (flex time off) vacation app in my “for fun” time at work and home. The goal is to get an application that can replace the arcane paper based system that my company currently uses.

I have most of the front end of the app done, but I needed a good calendar view to show the events. I decided I would use google calendars, so I wrote a little calender wrapper. Here is a snippet of the test driver class. GoogleCalendar is mine, the *Entry items are part of the api.

This is groovy code, not java…

//omitting calendar name assumes the default users calendar
GoogleCalendar gc1 = new GoogleCalendar(username,password)
// adds an event 3 days in duration starting 3 days from now, with title and desc here
CalendarEventEntry entry = gc1.insertEvent("DELETE ME FTO","FTO",new Date()+3,new Date()+6)
gc1.deleteEvent(entry)

println("List of users owned calendars:")
for (CalendarEntry cal : gc1.getCalendars()) {
	println("\t" + cal.getTitle().getPlainText());
}

//this demonstrates the mixed constructor that is allowed in the groovy wrapper.
//i define a calendar name, and it looks it up and sets that as the calendar to work with
GoogleCalendar gc2 = new GoogleCalendar(username,password,"Web Services Team")
//adds an event 3 days in duration starting 2 days from now, with title and desc here on the WST calendar
gc2.insertEvent("Joshua FTO","FTO",new Date()+2,new Date()+5)

Such fun.

This will allow me to have a nice visual display of everyone’s scheduled vacation calendar, and have an easy way to share it with other apps/users such as our wiki.

No responses yet

Nov 28 2008

python packaging

Published by jfrank under python

Python packaging is a pain in the ass. There are some tools to make it easy, so easy in fact that it becomes even worse…

easy_install is the easiest thing since sliced bread. What does it do? Everything. Its so magic it probably installs itself recursively just for fun.

You want a package?

Ok just type this: easy_install sqlalchemy (for the awesome ORM package for python)

It magically goes and finds sqlalchemy, and installs it INTO your system python installed path.

Why is the standard assumption that if I want to use a python package that is say a dependency for my project, that I want to INSTALL IT INTO PYTHON running on my system?

What kind of crazy idea is this? It causes all kinds of issues. The first and most obvious is: What If I have two programs that expect different versions of a given package? Since the packages are installed in to the runtime and not my app, you have to know about this issue and work around it.

If packages were managed the java way, the assumption would be that I want to install the package in the app that I am working on, not into /systemjdk/extensions/somePackage

The only argument FOR doing it this way that I can think of is saving disk space. Disk space is cheap.

/rant.

Ok so honestly, can anyone tell me why this is?

2 responses so far

Aug 12 2008

svnant for subversion 1.5

Published by jfrank under svnant

One day at work I saw that tortoiseSVN had an update, and so I blindly installed it and went about my business. It then began poisoning all the shared working copies that we use at work, with subversion 1.5 format, thereby causing all other svn clients to report “This client is too old to work with working copy …” Long story short, once you start its hard to stop.

I thought ok no problem, I’ll help all of my co workers upgrade and that will be that. Subversion 1.5 is a release after all, surely all the tools that go with it are released too! That turned out to be mostly true, but not for a specific tool that we use quite a bit here, svnant. There was no svnant bound against the latest dependencies.

I found an email by the guy who runs the show mark that said he wanted someone to take on the project. So I volunteered.

I became the svnant guy just like that. I made a simple release so if you are just dying to get svnant working with subversion 1.5 working copies, download the release candidate.

7 responses so far

Jul 16 2008

launchy hot key broken

Published by jfrank under resources

I use Launchy for Windows, it is a command line launcher that allows the user to forget the start menu is even there. Which is a dream come true. It is also customizable and generally useful.

I somehow broke my launch key setting by resetting it to an invalid combination. Alt-Space is the default, and I had set it to something that simply didn’t bring up the Launchy window. This is a problem with Launchy because there is no ‘official’ way to reset the hotkey without first bringing up the launchy window.

In short, if you ever have this problem, instead of attempting a reinstall, which doesn’t work just do this:

How To Fix Launchy’s Hot Key:

  1. Kill Launchy.exe from the task manager.
  2. Open launchy.ini in your users application data folder.
    For windows XP users, this is:
    C:\Documents and Settings\yourusernamehere\Application Data\Launchy\Launchy.ini
  3. Add or replace these ini style keys:
    [GenOps]
    hotkeyAction=32
    hotkeyModifier=134217728
  4. Save the file, and restart Launchy.exe
  5. Use Alt-Space (which is what you just reset the hotkey combo to be)

2 responses so far

Next »