I have run a very simple file, print, backup and SVN server at home for a number of years. It was built using old parts laying about the house. A few weeks back the fan on the video card and the chipset fan on the motherboard died. I had another old AGP video card so I slapped that in and it kept running until this past Thursday.
My wife needed data off the HD so I had here take the external USB drive I use for Monday / Wednesday / Friday backup cycle and had her plug it directly into her machine. Made me a bit nervous but she needed her files. I just asked her not to delete anything.
Thursday night I pieced together a new machine to be the server. I plugged in the original HD and went to work. This was my son's box and it had been acting flaky so I had some doubts. I got WinXP running again but when I tried to the the motherboard USB 2.0 drivers to work things went to hell quickly. Devices were not recognized and unplugging or plugging one in could cause a BSOD and reboot.
I spent way too many hours on this before I gave up. I hit the web to see what the cheapest Win7 based machine I could get at Microcenter happened to be. I was sick of WinXP on the server and all other machines in the house are running Win7. They had an open box eMachine for $215. I know, it is an eMachine but I have bought them in the past for family members on budgets and if you just run what it has as the base configuration they keep running. I have not had one fail yet. My big worry is their small power supplies.
This is a typical machine with AMD 2.8g processor, 2g of RAM, 500 mb HD, nVidia chipset and video card in a slim line case with plenty of USB 2.0 ports. Fired right up and I spent the next bunch of hours uninstalling crap, installing patches and restoring a previous backup from the external USB drive. The proper area of the drive is shared and the printer is shared so the rest of the family is happy. I have installed Apache and SVN but have not fully configured them yet. I was sick of computer stuff so I played some games and did work on a side Android project.
In the end of should have given up much earlier and just bought a new machine. Trying to get old suspect hardware running just to be cheap is not a good solution. We have proven over the years that the server is critical to running our house. I have plans to get more services running on the box - SVN, some flavor of SQL, etc. so it needs to be slightly on the mission critical side of things.
Showing posts with label dead. Show all posts
Showing posts with label dead. Show all posts
Monday, March 19, 2012
Monday, December 12, 2011
First OSX Utility - find unreferenced image files
Today I wrote my first OSX application. I have been writing iPhone apps in Objective C but I had not done an OSX application. I needed a utility to tell me what image files were unreferenced in my iOS project so I can remove them and clean things up.
Started out with a base OSX Application in Xcode. Added some basic fields to the XIB file - Directory name, [Browse...] button, [Find Issues] button and a text area to show the results.
Next I figured out how to browse for a single directory and get the URL back. Take that URL and do a recursive search for all other directories. In each directory find image files using an image extension list and file all code files (*.m, *.h).
Once all the file information is available start looking in the *.xib, *.h and *.m code for images either by NSResourceName, extension or by imageNamed: as that call will automatically look for PNG files. As we find references in code increment the image name reference. I have code to ignore commented out lines and blocks of code although the block indicator needs to start the line not be buried within a line at this time.
At the end of the run it builds a string of all orphan image files (those without reference in code) and populates the text area with the list. This leaves some false positives for icons that you need to publish the app but those are pretty easy to ignore at this point.
I added a progress indicator as the program run can take a few seconds to run, clean up of the menu system to show only valid items, update the about dialog text and adding a real program icon.
Finally I added a check for {name}.png / {name}@2x.png to show what missing retina images or orphan retina images you happen to have. I found eight images that I had not done a retina version of so this was a handy validation. I also found an image that was not being used and was being referenced from an unrelated directory.
This does find false positives but mainly on the numerous icon files you need for all iOS device flavors. I might need to add another text field for you to type in "files that start with {string}" to ignore but only people who are OCD enough to crave an error free run would care. Everyone else will go "yeah, forget those" and move on.
I am using some code I found thanks to Stack Overflow to read basic text files a line at a time. Totally surprised, although at this point I should not be, that is missing from the core library. So odd to me how many very basic things are missing from the iOS / OSX SDK. It still appears that Apple likes to add new API areas but not make existing API calls better.
My overall understanding of Xcode / XIB files / Objective C put the whole project in at under a day. I learned how to query for a directory, roll through a directory structure, read lines from a text file and do widget anchoring in XIB so my window resizes / relayouts out controls as expected.
At this point the program is not as powerful as the Java version I wrote for Android project validation. On the Android side I can check images, strings, layouts, animations, etc. and I don't have any false positives as all my icons are referenced in one of my XML files. For OSX I am making a bit more of a guess about the code to see if you are using an image. The utility will help me do this round of clean up and will keep it clean as time goes on. I really wish the SVN integration with Xcode was better. I know I can delete the file from the project but it does not delete it from SVN. I will have to manually clean that up or do the work under AppCode from Jetbrains as it does full integration.
Started out with a base OSX Application in Xcode. Added some basic fields to the XIB file - Directory name, [Browse...] button, [Find Issues] button and a text area to show the results.
Next I figured out how to browse for a single directory and get the URL back. Take that URL and do a recursive search for all other directories. In each directory find image files using an image extension list and file all code files (*.m, *.h).
Once all the file information is available start looking in the *.xib, *.h and *.m code for images either by NSResourceName, extension or by imageNamed: as that call will automatically look for PNG files. As we find references in code increment the image name reference. I have code to ignore commented out lines and blocks of code although the block indicator needs to start the line not be buried within a line at this time.
At the end of the run it builds a string of all orphan image files (those without reference in code) and populates the text area with the list. This leaves some false positives for icons that you need to publish the app but those are pretty easy to ignore at this point.
I added a progress indicator as the program run can take a few seconds to run, clean up of the menu system to show only valid items, update the about dialog text and adding a real program icon.
Finally I added a check for {name}.png / {name}@2x.png to show what missing retina images or orphan retina images you happen to have. I found eight images that I had not done a retina version of so this was a handy validation. I also found an image that was not being used and was being referenced from an unrelated directory.
This does find false positives but mainly on the numerous icon files you need for all iOS device flavors. I might need to add another text field for you to type in "files that start with {string}" to ignore but only people who are OCD enough to crave an error free run would care. Everyone else will go "yeah, forget those" and move on.
I am using some code I found thanks to Stack Overflow to read basic text files a line at a time. Totally surprised, although at this point I should not be, that is missing from the core library. So odd to me how many very basic things are missing from the iOS / OSX SDK. It still appears that Apple likes to add new API areas but not make existing API calls better.
My overall understanding of Xcode / XIB files / Objective C put the whole project in at under a day. I learned how to query for a directory, roll through a directory structure, read lines from a text file and do widget anchoring in XIB so my window resizes / relayouts out controls as expected.
At this point the program is not as powerful as the Java version I wrote for Android project validation. On the Android side I can check images, strings, layouts, animations, etc. and I don't have any false positives as all my icons are referenced in one of my XML files. For OSX I am making a bit more of a guess about the code to see if you are using an image. The utility will help me do this round of clean up and will keep it clean as time goes on. I really wish the SVN integration with Xcode was better. I know I can delete the file from the project but it does not delete it from SVN. I will have to manually clean that up or do the work under AppCode from Jetbrains as it does full integration.
Subscribe to:
Posts (Atom)