Shelby
this picture that pat took is awesome.
I know this has been done dozens of times before, but it’s been a real headache for me lately. A full example of how to use IO::Socket::UNIX is not really available anywhere on the web. All of the socket info for perl seems to assume you’ve been doing socket programming in C for years, and theres very limited info on doing Unix Domain Sockets. it all seems to be about inet sockets. which, of course, relates a lot to Unix Sockets, but there are some differences.
okay, here is my working example. Its meant to be run twice, the first time it’s the server, the second time it’s the client.
#!/usr/bin/perluse strict; $|++;use IO::Socket;
my $socketfile = $ENV{HOME} . "/.sockettest";
if ( -S $socketfile ) { # client! my $client = IO::Socket::UNIX->new(Peer => $socketfile, Type => SOCK_STREAM ) or die $!; my $string = "this is some sent garbage.\n"; print $client $string; $client->flush; $client->close; exit;
} else { # server! unlink $socketfile; my $data; my $server = IO::Socket::UNIX->new(Local => $socketfile, Type => SOCK_STREAM, Listen => 32 ) or die $!; $server->autoflush(1); while ( my $connection = $server->accept() ) { my $data= <$connection>; print $data, $/;
sleep 5; }}
Mountain Man: Nature is fun.
David: Like boobs?
Mountain Man:But it can also be dangerous.
Michael Showalter: Like fire boobs?
With over 33,000 songs in my library, my iTunes share here at work is very popular. iTunes has a built in connection limit that people often complain to me about hitting. So this is why I started looking into running a duplicate share on my FreeBSD server.
first thing I did was set up nfs on my Mac OS X box to share to my mac, handily if you just write an /etc/exports file and reboot, the NFS server just starts. here’s my /etc/exports file:
/Volumes/Music -mapall=rex shaolin
/Volumes/Music is where my music is, rex is my user’s shortname, and shaolin is the machine hostname for my FreeBSD server that will want to mount the share.
then, on my FreeBSD box I put this in my /etc/fstab:
mogu:/Volumes/Music /music nfs ro,intr,noauto 0 0
intr is nice so that when nfs goes down my df commands don’t hang. I’ll probably take out the noauto once I figure out if this setup is working right.
after that I just did: mkdir /music ; mount /music , as root, of course.
all of this I did after I found this handy site:
Setting up an iTunes server in FreeBSD
This page was very helpful, but I found some of the info out of date and some dependancies broken. so here’s my rundown (read that page before continuing)
First, install daapd. it’s in /usr/ports/audio/daapd.
In the above instructions the info on daapd is correct, but I had many issues getting the port to build. The dependancies didn’t seem to work out of the box, the error it gave me lead me to build multimedia/mpeg4ip manually. do this:
# cd /usr/ports/multimedia/mpeg4ip-libmp4v2# make install clean# cd /usr/ports/multimedia/mpeg4ip# make install
then, it gets tedious. to get the mpeg4ip port to build, I had to edit some makefiles. I kept running that last command over and over, editing files as I went. The first errors were about mp4.h not found. this happened about 3 times; when it did, I noted from the error what directory it was in, then edited the Makefile in that directory and added
-I$(src_topdir)/lib/mp4v2
to the INCLUDES= line. for some reason this was omitted someplace. I’ll e-mail the maintainer, hopefully it’ll be fixed when you go to build the port.
After that I got some errors that were warnings treated as errors because -Wall was in the Makefile. The errors looked rather harmless, so I went into the directories in question and edited the Makefile to remove every instance of
-Wall
I think this only happened once.
The next batch of errors I had was some errors that said something along the lines of “undefined reference to `MP4IsIsmaCrypMediaTrack’”, those were solved by manually rebuilding mpeg4ip-libmp4v2, which you already did, because I mentioned it above.
After mpeg4ip was installed, I went and built daapd, which rebuilt a bunch of stuff on my machine in my xlibraries. most of these things were upgrades, so I had to rebuild them by hand using cd /usr/port/dir ; make deinstall ; make reinstall. I had to do this for at least 3 ports; including pango, gtk and glib. I also got an error from /usr/ports/x11-fonts/XFree86-4-fontScalable that required me to build the port manually, that is, after manually installing a new version of make and imake. I did both of these with
portupgrade imake make
. Hopefully anyone reading this won’t have ports as old as mine and won’t have issues with these.
once daapd is installed you’ll want to put daapd_enable=”YES” in your /etc/rc.conf. and don’t forget to edit your /usr/local/etc/daapd.conf, a sample is provided, and an example is shown on the page I linked above.
setting up mdnsresponder/rendezvous
the information on this in that above page is outdated. I found that I already had a mDNSResponder port, so I installed that. in fact, it’s part of the dependancies of howl, which is part of the daapd dependancies. but I installed /usr/ports/net/mDNSResponder, and /usr/ports/net/howl by hand; I believe they went fairly painless. Finally I created /usr/local/etc/howl and created an mDNSResponder.conf there with these contents:
FREEBSD SERVERNAME_daap._tcp. 3689
(note that blank line in there).
also, don’t forget to add mdnsresponder_enable=”YES” to your /etc/rc.conf
after that I ran
# /usr/local/etc/rc.d/mdnsresponder.sh start# /usr/local/etc/rc.d/daapd.sh start
if you haven’t changed your rc.conf these commands won’t start the servers, so make sure you do that first.
this took over 10 minutes to start up the first time, I’m guessing because it had to parse my almost 160GB of music. but after that it started up rather quickly. you can watch /var/log/daapd.log to see what the server is doing.
one note, the first time I ran this, it crashed after I played with it a bit. hopefully this doesn’t continue to happen.
The snow is floating down in such big clumps that the shadows it makes looks like bugs scurrying across the sidewalk. It doesn’t look like any of it is sticking. the weather report says 5 inches. maybe class will be cancelled tomorrow morning. wouldn’t that be swell?
I came home from work today at 2 to meet up with Comcast. I ordered the new comcast “dual dvr”. I’ve also been having weird issues with my cable since I moved in, so I scheduled a service call, too. They informed me on the phone this would be two separate comcast visits. so I scheduled them both for the same time.
I got home and dan was in his room. I mentioned to him that comcast was coming after I noticed comcast pull up outside. I think he’s been stressing out over papers. he’s been acting weird lately. I noticed him come out of his room to use the bathroom in a towel and a tshirt. meaning he was just hanging out in his room without pants on. then again, don’t we all do that?
my cellphone rang and it was comcast telling me the service man was there and I wasn’t answering the door. I told the lady, he’s at the wrong house. I went out on the porch, and of course, he was at the wrong house. i went out on the porch and met up with the guy. he asked was the dvr installer. he wanted to see my tv to make sure it was all good. he came upstairs and looked at the FRONT of my tv and said “no, this isn’t going to work.” I questioned him a bit and he had no answers but he offered to show me the box.
We went out to the truck and he shows me the box. it has one coax in, and component, svideo, and composite outputs for audio and video and spidf outputs and just a ton of connections. I told him that this would work fine on my tv. he guaranteed that it wouldn’t. I guess he thought you HAD to use the component output or it wouldn’t work. I dunno. comcast techs seem to be so misinformed. same goes for the people who answer the phone. I proceeded to go into descriptive detail on what each of these plugs do, basically just flooding him with information until he let me try it on my tv. we took it up to my room, and after I hooked it up, he started making phone calls to get it all turned on. I think it’s kinda silly that I paid this dude 24.95 for install when I’m the one who did all the work. Maybe I should ask comcast about that. he started to tell me how someone was using the usb port on his dvr but he didn’t finish his thought, I should have pressured him. I’m curious what I might use the usb or firewire ports for.
he left and 10 minutes or so later some other comcast dudes showed up. I explained that the dvr guy had just been there and I showed them the signal level issues I was having in my basement on the projector and showed them the small amount of fuzzyness that became apparent after I hooked up the dvr. they bitched that the other guy should have done all of these things. I told them that comcast had told me that it would require THEM to fix this other stuff. anyhow, they went outside and went to work on my problem. after at least 3 service calls these guys finally knew what to do. I went out back to watch them and they were climbing the pole to change my wiring, redoing all of the janky wiring on the side of my house and checking levels and making phone calls to higher-ups to get some other levels looked at and tons of stuff. these guys fixed my cable and made calls to fix the cable for the whole neighborhood.
This seems to be how it is with comcast. you get 5 service calls where the techs seem to know jack shit. they stumble to answer your simplest questions, they don’t seem to have any knowledge about what you think should be common problems. but then you get that one guy, or usually it’s two guys, and they’re fucking superhuman. they can just fix everything like they’re flipping a switch. I wonder if it’s because they’re working together they strive to do better. kinda like if I have someone around I don’t feel like sitting around all day watching tv, because I see what I’m doing through their eyes and feel like doing something better. right, I wasn’t like that today. well, as they were leaving I told them thanks and I was glad to finally get someone who knew how to fix something. they gave me their managers number and encouraged me to call him and tell him that. I may just do that.
after they left I started playing with my dvr. I’ve been playing with it and watching tv and basically not leaving my room since then. being able to record shows like this and pause tv and watch shows on my own schedule will definately change how I watch tv. even without some of the tivo features, this alone is worth the $10 a month. it’s like a shift in how I use my tv. then again, today, instead of making me want to watch LESS tv, it was making me want to watch MORE. hopefully this isn’t a trend. I think maybe I should cancel netflix. there are so many movies on comcast in demand, and I really don’t NEED to see those 400 movies in my netflix queue. plus, i can always borrow movies from BitTorrent or BenArwin. my two favorite movie sharing protocols.
I have a huge bag of mini kit kat, they have valentines messages on them. they’re so rectangular. I bet I could stack them into simple structures. I should try that. maybe at work on my desk where I have more space to construct.
oh, today I also wrote a script to intercept my notification e-mails from allofmp3.com and automatically download the mp3s. I don’t know how much I’ll use allofmp3.com after I burn through the $15 I sent them. but I like the idea, so maybe I should send them the $5 a month I normally send slsk. I could actually end up with more music per month. then again, slsk seems to have a wider selection of rarer stuff.
I got comcast dual dvr too now so I can be cool. It’s awesome. My installer was an idiot too but at least got it working.
I’ve written this script a half-dozen times at least, but this is the first one that doesn’t use Mac::iTunes to create the playlist. I needed something that would add a directory of mp3s to a playlist in itunes with the same name as the directory, so I wrote this:
#!/usr/bin/perl
use strict; $|++;
use warnings;
use Mac::Glue qw(:all);
my $itunes = Mac::Glue->new(“iTunes”);
my $dir = shift;
die “specify directory on command line\n” unless ( $dir and -d $dir );
my $playlist = $dir;
$playlist =~ s/\///g;
$playlist =~ s/\s+/_/g;
die “no playlist found\n” unless ($playlist =~ m/[a-zA-Z]/);
# check the playlist total time to see if the playlist exists already.
# $pl_time will be null if playlist doesn’t exist, “0:00″ for empty playlist
my $pl_time = $itunes->obj(playlist=>$playlist)->prop(‘time’)->get;
if ($pl_time) {
print “playlist exists!\n”;
} else {
$itunes->make(new => ‘playlist’, with_properties => { name => $playlist });
}
opendir DIR, $dir or die $!;
# only adding songs m4a, m4b, and mp3s.
my @file_list = grep { /(mp3|m4[ab])$/i } readdir (DIR);
foreach my $file (@file_list) {
print $file, $/;
# add files to playlist.
$itunes->add(“$dir/$file”, to => $itunes->obj(playlist=>$playlist));
# remove original
unlink “$dir/$file” or warn $!;
}
you can also find it on the code section of my webpage here.
how nice!
I love imunge!
I had some songs with annoying song names in all caps, with the help of ernie I wrote this imunge command:
imunge -s -r ‘.+’ -P ‘\L$&’
beautiful!
How to copy a dvd and burn it to DVD on my mac powerbook:
I’ve recently discovered a new medium that is having problems staying afloat. About a year ago I developed an affinity for a particular bathroom and stall here at WCC to take my daily bathroom breaks. this bathroom wasn’t particularly different from any others on campus, it was away from most of the staff locations, so I wasn’t going to run into anyone I knew, most likely, and it was rather secluded, which is nice, because some of the bathrooms at wcc have surprisingly revealing doors. with huge gaps or don’t close all the way.
Anyhow, this bathroom had amazing political commentary on the walls. I started visiting this bathroom when the troops were just getting ready to go to Iraq. the entire wall and door of the stall was full of people ranting and pontificating about the merits and disadvantages of going into IRAQ. Then the commentary started to change to things about the election as that approached. most of this stuff was really well written and had some great points. every now and then you’d get something that just said BUSH SUCKS or something clever like JOHN KERRY.
I often thought about taking a picture of this stuff, or trying to document it somehow, but it was always there, and I had no reason to believe that it wouldn’t be there forever. I’d tried checking out other stalls, to see if they had similar discourse going on, but none were as good as this particular place on campus. But like all good things, this too, must come to an end.
First they tried scrubbing the stuff off. that had marginal effect, the multiple types of pen used to write it up just created half discernible smudging. then they repainted over it all, and it just came back. So they did what was required, and painted that whole stall black. Thats when I realized it was only this particular stall. because I looked all over campus and that was the only one I could find that was painted black.
Now, I realize it’s someone’s job at WCC to clean things, but this didn’t need to be cleaned up! it was damned good political commentary. I felt like I was really reading what people think. There were first and second hand accounts of iraq, transcribed quotes from news articles, and tons of opinions. and damn, it was surprisingly well written.
Maybe I should write a letter or something, get this policy reversed. I should have been taking wide angle pictures of the bathroom stall. it’s a shame this is lost forever.
Ernie 11:04 am on August 13, 2005 Permalink
that show is so almost fucking cool. I cracked up at that dialog