September 26, 2008

Splitting MP3s in Perl

Drew Stephens @ 1:35 pm — Tags: , ,

I listen to some podcasts daily that have annoying messages in them that never change. With a bit of research, I came across the MP3::Splitter module on CPAN which has somewhat confusing documentation but provides a method mp3split() that pulls specified pieces of a file. You provide mp3split() with the input MP3 filename, options as a hash and then any number of arrays that specify which portions of the MP3 to copy into new files. The easiest syntax for specifying a portion is to pass the start position and the length of the desired chunk, both in seconds. From the command line, I did this:

perl -MMP3::Splitter -e "mp3split('foo.mp3', {}, [20,25], [95,600], [950,INF])"

which creates three new MP3 files, 01_foo.mp3, 02_foo.mp3 and 03_foo.mp3. These can then be joined to create a new MP3:

cat 01_foo.mp3 > new.mp3
cat 02_foo.mp3 >> new.mp3
cat 03_foo.mp3 >> new.mp3

Which will leave you with new.mp3 that is a concatenation of the three pieces. Using cat to join them means the resulting file will probably have some artifacts at the join points but that’s not a problem for my use. If it is, you can use something like mp3join to properly join the files.

September 22, 2008

Code Golf: Saving Time

Drew Stephens @ 12:57 am — Tags: , ,

After a new challenge, Saving Time was posted a few weeks ago, I’m finally getting to another round of Code Golf. As usual, my preferred language is Perl; don’t read below if you don’t want hints!

(more…)

September 16, 2008

United States Federal Lands

Drew Stephens @ 11:27 pm — Tags: ,

Map

I gave this post a vague title because the control of federal lands, such as National Parks, National Memorials and National Forests, is a surprisingly complicated issue. Tracts controlled by the federal government arise from disparate processes and are controlled by a number of different agencies including the National Park Service, Bureau of Land Management and the United States Forest Service.

Agencies

National Park Service

The most well-known federal land management agency is the National Park Service, housed under the Department of the Interior. The NPS was created in 1916 to organize management of the fledgling system of parks that began with the designation of Yellowstone National Park in 1862.

Bureau of Land Management

Originally created in 1812 as the General Land Office under the Department of the Treasury the Bureau of Land Management became part of the Department of the Interior after merging with the United States Grazing Service. Unlike the National Park Service, the BLM does not exist as an agency purely to protect the lands that it controls; the BLM issues permits for grazing, logging and mineral collection on many of the lands that they control.

U.S. Forest Service

The United States Forest Service is responsible for the management of National Grasslands and National Forests, controlling access to grazing, logging and mineral collection on lands under their control in addition to allowing recreation on these lands.

U.S. Fish and Wildlife Service

The United States Fish and Wildlife Service is the caretaker of the country’s National Wildlife Refuges and National Fish Hatcheries.

Lands

National Park

Beginning with the creation of Yellowstone in 1862 by congress National Parks are areas created by the legislative branch as natural preserves for recreational use by citizens of the country. National Parks do not allow for logging, mineral extraction or any other exploitation of the land. These lands are generally the most visited areas controlled by the federal government, receive the most funding for improvements to support visitors to the park and the most legislative attention. National Parks are all manage under the National Park Service.

National Monument

As a DC native, the term National Monument evokes thoughts of man made symbol commemorating a person or event. In terms of U.S. public lands, however, a national monument is a tract set aside by executive order without the approval of Congress. The land for a national monument may be that which the federal government already controls or something that is given to the government by an individual or state. The presidential power to create such lands was granted by the Antiquities Act of 1906 signed by Theodore Roosevelt and first used to protect Devil’s Tower in Northeastern Wyoming. The intent of the act is to allow the president to afford protection to natural resources of the United States more quickly than an act of Congress is capable. National monuments are intended to be less expansive than national parks, generally protecting a single natural feature. Management of national monuments falls to either the National Park Service or the Bureau of Land Management.

National Memorial

Now this is what should make me think of the Lincoln and Jefferson Memorials in Washington. National Memorials are protected areas established by the legislative branch to commemorate a historic person or event. Though most National Memorials are administered by the National Park Service, some, such as the Benjamin Franklin National Memorial are overseen by another organization and considered an affiliated area of the NPS.

National Wilderness Area

A National Wilderness Area is defined within land that is already under federal control by the Wilderness Act of 1964 as an area in which commercial activities are forbidden and human activity is limited to non-motorized recreation and non-invasive activities such as scientific study. NWAs exist under the cooperative purview of all four land management agencies, the National Park Service, Bureau of Land Management, U.S. Forest Service and the U.S. Fish & Wildlife Service.

National Forest and Grassland

Managed by the Forest Service, a division of the Department of Agriculture, National Forests are unlike their protected brethren in that commercial exploitation of their resources is allowed with permits given for grazing, logging and mineral extraction. Lands administered by the Forest Service my also be licensed for commercial recreation such as ski resorts. National Forests are created by executive order as granted by the Land Revision Act of 1891 and National Grasslands by the Bankhead-Jones Farm Tenant Act.

National Recreation Area

Until 1963, National Recreation Areas were created by executive order but a change in policy means that all Areas designated thereafter are by legislative action. National Recreation Areas can be managed by the National Park Service, Bureau of Land Management or the U.S. Forest Service. NRAs are usually created to encourage water sports on lakes created by the damming of rivers.

National Wildlife Refuge

Originally defined by the National Wildlife Refuge System Administration Act of 1966 a National Wildlife Refuges exist, unsurprisingly, as habitats for specific or groups of species. They are created by congressional legislation and administrated by the U.S. Fish and Wildlife Service.

National Seashore

Usually controlled by the National Park Service, National Seashores are protected areas that are similar to both NRA’s and National Parks. Most of the areas contained within a National Seashore is available for recreation, often including vehicular offroading trails.

National Historical Park

National Historical Parks or National Historic Sites are historically significant structures or areas governed by the National Park Service. These areas were at one time declared by the Secretary of the Interior, but in modern times by acts of congress.

Parkway

Parkways are roads controlled by the National Park Service and are often scenic roads through federally controlled lands, such as Blue Ridge and Rock Creek parkways. Others, such as a significant portion of the Baltimore-Washington Parkway, are not maintained by the NPS but state and local agencies instead.

References

16 USC - Conservation
43 USC - Public Lands

September 12, 2008

Rick Ross’ Financial Success

Drew Stephens @ 2:28 am — Tags: ,

Since he was mentioned on The Daily Show a few weeks ago, Rick Ross has quickly become my favorite rapper. The king of repetition, Ross hails from Miami and makes much of his activities trafficking drugs despite allegations that he worked for the man during part of his life. Like many rappers, Rick Ross talks a lot about his expensive cars and I noticed a trend in the vehicles of which he spoke.

In his first album, Port of Miami, Ross’ makes a number of references to his white on white BMW 745i such as this line from the hit single Hustlin’:

Who tha fuck you think ya fuckin with? I’m tha fuckin boss
745 white on white, thats fuckin Ross

To be sure, any BMW 7 series is a fine car, but the 745i is the base model of the line. Is Rick Ross a poor rapper? Not too fast, in the song White House, he mentions a Rolls Royce Phantom:

we in the white house
big phantom on the lawn getting wiped down

Is this song a fantasy about occupying the White House proper, or is it simply hyperbole about his mansion, with a nod to cocaine usage and trade? Given the previous mention of a 745i, I can only assume that the Phantom was but a fantasy for Rick Ross in 2006.

Times change. In 2008, Rick Ross released the album Trilla and it sounds like he’s had a significant upgrade. The song Luxury Tax, makes specific mention of a 760, the top of the line BMW 7 Series:

Got my whole arm rocked.
Keep the 760 double parked in the wrong spot.

The cover of the album also features the rapper in the back seat of a Maybach, the sole car from the eponymous ultra-luxury brand owned by Mercedes. The album also includes a song Maybach Music, Ross says that he has 20 whips, one of which is a Maserati.

September 9, 2008

Shell Command Substitution

Drew Stephens @ 8:08 pm — Tags: ,

The other day I wanted to diff a pair of files on two different hosts, stg1 and stg2. Normally, I would do so by copying on of the files to the other host, or grabbing them both onto my workstation with scp; “there must be a better way,” I thought.

Enter command substitution, a process by which you use the output from an executed command as the input to another. Many people have used this in a simple manner such as ls /usr/src/linux-`uname -r`which takes the output of uname -r, namely the kernel release you’re running, and uses that to flesh out the ls command. There is a more complicated form, however, that I use for diffing remote files. In the aforementioned example, I used the following command to diff the files:

vimdiff <(ssh stg1 cat /etc/rc.d/init.d/httpd) <(ssh stg2 cat /etc/rc.d/init.d/httpd)

Much like a subselect in MySQL, the cat commands are executed on the remote machine and then piped to vimdiff allowing for single command, no-file-copying diffs.

September 5, 2008

Speeding up SSH Logins in Ubuntu

Drew Stephens @ 1:23 pm — Tags: , ,

After getting access to some new machines, I noticed that SSHing too them was excruciatingly slow, taking 5-10 seconds to ask for a password and no faster using keys. I pulled open the global SSH config file, /etc/ssh/ssh_config on my Ubuntu machine and found a couple of GSSAPI things that were enabled by default:

GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes

The machines I was SSHing to don’t do GSSAPI, so every time I tried to connect my client had to wait a short timeout before trying other authentication methods. Since I don’t care about GSSAPI (few people use it), I simply set those options to no and now my SSH sessions start much more quickly.

September 3, 2008

No-Tech Hacking

Drew Stephens @ 3:45 am — Tags: ,

While looking through the audio from the last hope, I stumbled across Johnny Long’s talk entitle No-Tech Hacking. I saw this talk a couple of years ago at ShmooCon and re-watched it via the above Google Video link and it’s just as good as the first time. Anyone interested in any sort of security should watch this talk because it’s very interesting and very funny.

Powered by WordPress