Steve Kamerman's Blog
Deleting tons of files in Linux (Argument list too long) 
Wednesday, March 26, 2008, 05:35 PM - Linux
Posted by Administrator
Quick Linux Tip:

If you're trying to delete a very large number of files at one time (I deleted a directory with 485,000+ today), you will probably run into this error:


/bin/rm: Argument list too long.


The problem is that when you type something like "rm -rf *", the "*" is replaced with a list of every matching file, like "rm -rf file1 file2 file3 file4" and so on. There is a reletively small buffer of memory allocated to storing this list of arguments and if it is filled up, the shell will not execute the program.

To get around this problem, a lot of people will use the find command to find every file and pass them one-by-one to the "rm" command like this:


find . -type f -exec rm -v {} \;


My problem is that I needed to delete 500,000 files and it was taking way too long.

I stumbled upon a much faster way of deleting files - the "find" command has a "-delete" flag built right in! Here's what I ended up using:


find . -type f -delete


Using this method, I was deleting files at a rate of about 2000 files/second - much faster!

You can also show the filenames as you're deleting them:


find . -type d -print -delete


...or even show how many files will be deleted, then time how long it takes to delete them:


root@devel# ls -1 | wc -l && time find . -type f -delete
8532

real 0m3.660s
user 0m0.036s
sys 0m0.552s

add comment ( 3 views )   |  permalink   |   ( 2.9 / 76 )
osCommerce Webmaster’s Guide to Selling Online 
Friday, February 15, 2008, 08:52 AM - PHP, MySQL

If you're selling products online with osCommerce, check out the new book osCommerce Webmaster's Guide to Selling Online. Most notably, this book focuses on increasing your sales and profits through SEO, Marketing, Design, Selling Strategies and more.

I will be evaluating this book in the near future and writing a full review, so check back later to find out more information on the osCommerce Webmaster's Guide to Selling Online!
add comment ( 5 views )   |  permalink   |  related link   |   ( 3 / 6925 )
Flex 2 DataGrid ItemRenderers are re-used! Warning!!! 
Thursday, January 10, 2008, 11:37 AM - Flash / Flex, Actionscript
After battling with Flex 2's DataGrid ItemRenderer for a few hours, I have finally figured out how they really work.

The Scenario


Let's say you want to have a DataGrid with a thumbnail in one of the cells. To do this you would assign the DataGridColumn an ItemRenderer. Here's a quick and dirty MXML ItemRenderer that will work:


<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Image id="thumbnail" width="25" height="25"/>
</HBox>


Now, when the DataGrid goes to render the cell the first time, it instantiates the ItemRenderer and sets the "data" property to the data of the current row in the DataGrid. Let's say you have a property called "thumb_src" in the data. You could just bind the image's source property to "data.thumb_src" and you probably wouldn't have any problems, but if you wanted to do anything to the data before you use it you will run into trouble. The problem is that DataGrids only create as many ItemRenderers as are visible in the grid, so if you have 1000 rows in your DataGrid but you can only see 10, only 10 ItemRenderers will be created (more will be created on demand if you resize the DataGrid). Once a cell is scrolled off the top of the grid it is reused at the bottom (and visa-versa). When the ItemRenderer is reused, the DataGrid sets the data property with the new data and that's it - it is not destroyed re-instantiated.

The Problem


All this becomes a major problem when you use the creationComplete event to setup some stuff on your renderer, since this event is only fired once - then renderer will be used and re-used to display the data from many different cells. When this problem occurs, you will see data in the ItemRenderer cells being thrown around seemingly at random when you scroll the DataGrid - it will probably drive you crazy!

The Solution


You need to setup / clear everything in the renderer when the data property is set. The easiest way to do this is to override the Container's "data" setter function like this:


public override function set data(value:Object):void{
// This will fire off the FlexEvent.DATA_CHANGE Event
super.data = value;
// if the value is null this cell is empty
if(value == null){
// clear all the controls
return;
}
// set the controls with this data
}


You could also add an event listener for FlexEvent.DATA_CHANGE, which is fired off by the Container superclass.

Here's a great example that I made that shows the problem. You can right click on the application and hit "View Source" to see the code, or go there directly.
5 comments ( 57 views )   |  permalink   |  related link   |   ( 3 / 8402 )
My desk gets another monitor :D 
Monday, September 24, 2007, 05:44 PM - Tera Projects
So the other day my 20.1" Widescreen Viewsonic monitor started acting funny and turning off on me (this is my 2nd one that has died), so I replaced it with a 22" Widescreen Xbrite and the new monitor rocks! I figured I would send the Viewsonic back again and have it replaced again, but I thought I would give it another shot as-is first. It seems to run fine unless I leave it on for 12-24 hours at a time so I decided to take it to my office.

Since I already have 2x 17" Flat Panels at my office, I was going to need another video card to support more than 2. After a little researching on the net, I jumped on Newegg.com and found myself a couple dual-head PCI video cards to throw in with my ATI Radeon X1650 PCIe. I got 2 because the only Radeon series for under $100 were either 1xDVI+1xVGA or 2xDVI Low Profile. I got one of each. The first one I received was a VisionTek Radeon 7000 64MB PCI ($34.99). I installed the card and plugged in my 20.1" Viewsonic and turned on the computer - no joy. I installed the drivers and prayed it wouldn't mess up my X1650. Drivers installed no problem, but still no display. Restarted - no display. Now I could see the other card and the monitors in the dislpay properties, but when I "attached" them they didn't do anything. I restarted it again and went into the BIOS and changed Init Display First from PCIe to PCI Card. I saved the changes and booted into windows - whalah! 3 monitors - all playing nicely :). The computer seems like it's going to die when it starts up because everything slows down to a crawl for a little while, but then it works as expected. This 3-monitor setup seems very efficient to me. I'll have to report back after I've used it for a while.





My Setup
ATI Radeon X1650 PCIe 512MB Dual Head (2x DVI)
ATI Radeon 7000 PCI 64MB Dual Head (1x DVI, 1x VGA)
2x Dell 17" Flat Panels
1x Viewsonic 20.1" Widescreen Flat Panel




add comment ( 2 views )   |  permalink   |   ( 3 / 8339 )
NVIDIA SLI Zone Giveaway 
Friday, September 14, 2007, 03:38 AM - Flash / Flex
I happened to be browsing around tonight and noticed that NVIDIA has been giving away 1 prize per day for a year! Here's the catch - you need to visit the site every 7 days to see if you won or your prize will go to the next guy! Stupid! To make matters worse, only way to see if you won is to use this annoying marquee on their site!

http://www.slizone.com/object/slizone_sli_giveaway.html

So naturally I decided to make everyone's life a little easier and pumped out a handly little Flex2 app that shows who won for the last week. It is updated in real time since I'm just grabbing the winners off the same RSS feed that's feeding the NVIDIA website. Check it out - it's cool, it's Flex, and it might just save your butt!

http://devel.teratechnologies.net/nvidia_winners/
add comment ( 2 views )   |  permalink   |  related link   |   ( 3 / 8603 )

| 1 | 2 | 3 | 4 | 5 | 6 | Next> Last>>