Search Results

Search found 786 results on 32 pages for 'cleanup'.

Page 3/32 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Win32 -- Object cleanup and global variables

    - by KaiserJohaan
    Hello, I've got a question about global variables and object cleanup in c++. For example, look at the code here; case WM_PAINT: paintText(&hWnd); break; void paintText(HWND* hWnd) { PAINTSTRUCT ps; HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0)); HDC hdz = BeginPaint(*hWnd,&ps); char s1[] = "Name"; char s2[] = "IP"; SelectBrush(hdz,hbruzh); SelectFont(hdz,hFont); SetBkMode(hdz,TRANSPARENT); TextOut(hdz,3,23,s1,sizeof(s1)); TextOut(hdz,10,53,s2,sizeof(s2)); EndPaint(*hWnd,&ps); DeleteObject(hdz); DeleteObject(hbruzh); // bad? DeleteObject(ps); // bad? } 1)First of all; which objects are good to delete and which ones are NOT good to delete and why? Not 100% sure of this. 2)Since WM_PAINT is called everytime the window is redrawn, would it be better to simply store ps, hdz and hbruzh as global variables instead of re-initializing them everytime? The downside I guess would be tons of global variables in the end _ but performance-wise would it not be less CPU-consuming? I know it won't matter prolly but I'm just aiming for minimalistic as possible for educational purposes. 3) What about libraries that are loaded in? For example: // // Main // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // initialize vars HWND hWnd; WNDCLASSEX wc; HINSTANCE hlib = LoadLibrary("Riched20.dll"); ThishInstance = hInstance; ZeroMemory(&wc,sizeof(wc)); // set WNDCLASSEX props wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = WindowProc; wc.hInstance = ThishInstance; wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = TEXT("PimpClient"); RegisterClassEx(&wc); // create main window and display it hWnd = CreateWindowEx(NULL, wc.lpszClassName, TEXT("PimpClient"), 0, 300, 200, 450, 395, NULL, NULL, hInstance, NULL); createWindows(&hWnd); ShowWindow(hWnd,nCmdShow); // loop message queue MSG msg; while (GetMessage(&msg, NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // cleanup? FreeLibrary(hlib); return msg.wParam; } 3cont) is there a reason to FreeLibrary at the end? I mean when the process terminates all resources are freed anyway? And since the library is used to paint text throughout the program, why would I want to free before that? Cheers

    Read the article

  • javascript/jquery input fields cleanup

    - by user271619
    I've created a few input fields, that I am cleaning up as the user types. So, I'm using a keystroke detection event, like .keyup() It's all working very well, but I do notice one thing that's rather annoying for the users. While the script is cleaning the data as they type, their cursor is being sent to the end of the input field. So, if you want to edit the middle of the value, you're cursor immediately goes to the end of the box. Does anyone know of a way to maintain the cursor's current position inside the input field? I'm not holding my breath, but I thought I'd ask. Here's the cleanup code I'm using: $(".pricing").keyup(function(){ // clean up anything non-numeric **var itemprice = $("#itemprice").val().replace(/[^0-9\.]+/g, '');** // return the cleaner value back to the input field **$("#itemprice").val(itemprice);** });

    Read the article

  • Invoke a cleanup method for java user thread, when JVM stops the thread

    - by user309281
    Hi All I have J2SE application running in linux. I have stop application script in which i am doing kill of the J2SE pid. This J2SE application has 6 infinitely running user threads,which will be polling for some specific records in backend DB. When this java pid is killed, I need to perform some cleanup operations for each of the long running thread, like connecting to DB and set status of some transactions which are in-progress to empty. Is there a way to write a method in each of the thread, which will be called when the thread is going to be stopped, by JVM.

    Read the article

  • How do I align ReSharpers "cleanup code" with Visual Studio's "format document"

    - by Thomas Jespersen
    I'm a big fan of ReSharpers "cleanup code" feature. Especially the Solution wide clean up. But I use Visual Studio's Ctrl+K+D (Format document), it formats the code slightly differed than ReSharper. I'm on a quest to align ReSharper with Visual Studio (not the other way... because you can not share Visual Studio settings in the solution/source control system). So I'm after something like this: <Configuration> <CodeStyleSettings> <Sharing>SOLUTION</Sharing> <CSharp> <FormatSettings> <SPACE_AROUND_MULTIPLICATIVE_OP>True</SPACE_AROUND_MULTIPLICATIVE_OP> <SPACE_BEFORE_TYPEOF_PARENTHESES>False</SPACE_BEFORE_TYPEOF_PARENTHESES> </FormatSettings> </CSharp> </CodeStyleSettings> </Configuration> Which other settings will help ReSharper format code like Visual Studio?

    Read the article

  • Div Container Cleanup?

    - by Nto
    Just wondering if its possible to cleanup (less code needed to do the same thing) making this div container. Basically it's just a div with a background image however the top & bottom of the div have rounded graphical corners which is why I have a top, middle, and bottom div inside the container div. <div class="fbox"> <div class="ftop"></div> <div class="fmid"> Fullbox Text Goes Here </div> <div class="fbot"></div> </div> Css: .fbox { width: 934px; margin: 0 auto; opacity: 0.70; } .ftop { width: 934px; background:url(../images/cb/full.png) no-repeat 0 -34px; height: 17px; margin:0 } .fmid { width: 894px; padding-left: 20px; padding-right: 20px; background:url(../images/cb/fullmid.png) repeat-y; min-height: 50px; margin:0 } .fbot { width: 934px; background:url(../images/cb/full.png) no-repeat 0 -17px; height: 17px; margin:0 } Outcome: http://img709.imageshack.us/img709/6681/fbox.jpg

    Read the article

  • The 35 Best Tips and Tricks for Maintaining Your Windows PC

    - by Lori Kaufman
    When working (or playing) on your computer, you probably don’t think much about how you are going to clean up your files, backup your data, keep your system virus free, etc. However, these are tasks that need attention. We’ve published useful article about different aspects of maintaining your computer. Below is a list our most useful articles about maintaining your computer, operating system, software, and data. HTG Explains: Learn How Websites Are Tracking You Online Here’s How to Download Windows 8 Release Preview Right Now HTG Explains: Why Linux Doesn’t Need Defragmenting

    Read the article

  • How do I clean build and installs, ie un-build?

    - by Kaustubh P
    I have installed and downloaded and built mongodb, and just one works. $ mongo mongo: error while loading shared libraries: libmozjs.so: cannot open shared object file: No such file or directory $ /opt/mongo/bin/mongo /opt/mongo/bin/mongo: error while loading shared libraries: libboost_system-mt.so.1.38.0: cannot open shared object file: No such file or directory $ /usr/bin/mongo MongoDB shell version: 1.6.5 connecting to: test > I can remove the installation via apt-get. But how do I remove all things mongo that were built with make, and get a clean system? I followed this guide to build and install mongodb. Thanks.

    Read the article

  • Modernising settings, packages

    - by Sam Brightman
    The update manager (possibly combined with the janitor) does a reasonable job of bringing packages up to date with a new release, removing ones that are replaced by different projects etc. However, I'm left with the lingering feeling that quite a few settings are lingering from old releases. For example, some packages may be left around that I installed myself whereas now the functionality is provided by default. Another example is that my user doesn't get the new theme, and the panel bar is a mess. I can compare against an inactive user on the same system: everything seems tidier. There are also things like the explosion of System Preferences, user groups (inactive user, more recently created, is in groups that the older, active user isn't). In other areas (e.g. default font) I do seem to get given the new defaults. Another example is Spotlight-equivalent search. I remember Beagle and Tracker, I remember removing tracker when it used all system RAM and swap for 2 entire release cycles, but I don't know what I'm "supposed" to be using now. Is there even a default indexing-search installed and exposed? aptitude install ubuntu-desktop doesn't do anything, so the basics are in place package-wise. Is there any way to update my settings to the modern "Ubuntu way" without reinstalling from scratch? Can I do so selectively i.e. show the differences? Most of the time package management on Linux is an absolute joy compared to the alternatives, but if the desktop gets messed up after only a release or two, we're back to reinstalling just like Windows.

    Read the article

  • How do i clean up my harddrive?

    - by acidzombie24
    Not to long ago i was using only 35% of my HD. Just recently it shot up to 54% and my diskspace is 16gb so thats more then 3gigs that have been taken. From what i remember i failed to build mysql, i install gitolite which required me to build git from source which had a tons of dependencies (i think it was for building docs, i think i saw latex and other packages but i was drozy when i was installing). I suspect that is what is taking the diskspace. Anyways so far i deleted source folders i know i had and ran these commands. What else can i do? (3gigs is mighty) sudo apt-get autoclean sudo deborphan | xargs sudo apt-get -y remove --purge

    Read the article

  • Can you delete the Humanity icon theme safely?

    - by Alex
    I'm trying to reduce used space after running disk usage analyser, since I'm using a 40GB SSD. The icons use quite a bit of space! Could I delete those that I don't use, such as humanity? (I use Faenza-Dark) If it is possible, what would be the best way to this? as when I attempt to remove humanity in the Software Centre it says the software-centre itself must be removed. Similar problems arise with synaptic package manager. I was wary of just deleting the unused directories in usr/share/icons/. Thanks for the help!

    Read the article

  • which kernels can I safely purge?

    - by ecoologic
    I use the main answer of this question quite often to clear some space, but now I'm in extreme need and I'd like to better understand which kernels are safe to purge, my list is the following 10:50:58-673 - ~> dpkg -l | grep -Eo "^.i +linux-(image|headers)[^ ]+" | cut -c 5- | grep --color -E "$|"`uname -r` linux-headers-2.6.38-15 linux-headers-2.6.38-15-generic linux-headers-2.6.38-15-generic-pae linux-headers-2.6.38-16 linux-headers-2.6.38-16-generic linux-headers-2.6.38-16-generic-pae # current one linux-headers-generic linux-headers-generic-pae linux-headers-server linux-image-2.6.38-15-generic-pae linux-image-2.6.38-16-generic-pae linux-image-generic-pae linux-image-server Is it enough to keep linux-headers-2.6.38-15 linux-headers-2.6.38-15-generic linux-headers-2.6.38-15-generic-pae linux-headers-2.6.38-16 linux-headers-2.6.38-16-generic linux-headers-2.6.38-16-generic-pae # current one Or would this be enough linux-headers-2.6.38-15-generic-pae linux-headers-2.6.38-16-generic-pae # current one Or which other would be the shortest (keeping the previous one too)? And why?

    Read the article

  • How can I autoclean my gnome main menu?

    - by Bruce Connor
    I like to experiment with lots of different software in my Ubuntu install. Then, every time Ubuntu reaches a new release cycle, I simply do a clean install (instead of upgrading) to get rid of all the extra software (and their respective config files/folders). The only thing I always backup and carry to the next install (besides personal files) are the config files for gnome, so my desktop is always the way I like it. =) The problem with that, is that the different packages I test out never get properly uninstalled, so my gnome main menu is full of broken links referring to software I had in previous installations (which got carried over because I kept the gnome config files). Is there any automated way to go through my gnome main menu and remove any broken links? I know how to manually edit the menu, and I could go through it myself, but I'm looking for some script or package that will clean for me so I wouldn't have to do it manually every release cycle.

    Read the article

  • How can I detect and delete all lost configuration folders?

    - by Takkat
    Over the time there is an increasing number of hidden .configuration folders in my home folder. Many of these come from applications I only installed for testing or from applications that I don't use any more. I would not mind really but these folders do clutter my home, and worse than that sum up to as much as 80 GBytes by now. As there are also applications I never heard of (at least I can't remember I had installed them) I hesitate to delete them. Is there a way to find out which folders came from purged applications? May there even be a way to auto-remove a configuration folder when purging (not removing) the application that created it?

    Read the article

  • Is there a usage count for packages or programs?

    - by math
    Motivation: I want to remove applications I do not use to speed up my package processing tasks like dist upgrades, regular updates, but also for saving disk space and other reasons. I know this is a complex topic so first I will ask my question and second I will give some answers I already found out. Question: How do I find out which package I did not used at all? For example I always use the VLC so I could remove totem package. (Which I could have been used some day, yes.) Of course package dependencies could force me to have programs installed which I will never use. Notes: Find the packages which consume much space via synaptic: Select "Status" in lower left, select "Installed" in upper left, sort column on "size" in upper right. Then you can decide which big packages you really need. Use aptitude autoremove Use ubuntu-tweak's Janitor for removing old kernel packages, old configs, apt-cache entries, etc. Manually search for applications for a given task that you usually solve with your standard app. E.g. Movie player, Music player, Office program, Browser etc. (BTW: this is what I want to be helped with my question) When removing packages I always favour "apt-get purge" over "aptitude remove --purge" as aptitude often will also remove essential packages due to package dependencies. E.g. when removing "evolution" (as I use thunderbird) aptitude wants to remove also "ubuntu-desktop" and 756 other packages as well, while apt-get just removes evolution and its helping pacakges like evolution-common. Ubuntu lense gives me most recent used applications which are candidates for keeping :) Employ deborphan as I read in this related answer: How do I clean up my harddrive? I should certainly keep essential packages: Keep only essential packages This question is pretty much a duplicate of How to see what installed packages I have never used for cleaning purposes but covering only few aspects. However one answer suggests to use a program called unusedpkg but the link seems down. There is also a program called Kleen http://code.google.com/p/kleen/ but it won't compile in 11.10. However I hacked it to compile but the results are unusable, as for example the g++ package was marked as not used for 203, but actually I used it seconds ago for compiling Kleen itself ;) So don't use this tool. On http://wiki.debian.org/DebianPackageInformation I read the the package popularity-contest will produce log files with usage statistics. Unfortunately I didn't enabled the popularity contest so I can't find this log file.

    Read the article

  • Cleanup for control inside a FlowDocument

    - by Thorarin
    I have a custom control that I use inside a FlowDocument. The control uses a System.Drawing.ImageAnimator to display transparent, animated GIF images. Why is this such a pain in the butt in WPF anyway? :P In my original implementation, this was causing memory leaks when a paragraph containing the control was being deleted from the document, because the ImageAnimator kept a reference to the control for event handling. I've now implemented a WeakEventManager pattern which seems to indeed fix the leak itself, but I would like to stop "OnFrameChanged" events from being fired if a particular animated GIF is not currently in the document, instead of relying on the garbage collector to eventually collect the control objects and my event manager to notice that there no longer are valid listeners to the event. Basically, I would like to take a more active role in this and have the control react to being removed from the FlowDocument. Is there some way to do this? I've been unable to find it. OnVisualParentChanged doesn't get fired, because the direct parent (a Paragraph) is unchanged.

    Read the article

  • Memory cleanup on returned array from static method (objective-c)

    - by Michael Bordelon
    In objective-c, I have a utility class with a bunch of static methods that I call for various tasks. As an example, I have one method that returns an NSArray that I allocate in the static method. If I set the NSArray to autorelease, then some time later, the NSArray in my calling method (that is assigned to the returned pointer) losses it's reference because the original form the static method is cleaned up. I can't release the NSArray object in the static method because it needs to be around for the return and assignment. What is the right way to return an object (like the NSArray) from a static class, and have it hang around for the calling class, but then get cleaned up later when it is no longer needed? Do I have to create the object first in the caller and pass in a pointer to the object and then return that same object form the static method? I know this is a basic O-O problem, I just never had this issue in Java and I do not do much C/C++. Thanks for your help.

    Read the article

  • Django: how to cleanup form fields and avoid code duplication

    - by Alexander Konstantinov
    Quite often I need to filter some form data before using it (saving to database etc.) Let's say I want to strip whitespaces and replace repeating whitespaces with a single one in most of the text fields, in many forms. It's not difficult to do this using clean_<fieldname> methods: # Simplified model with two text fields class MyModel(models.Model): title = models.CharField() description = models.CharField() # Model-based form class MyForm(forms.ModelForm): class Meta: model = MyModel def clean_title(self): title = self.cleaned_data['title'] return re.sub(r'\s{2,}', ' ', title.strip()) def clean_description(self): description = self.cleaned_data['description'] return re.sub(r'\s{2,}', ' ', description.strip()) It does exactly what I need, and has a nice side effect which I like: if user enters only whitespaces, the field will be considered empty and therefore invalid (if it is required) and I don't even have to throw a ValidationError. The obvious problem here is code duplication. Even if I'll create some function for that, say my_text_filter, I'll have to call it for every text field in all my forms: from myproject.filters import my_text_filter class MyForm(forms.ModelForm): class Meta: model = MyModel def clean_title(self): return my_text_filter(self.cleaned_data['title']) def clean_description(self): return my_text_filter(self.cleaned_data['description']) The question: is there any standard and simple way in Django (I use version 1.2 if that matters) to do this (like, for example, by adding property validators = {'title': my_text_filter, 'description': my_text_filter} to MyModel), or at least some more or less standard workaround? I've read about form validation and validators in the documentation, but couldn't find what I need there.

    Read the article

  • C sharp code cleanup : resharper

    - by Ankit Rathod
    Hello, I just used Resharper in one application and it made me feel as if i don't know how to code at all in C# :(. On every line it gave me it's suggestions :- Few of Resharper's favorite suggestions are :- 1) SomObject o = new SomeObject(); Resharper will convert to : var o = new SomeObject() 2) this.Loaded += new RoutedEventHandler(MainPage_Loaded); to this.Loaded += MainPage_Loaded; 3) convert my variables and putting _ in front of all instance variables. 4) Removing class parent's name. I tested this on Silverlight. public partial class MainPage : UserControl to public partial class MainPage EDIT :- 5) replace instance variable this.variable = somevalue to variable = somevalue Are all of these really necessary? Is it really going to affect the efficiency of my program? I mean what good is it going to do by replacing my class names with var keyword. After all var is also replaced with class name at compile time. Is it doing because it has been programmed to do or do these things really affect in some or another way? Thanks in advance :)

    Read the article

  • Multi-Threading - Cleanup strategy at program end

    - by weismat
    What is the best way to finish a multi-threaded application in a clean way? I am starting several socket connections from the main thread in seperate sockets and wait until the end of my business day in the main thread and use currently System.Environment.Exit(0) to terminate it. This leads to an unhandled execption in one of the childs. Should I stop the threads from the list? I have been reluctant to implement any real stopping in the childs yet, thus I am wondering about the best practice. The sockets are all wrapped nicely with proper destructors for logging out and closing, but it still leads to errors.

    Read the article

  • How to do cleanup reliably in python?

    - by Cheery
    I have some ctypes bindings, and for each body.New I should call body.Free. The library I'm binding doesn't have allocation routines insulated out from the rest of the code (they can be called about anywhere there), and to use couple of useful features I need to make cyclic references. I think It'd solve if I'd find a reliable way to hook destructor to an object. (weakrefs would help if they'd give me the callback just before the data is dropped. So obviously this code megafails when I put in velocity_func: class Body(object): def __init__(self, mass, inertia): self._body = body.New(mass, inertia) def __del__(self): print '__del__ %r' % self if body: body.Free(self._body) ... def set_velocity_func(self, func): self._body.contents.velocity_func = ctypes_wrapping(func) I also tried to solve it through weakrefs, with those the things seem getting just worse, just only largely more unpredictable. Even if I don't put in the velocity_func, there will appear cycles at least then when I do this: class Toy(object): def __init__(self, body): self.body.owner = self ... def collision(a, b, contacts): whatever(a.body.owner) So how to make sure Structures will get garbage collected, even if they are allocated/freed by the shared library? There's repository if you are interested about more details: http://bitbucket.org/cheery/ctypes-chipmunk/

    Read the article

  • Git history cleanup doesn't seem to have an effect

    - by eaigner
    Hi, i ran the following 2 commands to clean up .pbxuser and .mode1v3 files from my git repository, but afterwards when i e.g. fire up gitx i can still see them in the history. git filter-branch --tree-filter "git rm -rf --cached --ignore-unmatch *.pbxuser" HEAD rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune What did i misunderstand here? The commands seem to do the job but why is gitx still viewing the diffs in its history? Regards, Erik

    Read the article

  • Folder cleanup with PowerShell

    - by 280Z28
    I'd like to clean up some directories after my script runs by deleting certain folders and files from the current directory if they exist. Originally, I structured the script like this: if (Test-Path Folder1) { Remove-Item -r Folder1 } if (Test-Path Folder2) { Remove-Item -r Folder2 } if (Test-Path File1) { Remove-Item File1 } Now that I have quite a few items listed in this section, I'd like to clean it up. How can I do so? Side note: The items are cleaned up before the script runs, since they are left over from the previous run in case I need to examine them.

    Read the article

  • Scheduled Task: Directory cleanup using windows batch script

    - by d03boy
    I have a shared disk that I would like to clean up once per week using a scheduled task of some sort. I would like to use a batch script so that the system admins can easily modify it or reuse it on other directories when needed. The directory has files with multiple file extensions but the ones that need to be deleted end in .bkf and must be over 2 weeks old. Does anyone have a batch script solution for this windows server (not sure which version)?

    Read the article

  • Cleanup ActiveRecord field

    - by Beer Brother
    I have model Article it has field title with some text that may contain some "magic" patterns. In some cases i need to process text in title and other cases i don't, but in last case i need to get string w/o that patterns. For example i have title value like "Something **very** interesting" and when i call @article.title i need to get cleaned up string like "Something very interesting", but when i call @article.title_raw i need get original string. The problem also is that i have working application and i cannt do "revolution" but what way to go... -- Excuse me for my bad English.

    Read the article

  • How to cleanup old Failed Builds in TeamCity?

    - by dr. evil
    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.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >