PAR2 file mover
This is my first Ruby script... please feel free to contact me with feedback.
It will read a PAR2 parity file and move all the files in it to a subdirectory. The original thing I asked for:
I know you can currently download into subdirectories based on ID3 tags. I would love to be able to have downloads go into subdirectories based on the PAR2 file that "covers" them.
Example, all files downloaded overnite into a huge directory:
AAA.PAR2 AAA 01-16.mp3 AAA 02-16.mp3 ... AAA 16-16.mp3 AAA.nfo AnnoyinglyNamedNothingLikeAAAButInThePARFileAnyway.nfo BBB.PAR2 BBB 01-92.mp3 BBB 02-92.mp3 ... BBB 92-92.mp3 BBB.nfo ... XXY.PAR2 XXY.mp3 XXY.txt
So I would want them moved into the subdirectories "AAA", "BBB", "XXY", etc. It wouldn't be perfect but it would be a great start for what I do to process my inbound stuff.
If not, how about dumping some log file I can parse in perl or ruby that gives me "AAA.LOG" which lists the files that went with AAA.PAR2 ?
Of course, being a borderline OCD engineer, I didn't just solve the problem but also put together a full object-oriented infrastructure to parse and process PAR2 files. I've only handled one packet type defined in the PAR2 specifications, but put in place a Par2BasePacket with an interface that all the other packet types can be derived from.
Without further delay, see the attached code (sorry, my install doesn't support syntax highlighting of ruby and I don't have time now - but you can paste the code into this online highlighter).
Using Kompare
So I was using Python to do some pretty diffs (will post that some time soon) and a coworker pointed out the program Kompare on Linux. I don't normally use Linux as a desktop, only servers. Anyway, it gives me an awesome interface, almost as good as the TortoiseSVN diff viewer I am used to. It can take the output of svn diff and then will find the original files and show you graphically all the changes.
The command I have been using:
svn diff | kompare -o -
Arduino Project
I'm thinking about starting an Arduino project. I don't want to reveal details yet. But it won't be all that cool, just something I want.
I was really liking the BlackWidow until I read that it is not 802.11b/g but b only, which would slow my network down too much. FAIL guys. :(
So now I need to decide - do I get a Ethernet shield for $46 and then load OpenWRT into a $25 802.11n router? Then if the project fails, I still can re-use the router as a bridge somewhere else... or do I splurge and spend $90 for a "real" Arduino 802.11g unit?
I Hate Java
(Originally posted 27 Nov 09, lost in server mishap, found in Google's cache of this page)
So for some reason this evening, my favorite RSS Reader (RSSOwl 2) wouldn't run... and that scares me. I use it to peruse probably 60-80 websites daily.
Anyway, it just wouldn't run. No error messages. Didn't even look like Windows would give it a chance. Never showed up in Task Manager. Well, I was using a beta, so I uninstalled it and installed the newly released 2.0. Still no luck. Nothing at all.
Decided to try it from the command line, to see if the helps:
Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
That's nice and descriptive - WTF? Remembering that RSSOwl is built on the Java IDE Eclipse, I decided to make sure I have the newest Java. I am running Windows 7, which is fairly new, so maybe something happened there. Doesn't explain why I've been running it since its release with no problems up to now... In fact, I notice that running java from the command line gives me the same error.
BTW, Google was useless, a bunch of posts about Java from 2005, or talk about the SDKs and/or rt.jar. None seemed to apply.
So I install the latest, which is "Java 6 Update 17" - an odd numbering scheme, I will get back to that. With a fresh install, the plugin works in Firefox. Java.com has a link to check your JVM too. That crashed Firefox. So I copy the URL and try Internet Explorer. Crashed that too. Drop to the command line to try java - same error.
Open up the control panel to add/remove programs, and I see that there are 4 or 5 versions of Java installed. Why? Shouldn't "Update 17" be sufficient instead of also having Updates 2, 5, 7, and 13 also? (I don't remember the exact numbers).
After uninstalling all of them, and then installing the newest, everything works fine, including RSSOwl and the JVM check page:
RevRagnarok@Jotunheim ~ $ java -version java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
One note: I think Update 17 was the first one to be installed/updated after the upgrade from Vista to Win7. That may be related to why there was such weirdness... but I still don't agree with an update not removing all the previous ones.
RHEL/CentOS/VMWare pissed me off
(Originally posted 25 Oct 09, lost in server mishap, found in Google's cache of this page)
I cannot believe that a point release would hose me up so badly...
- http://bugs.centos.org/view.php?id=3884
- You can see what I did to fix it listed at the bottom
More than 4 serial ports under Linux
(Originally posted 24 Oct 09, lost in server mishap, found in Google's cache of this page)
So at work I am using a PCI104 octal serial port board. It's pretty cool that Linux now supports those OOB, but I had problems; I only saw the first two ports!
After doing a bunch of research; I finally found the problem. I had assumed it was something with the chipset itself. However, it is a problem with the default kernel build from RHEL/CentOS. They only allow up to four by default! To get more (up to 32 with the RHEL/CentOS kernel), you have to add to the command line in GRUB:
8250.nr_uarts=12
Again, that can be up to 32. I chose 12 because "traditionally" the mobo could have up to four. That made the two on the mobo ttyS0 and ttyS1, so the octal card has ttyS4 to ttyS11. So ttyS2 and ttyS3 are unused. A quick check with dmesg | grep ttyS will show them being allocated.
Side note: You can check how many the default is by doing grep CONFIG_SERIAL_8250 /boot/config-`uname -r` and looking for CONFIG_SERIAL_8250_RUNTIME_UARTS. CONFIG_SERIAL_8250_NR_UARTS is the maximum you can have without rebuilding the kernel.
Maybe I'll get inspired and blog sometime about the cool stuff I did with udev so that I can configure a box and then the software would just "know" where which serial port the (external device) was on by calling /dev/projectname/extdevice .
Strange Software Install Issue (Installer silently hangs)
I've been having a strange install issue with the ATI Catalyst software. It's documented here on the AMD site: http://forums.amd.com/game/messageview.cfm?catid=279&threadid=125401&forumid=11
However, forums like that have a great history of disappearing when I need them most, so a summary is also now here.
Setup was totally hanging. I tried all kinds of things to trace what was happening. Then this wonderful post came along:
From Wiink:
I signed up to post in this thread since I was having the exact same issue and was really frustrated over it. I have a 4890 and have always used Ati graphics cards, never had any issues and drivers always installed flawlessly until one day i decided to update from 9.8 to the current 9.12.
I'd go through the usual uninstall methods using the ati uninstaller and then follow up with driver sweeper. Click on the exe for the 9.12 suite and it would unpack/extract then an hourglass for about 5 seconds and then nothing. I would see InstallManagerApp.exe running in the taskmanager and my hdd light would be lit, but that was about it....no install. Tried many times and nothing worked. Drove me absolutely crazy. Checked and re-checked all the cleanup, c++ redist and .net stuff....All in order and still same results - nothing.
Then I came across this thread about not having full admin permission for registry changes needed for some software installs even though I am the only user and Admin of this pc. When installing the 9.12 Catalyst Suite, it needs to change something in the registry that was now being blocked , so I ran this fix posted here and my problems were solved immediately on both my Vista and my XP Pro machines. Just remember to create a fresh system restore point before applying it. I was so happy to have the issue fixed I had to share. It specifies Vista in the post, but it worked for my Xp Pro as well flawlessly. Took about 20 minutes and fixed! And sorry for the wall of text. Just do a reboot after running the cmd file and try to install the catalyst 9.12 suite again, should work now.
Post by Michael G. Simmons: http://social.msdn.microsoft.com/forums/en-US/vbexpress2008prerelease/thread/c273b0e1-7f46-4065-afaf-4edf285d2531
There is a quick fix for this and any other permission issues that occur with Vista. I've seen this happen with several different installs under Vista including VS 2005 and Orcas. The problem is for some reason regisry permissions are given to the user msiserver. You can reset each entry manually, but that is a major pain. It's much easier just to fix the entire registry by using the SubInACL utility. Basically, you can use the utility to add administrator permissions to every key in the registry.
1. Download and install the SubInACL utility.
2.Create a new text file named fix_registry_permissions.cmd and add the following text to it and save it.
cd /d "%programfiles%\Windows Resource Kits\Tools"
subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f
subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f
subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f
subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f
subinacl /subdirectories %windir%\*.* /grant=administrators=f /grant=system=f
3. Run the file by double-clicking on it.
That's it. It will take several minutes to finish, but at the end all registry keys will be accessable to the administrator and system, as it should be.
My Dell XPS Gen 3 won't boot from CD-ROM!
To: Some friends of mine.
Any ideas on this head-scratcher?
My Dell XPS (getting really old, I know) won't boot from CD-ROM. I have tried 3-4 different CDs. One of the CDs has multiple boot images on it and none of them boot.
Here's the weird part - I can get the boot loaders to work! The Ghost ones will say "Loading PC-DOS..." and then the CD drive just stops spinning. The multiboot one gives me all the menus, but as soon as it tries to launch something, it hangs in the same way. Even good ol' DOS 6.22 says "Loading MS-DOS..." and hangs. I tried my CentOS 4 installer DVD - I get the boot menus, I type "linux rescue" and then it just sits there.
My config is multiple SATA drives and two PATA CDs. I have even disabled the master and then I have the same issue with the secondary (it won't touch the secondary if the master is enabled, even if no CD in master). Same thing.
And here it gets even weirder... I booted from a USB key with Ghost on it just fine; I'm doing my backups now. WTF?!?!
Various suggestions came back... then a few days later, I found the solution!
You've GOT to be shitting me... I fixed it!
I didn't install this BIOS release from over 4 years ago (I have A06), but look at the changelog:
"1. Prevent boot issues when USB devices with media readers are present."
Lo and behold, I plugged my monitor in a few weeks ago. Which has a (useless) built-in USB hub and media reader! I never would've expected something like that to happen! So my guess is that the BIOS tries to enumerate the drives somehow to map to INT13 and hangs up! When I yanked the USB cable from the monitor, CDs booted just fine!!?!?
I thought the USB hub was useless before because it powers off with the monitor - now it is a downright HINDRANCE!
RPMBuild stupidity
OK, this just pisses me off. It's plain dumb - rpmbuild expands macros before stripping comments. So what happened to me today (and I wasted an hour on) was that a multi-line macro was being inserted into a comment!
Based on a quick search of bugzilla at readhat, I'm not the only one - see 74949 and 99100. They say WONTFIX but that's just dumb in my not-so-humble opinion.
So now you know. If you are making a spec file for an RPM:
%files # %build
will screw you over like it did me. You need to:
%files # %%build
MATLAB objects and subsref
Oh MATLAB, why do you have to be so obtuse about what you are doing??? I understand that OO stuff is being shoved into a language that didn't originally support it, but WHY isn't it just documented better?
Problem: All of a sudden, my method calls from outside the class stopped working.
Background: All the documentation says that if you have a (dependent) property and there is public access to it, the methods get.propname(obj) and set.propname(obj, val) will be automatically called for you. This is true.
At least, it was until I decided I wanted my class to be able to return more than one value at a time. Once I defined at subsref() method, all external access died and now goes through it instead. EVERYTHING. So you must handle all your own public methods, etc, with useless wrapper logic. MATLAB doesn't do something intelligent like, "well, let me see... OK, there's a get.propname() so I'll call that." Nope. Instead, I need to do:
% (All within a "classdef") function ar = subsref(obj, subs) switch subs(1).type case '.' switch subs(1).subs case 'single_val' ar = obj.single_val; % which DOES call the get.single_val() method!!! end % subs case '()' % actually do the stuff I wanted to do with ranges here end % type end % subsref
This really confused me and I didn't find much on their website that was helpful about it either.
Using UltraCompare with TortoiseSVN
Diff: C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe -t %base %mine Merge: C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe -rom %theirs %mine %merged
MATLAB: Please dbstop here
I am doing a lot with MATLAB at work. I wanted the equivalent of a command that doesn't exist: dbstop here or dbstop now. Came up with two possible solutions with the help of the MathWorks tech support.
1: (from MATLAB documentation)
dbstop if warning 'MFILE:stop'; % Then later: if ~isequal(input, expected_input), warning('MFILE:stop','Boom!'), end; % At the end (or else things seem to slow down) dbclear if warning 'MFILE:stop';
When it drops into the debugger you can then issue the above dbclear command by hand to get it to stop dropping there.
2: (my way)
This way uses the command keyboard that I didn't know about until tech support told me about it - it is not listed in help dbstop but it is a "see-also" in doc dbstop which is annoying...
breakable=1;
% Then later:
if breakable && ~isequal(input, expected_input), keyboard, end;When it drops into the debugger (you can still use F5, etc) you can then type breakable=0; to stop it from dropping at that point. It doesn't clutter up the dbstop stack so shouldn't slow down unrelated M-files.
RevRagnarok's Blog
This is not a typical "read my thoughts blog" - instead it is a "I found something that may be useful to be jotted down for myself, and maybe others can benefit from my sweat and tears." So it is more of a brain dump. If you find any of it useful, please feel free to drop me a line at blog using this domain name. The tags should be pretty self-explanatory. Also, most of my useful links are dumped at del.icio.us. And with that disclaimer finished, I now have a "funny stuff, etc" blog on blogspot.
VMWare Client Running on Fedora 9
What a pain! You have to get the latest open-vm-tools from SourceForge. Do a configure and make && make check. But then you cannot actually install the files or VMWare gets pissy.
After the make you need to pack up the kernel files you have created and patch the real VMWare installer with them:
for i in *; do mv ${i} ${i}-only; tar -cf ${i}.tar ${i}-only; done
cp *tar /usr/lib/vmware-tools/modules/source/
Then you can run the standard vmware-tools-config.pl and it will use the source you just upgraded.
This page was assembled from various net resources...
Hidden Directories
So, apparently Vista does something that is actually kind of smart. If a program tries to put preference files, etc into the "Program Files" directory, it dumps them elsewhere so that they are still going to be user specific. (This is all hypothesis!) Anyway I was trying to move my scores from WinXP to Vista for "Snoodoku" and this was the solution. http://www.wordofmousegames.com/forums/showthread.php?t=2134
Well, I found it myself, so figured I'd post the solution for future users.
Apparently, Vista merges two directories when a program is trying to store preference files in the Program Files directory. So the file was actually hidden away in C:\Users\RevRagnarok\AppData\Local\VirtualStore\Program Files\Snoodoku
More info from Microsoft.
"sudo" for Vista
http://technet.microsoft.com/en-us/magazine/cc162321.aspx
"elevate" acts as sudo
Subversion from Perl
So I spent about three hours trying to get my perl svn_compress script running and I ran kept running into the damned thing segfaulting!
svn_path_basename: Assertion `is_canonical (path, len)' failed.
I finally found the answer. Apparently, libsvn wants '' as the current directory, not '.' like every other program since the beginning of time (Jan 1, 1970, right?).
Three hours.
Where I read the answer. Pasted here:
Peter Samuelson wrote:
> [Julian Gilbey]
>> burnside:~/debian/tex/tetex-bin $ perl -MSVN::Client -e \
>> 'sub print_names { print "<$_[0]>\n"; } $ctx=new SVN::Client;
>> $ctx->status("", "BASE", \&print_names, 1, 1, 0, 1);' | head -5
>> <>
>> <.pc>
>> <.pc/.version>
>> <configure>
>> <INSTALL.generic>
>
> I reproduced your bugs with subversion 1.3.0-5, so I can properly
> discuss it with upstream. Unfortunately, I don't know much about the
> Perl bindings. But comparing "svn status" with your command, it does
> seem to correspond to the "." entry. I wonder if that is even
> considered a bug. I mean, if you prefix each entry with $(pwd)/, it is
> fine.
>
>
>> perl: /tmp/buildd/subversion-1.2.3dfsg1/subversion/libsvn_subr/path.c:377:
>> svn_path_basename: Assertion `is_canonical (path, len)' failed.
>
> Right, that's definitely a bug. Even if this isn't something the perl
> bindings can fix on their own, they should carp or something.
Hi. This is an issue that gets kicked around on dev at svn from time to
time, and usually ends up with the thread fizzling out sooner or later,
with no concrete action being taken, due to a lack of an obvious right
way to proceed. I'll sum up the situation...
There exist a number of path manipulation functions (svn_path_*) which
do not conform to the usual style returning an error status as the
return value, and output data via output pointer parameters. Instead
they return data directly as the return value, and are supposed to only
ever be able to experience errors that merit assert() or abort().
Subversion defines a 'canonical path' format, and most of the functions
(apart from the canonicalizer itself, obviously!) assert that the input
path looks like a canonical path.
Various groups of C programmers will conduct heated debates on whether
this is good programming practice, or an annoyance, but that is
irrelevant where the bindings are concerned, since assert()-ing out of a
scripting language interpreter is clearly bad.
There is a fairly obvious, though non-trivial, solution:
Make the bindings test all input paths (presumably using a path-specific
SWIG "in" typemap) using the same logic as is_canonical, and
canonicalize if necessary. The problem, though, is that discussions of
this nature tend to get intertwined with the parallel issue of whether
the C code is being generally unhelpful in this situation, and should be
changed too.
OK, now you know the background.
Feel free to prod dev at svn to raise awareness of this problem which has
sadly lain dormant for far too long.
Max.
Aside:
The canonical form (IIRC) is mostly common sense stuff:
* no repeated slashes
* no internal /../ sequences
* no trailing slash
BUT it has one weird rule:
* the canonical form of "." is ""
Today I created a yum repository
This is what happens when you are at work and you have ISOs for the 6 CDs of CentOS 5.2 but NOT the DVD, and no connection to the 'net... I couldn't use the 5.2 installer thanks to this bug (it's an embedded Celeron 650). Since I went thru all the work, I also then imported the directory as a "shared folder" under VMWare player and then did the same upgrade path on that machine (I want it to mirror the embedded machine for all versions of everything, except it also has the gcc suite, etc).
One Time Only
(This can be done on any Linux machine with the external drive connected)
- I mounted the external drive under Linux and there are the 6 ISO CDs. I mounted each and then upgraded what was on it that we already had installed.
- cd /media/ext_drive/<install dir>
- mkdir mnt
- mount -o ro,loop <CDFILE>.iso mnt
- cp -urv mnt/CentOS .
- If I were doing this again, I may mount the 6 as /mnt1 thru /mnt6 and then try to use cp -l to make links?
- (Optionally in another window to watch progress: watch -d 'lsof -c cp -s | cut -c37- | grep rpm ' )
- umount mnt
- (Repeat for all 6 - this gives us a CentOS subdir with all the RPMs. If I had the DVD instead of the 6 CDs, this would've been easier)
- Now we will make this new directory into an "official" repository
- cd CentOS
- rpm -i createrepo*rpm (glad that was there!)
- mkdir repo_cache
- createrepo -v -p -d -c repo_cache --update --skip-stat .
- This step takes forever (even longer than the copying above)
- With a DVD image, this is most likely not even needed!
Every Target Machine
- We need to disable all the remote repositories:
- Edit /etc/yum.repos.d/CentOS-Base.repo and add enabled=0 to every section
- Edit /etc/yum.repos.d/CentOS-Media.repo and change to enabled=1
- Depending on where the external hard drive is, baseurl will need an added path to it
- When I did it, it was file:///media/ext_drive/LinuxInstallers/CentOS-5.2-i386-bin-1to6/CentOS/
- There is a known bug in 5.1 - the GPG signature key should be RPM-GPG-KEY-CentOS-5 (not "beta")
- Depending on where the external hard drive is, baseurl will need an added path to it
- yum clean all
- yum install yum-protect-packages
- yum upgrade yum
- yum clean all
- yum upgrade --exclude=kernel\* -y | tee upgrade.log
- (Optionally in another window to watch progress: watch -n1 'lsof -c yum -s | cut -c43- | grep rpm ' )
- grep warn upgrade.log
- For this, you need to diff each file with the .rpmnew file or .rpmold file and merge them together.
- Reboot!

rss