Daily Archives

Articles indexed Sunday March 21 2010

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

  • Python memory leaks

    - by Fragsworth
    I have a long-running script which, if let to run long enough, will consume all the memory on my system. Without going into details about the script, I have two questions: Are there any "Best Practices" to follow, which will help prevent leaks from occurring? What techniques are there to debug memory leaks in Python?

    Read the article

  • How to convert HTML to XHTML?

    - by JRoppert
    I need to convert HTML documents into valid XML, preferably XHTML. What's the best way to do this? Does anybody know a toolkit/library/sample/...whatever that helps me to get that task done? To be a bit more clear here, my application has to do the conversion automatically at runtime. I don't look for a tool that helps me to move some pages to XHTML manually.

    Read the article

  • Use RAID for desktop computer?

    - by NickAldwin
    I'm building a new computer over the summer. I'm fairly competent in computer hardware, and am thus building the computer from scratch. I have everything planned out, but I was wondering if I should consider RAID/what RAID to use. I plan to purchase 2x1TB drives. Currently I'm leaning toward RAID 1 for the redundancy -- I've heard newer super-capacity drives fail more often than one would think, and I don't want to have a problem and lose all my data. What do you think? My mobo supports RAID 0/1/5/10. Is it worth it to use RAID at all, or should I just use a backup service like Mozy? Should I consider RAID 0 instead, for the performance? I'm kind-of going back and forth on this one. Thanks a lot for your help. EDIT: I'd like to avoid the OS drive different from Data drive situation, because that can get frustrating when programs like to store a lot of data in their program files folder. I've lived with that situation before and it gets annoying after a while.

    Read the article

  • Learning Python and trying to get first two letters and last two letters of a string.

    - by Sergio Tapia
    Here's my code: # B. both_ends # Given a string s, return a string made of the first 2 # and the last 2 chars of the original string, # so 'spring' yields 'spng'. However, if the string length # is less than 2, return instead the empty string. def both_ends(s): if len(s) <= 2: return "" else: return s[0] + s[1] + s[len(s)-2] + s[len(s-1)] # +++your code here+++ return Unfortunately my program doesn't run. :( I'm sure I'm overlooking something since I'm a newbie with Python. Here's the error: > Traceback (most recent call last): File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 120, in <module> main() File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 97, in main test(both_ends('spring'), 'spng') File "C:\Users\Sergio\Desktop\google-python-exercises\google-python-exercises\basic\string1.py", line 44, in both_ends return s[0] + s[1] + s[len(s)-2] + s[len(s-1)] TypeError: unsupported operand type(s) for -: 'str' and 'int' Thanks for the help guys. :D

    Read the article

  • Access virtualhosts over LAN (Also in xpmode (Virtual PC))

    - by Pheter
    Hi, I am running Wamp on my computer (the host). I have set up several virtualhosts in apache and they are working fine when I access them from the same computer (host). I have installed Windows XPMode on my computer (which is running windows 7). XPMode (which uses Virtual PC) is set up to use a NAT network. The network in XPMode is working fine, and I can access the host PC via the IP address 192.168.1.5, just as I would if I was using any physical computer on the same network. I can view all the web pages at 192.168.1.5 and it's subdirectories. However, I cannot access any of the subdomains that are configured in the virtualhosts of the host computer. How can I access the subdomains? I don't think that the fact that I am using XPMode and am using a virtualized OS has anything to do with it, but I thought that it was worth mentioning.

    Read the article

  • A question about Scala Objects

    - by Randin
    In the example for coding with Json using Databinder Dispatch Nathan uses an Object (Http) without a method, shown here: import dispatch._ import Http._ Http("http://www.fox.com/dollhouse/" >>> System.out ) How is he doing this?

    Read the article

  • .Except<T> is throwing an Exception

    - by Jason
    I have the following code: Public Shared Function GetAvailableManufacturers() As List(Of Manufacturer) 'first get all the live orders and extract their mfrs' Dim sos As List(Of OrderForm) = GetFormsByStatus(StockStatus.Building) Dim unavailableMfrs As New List(Of Manufacturer) For Each so As StockingOrder In sos unavailableMfrs.Add(so.Source) Next 'then remove all mfrs with an open SO from a list of all mfrs' Dim allMfrs As List(Of Manufacturer) = Manufacturer.GetManufacturers Return allMfrs.Except(unavailableMfrs) <----- error here End Function Explanation of what the above does: GetFormsByStatus() self-explanatory GetManufacturers() returns a list of all manufacturers in the database My idea to get available manufacturers was to get a list of all the manufacturers in my open forms, then get a list of all manufacturers and exclude all the manufacturers in the first list, illustrated like so (pseudo): List A: {1,2,3,4,5,6,7,8,9,10} List B: {5,7,10} Result: {1,2,3,4,6,8,9} I have set up my Manufacturer class according to this article so that it can be compared, but I'm still getting this error: Unable to cast object of type '<ExceptIterator>d__92'1[csCore.Manufacturer]' to type 'System.Collections.Generic.List'1[csCore.Manufacturer]'. I thought at first that because during testing GetFormsByStatus() returns 0 results maybe that was causing problems, but it doesn't make sense that Except() wouldn't work if the provided list had 0 items. Can anyone spot what I'm doing wrong? Thanks so much!

    Read the article

  • dynamiclly schedule a lead sales agent

    - by Josh
    I have a website that I'm trying to migrate from classic asp to asp.net. It had a lead schedule, where each sales agent would be featured for the current day, or part of the day.The next day a new agent would be scheduled. It was driven off a database table that had a row for each day in it. So to figure out if a sales agent would show on a day, it was easy, just find today's date in the table. Problem was it ran out rows, and you had to run a script to update the lead days 6 months at a time. Plus if there was ever any change to the schedule, you had to delete all the rows and re-run the script. So I'm trying to code it where sql server figures that out for me, and no script has to be ran. I have a table like so CREATE TABLE [dbo].[LeadSchedule]( [leadid] [int] IDENTITY(1,1) NOT NULL, [userid] [int] NOT NULL, [sunday] [bit] NOT NULL, [monday] [bit] NOT NULL, [tuesday] [bit] NOT NULL, [wednesday] [bit] NOT NULL, [thursday] [bit] NOT NULL, [friday] [bit] NOT NULL, [saturday] [bit] NOT NULL, [StartDate] [smalldatetime] NULL, [EndDate] [smalldatetime] NULL, [StartTime] [time](0) NULL, [EndTime] [time](0) NULL, [order] [int] NULL, So the user can schedule a sales agent depending on their work schedule. Also if they wanted to they could split certain days, or sales agents by time, So from Midnight to 4 it was one agent, from 4-midnight it was another. So far I've tried using a numbers table, row numbers, goofy date math, and I'm at a loss. Any suggestions on how to handle this purely from sql code? If it helps, the table should always be small, like less than 20 never over 100. update After a few hours all I've managed to come up with is the below. It doesn't handle filling in days not available or times, just rotates through all the sales agents with leadTable as ( select leadid,userid,[order],StartDate, case DATEPART(dw,getdate()) when 1 then sunday when 2 then monday when 3 then tuesday when 4 then wednesday when 5 then thursday when 6 then friday when 7 then saturday end as DayAvailable , ROW_NUMBER() OVER (ORDER BY [order] ASC) AS ROWID from LeadSchedule where GETDATE()>=StartDate and (CONVERT(time(0),GETDATE())>= StartTime or StartTime is null) and (CONVERT(time(0),GETDATE())<= EndTime or EndTime is null) ) select userid, DATEADD(d,(number+ROWID-2)*totalUsers,startdate ) leadday from (select *, (select COUNT(1) from leadTable) totalUsers from leadTable inner join Numbers on 1=1 where DayAvailable =1 ) tb1 order by leadday asc

    Read the article

  • SQL Server high CPU and I/O activity database tuning

    - by zapping
    Our application tends to be running very slow recently. On debugging and tracing found out that the process is showing high cpu cycles and SQL Server shows high I/O activity. Can you please guide as to how it can be optimised? The application is now about an year old and the database file sizes are not very big or anything. The database is set to auto shrink. Its running on win2003, SQL Server 2005 and the application is a web application coded in c# i.e vs2005

    Read the article

  • How to Unit Test HtmlHelper similar to using(Html.BeginForm()){ }

    - by DaveDev
    Can somebody please suggest how I could write a Unit Test with Moq for following HtmlHelper method? public static HtmlTagBase GenerateTag<T>(this HtmlHelper htmlHelper , object elementData , object attributes) where T : HtmlTagBase { return (T)Activator.CreateInstance(typeof(T) , htmlHelper.ViewContext , elementData , attributes); } which you would use as follows (please note the using statement - this is causing me confusion): <%--Model is a type of ShareClass--%> <% using (Html.GenerateTag<DivTag>(Model)) { %> My Div <% } %> using this method, if you specify T as type DivTag, where ShareClass is defined as public class ShareClass { public string Name { get; set; } public string Type { get; set; } public IEnumerable<Fund> Funds { get; set; } public ShareClass(string name, string shareClassType) { this.Name = name; this.Type = shareClassType; } } the following html will be rendered: <div class="ShareClass" shareclass-type="ShareClass_A" shareclass-name="MyShareClass">My Div</div>

    Read the article

  • Keeping DB Table sorted using multi-field formula (Microsoft SQL Server)

    - by user298167
    I have a JOB table, with two interesting columns: Creation Date Importance (high - 3, medium 2, low - 1). A JOB record's priority calculated like this: Priority = Importance * (time passed since creation) The problem is, every time I would like to pick 200 jobs with highest priority, and I don't want to resort the table. Is there a way to keep rows sorted? I was also thinking about having three tables one for High, Medium and Low and then sort those by Creation Date.

    Read the article

  • links in codeigniter

    - by Patrick
    hi All, I'm experimenting with codeigniter but don't really understand how links work. for example, I have a link like this: localhost/ci/welcome/cat/7 My base url is localhost/ci, so by clicking on this link I would expect the method "cat" of controller "welcome" to be called. This method is very simple: function cat() { echo "just a test."; } Pretty basic - I would expect to see the text on screen, but I just see a 404 -page not found error. What could be the problem?

    Read the article

  • pdb show different variable values than print statements

    - by martin
    Hi, everyone. I am debugging a python module with homemade c extensions. The output seems correct when I print it with 'p' in pdb. But if I use a normal print statement or pickle it, the output is wrong. What could be causing pdb to show different values than normal execution? I can even step to the print statement in debug mode, and pdb will show the correct value but the program will print the wrong one. The problem seems to happen only when I have called a certain c extension earlier. Glad to post code if that helps. Thank you.

    Read the article

  • Address of function is not actual code address

    - by mrjoltcola
    Debugging some code in Visual Studio 2008 (C++), I noticed that the address in my function pointer variable is not the actual address of the function itself. This is an extern "C" function. int main() { void (*printaddr)(const char *) = &print; // debug shows printaddr == 0x013C1429 } Address: 0x013C4F10 void print() { ... } The disassembly of taking the function address is: void (*printaddr)(const char *) = &print; 013C7465 C7 45 BC 29 14 3C 01 mov dword ptr [printaddr],offset print (13C1429h) What am I missing?

    Read the article

  • Can memory be cleaned up?

    - by Tom
    I am working in Delphi 5 (with FastMM installed) on a Win32 project, and have recently been trying to drastically reduce the memory usage in this application. So far, I have cut the usage nearly in half, but noticed something when working on a separate task. When I minimized the application, the memory usage shrunk from 45 megs down to 1 meg, which I attributed to it paging out to disk. When I restored it and restarted working, the memory went up only to 15 megs. As I continued working, the memory usage slowly went up again, and a minimize and restore flushed it back down to 15 megs. So to my thinking, when my code tells the system to release the memory, it is still being held on to according to Windows, and the actual garbage collection doesn't kick in until a lot later. Can anyone confirm/deny this sort of behavior? Is it possible to get the memory cleaned up programatically? If I keep using the program without doing this manual flush, I get an out of memory error after a while, and would like to eliminate that. Thanks.

    Read the article

  • JQuery validation without requiring MS scripts in asp.net mvc2 project

    - by Jim Geurts
    Is it possible to use the new client side validation features of asp.net MVC 2 without having to use the MS scripts (MicrosoftAjax.js, MicrosoftMvcAjax.js, MicrosoftMvcValidation.js)? I use JQuery throughout my application; JQuery has a great plugin for validation and I don't really want to force my users to load MS scripts just for validation. Is this possible? If so, any suggestions for how to accomplish it are appreciated.

    Read the article

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