clean-up

Tool to help clean up cut and paste code clones

I have a C# project with a large collection of cut-and paste cloned code. I have implemented a method that covers 90% of the usages (about 300 instances), but manually converting them by hand will probably introduce more errors than it fixes. Are there any (preferably free) tools that are designed to help with this? Basically the Code l...

Quick and easy way to remove "dead" (commented out) code

I'm working with an inherited code base which contains thousands of lines of commented out code. I know the previous coder meant to save all his hard work for posterity rather than simply deleting it but: I will never read it and it just gets in the way. One problem example is that when I perform text searches for certain code segments I...

How to clean-up an Entity Framework object context?

I am adding several entities to an object context. try { forach (var document in documents) { this.Validate(document); // May throw a ValidationException. this.objectContext.AddToDocuments(document); } this.objectContext.SaveChanges(); } catch { // How to clean-up the object context here? throw...

How to remove JQuery from the Window/make the GC take it.

I have a page, when loaded it does some stuff with JQ. In the next phase I want to load mootools and remove all JQ stuff, to avoid collisions and to avoid memory leaking. I am not giving you the all picture (to simplify the question), but assume I am not doing something stupid here, and it needs to be done how I am asking it. ...

How can I cleanly turn a nested Perl hash into a non-nested one?

Assume a nested hash structure %old_hash .. my %old_hash; $old_hash{"foo"}{"bar"}{"zonk"} = "hello"; .. which we want to "flatten" (sorry if that's the wrong terminology!) to a non-nested hash using the sub &flatten(...) so that .. my %h = &flatten(\%old_hash); die unless($h{"zonk"} eq "hello"); The following definition of &flatten...

clean html a string by element id using php

Hi, as you can see by the subject am looking for a tool for cleaning up a HTML string in php using a HTML id property, example: According to the following PHP string I wish to clean the HTML erasing the black11 $test = ' <div id="block1"> <div id="block11">Hello1 <span>more html here...</span></div> <div id="block12">Hello2 <s...

How to clean and simplify this code?

After thinking about This Question and giving an answer to it I wanted to do more about that to train myself. So I wrote a function which will calc the length of an given function. Th given php-file has to start at the beginning of the needed function. Example: If the function is in a big phpfile with lots of functions, like /* lots o...

AssemblyCleanup() after test fail/exception

Hello, I'm running a few unit tests that requires a connection to the database. When my test project get initialized, a snapshot of the database is created, and when tests are done the database gets restored back to the snapshot. Here is the implementation: [TestClass] public static class AssemblyInitializer { [AssemblyInitialize(...

Eclipse Clean Up and Formatting settings for Android application

I’m looking for a settings file that is customized for Android development, can you point to any? ...

Am I doing AS3 reference cleanup correctly?

In one frame of my fla file (let's call it frame 2), I load a few xml files, then send that data into a class that is initialized in that frame, this class creates a few timers and listeners. Then when this class is done doing it's work. I call a dispatchEvent and move to frame 3. This frame does some things as well, it's initialized a...

ActionScript Clean Up

i want to deallocate a spriteClass from memory and remove it from the display list. when the spriteClass is instantiated, it creates some of it's own sprites with new tweens and tween events and add them as children. i understand that the tween events must be removed in order for the spritClass to become available for garbage collectio...

How to cleanup old Failed Builds in TeamCity?

We do have hundreds of failed builds in TeamCity (number is especially high because of old retry on fail settings) and now it's a pain to browse history. I want to clean up only old failed builds, is there anyway to do that in TeamCity? Normal clean-up policy only allows X days before the last successful build sort of clean ups. ...

wxPython App - Ensure All Dialogs are Destroyed

I'm working on an application that will need to use a variety of Dialogs. I'm having trouble getting events bound in a way that ensures that my Dialogs are destroyed properly if someone closes the application before dismissing the dialogs. I would expect to use something like this: class Form(wx.Dialog): def __init__(self): wx.Dial...

making a python object unsable after a finalize-type call

I have a python object which wraps a sensitive and important resource on the system. I have a cleanup() function which safely releases various locks used by the object. I want to make sure that after a call to cleanup() the object becomes unusable. Ideally, any call to any member function of the object would raises an exception. Is the...

Drupal 6: View module generates div mess :/

Hi friends, I created some blocks with View Module. View Module really makes things easy! but it puts so many divs, class-names, etc... to output. and it mess up for some cases. example below: How can I get a CLEAN output from view? without any div, span... Appreciate helps! thanks a lot! ...

Error handling for xml parsing

I'm using tinyxml to parse xml files, and I've found that error handling here lends itself to arrow code. Our error handling is simply reporting a message to a file. Here is an example: const TiXmlElement *objectType = dataRoot->FirstChildElement( "game_object" ); if ( objectType ) { do { const char *path = objectType->At...

How to reduce code duplication in this example

I need to loop through a number (xx). xx always starts at zero. My problem is that if the moveDirection variable is +1 then xx increases until it reaches the positive of range. If moveDirection is -1, then xx decreases until reaching the negative of range. In the code below, I have done this by having an if statement test for moveDirect...

Cleaning up CSS files

I have a bunch of CSS files with a bunch of classes. I know a lot are not used. Is there a tool that will scan your site and clean up your CSS files or tell me which ones aren't used? ...

Do you clean up the unused scripts in a Visual Studio MVC project?

I am finalizing a MVC project and have switched to using Google's CDN for jQuery. After doing that, do you delete out the unused .JS files from the scripts folder? ...

twisted: catch keyboardinterrupt and shutdown properly

If I have a client connected to a server, and it's chilling in the reactor main loop waiting for events, when I hit CTRL-C, I get a "Connection to the other side was lost in a non-clean fashion: Connection lost." How can I set it up so that I know when a KeyboardInterrupt happens, so that I can do proper clean-up and disconnect cleanly? ...