Daily Archives

Articles indexed Sunday March 21 2010

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

  • mysql update where some field is max

    - by Syom
    The table videos has the following fields: id | average | name How can i write the query, to update the name of video, which have the max average, or the second by size average!!! i can do that with two queries, by selecting the max(average) from the table, and then update the name, where ite average equal to max or to second value, but i want to do that in one query. i think the query must look like this UPDATE videos SET name = 'something' WHERE average = MAX(average) Any suggestions?

    Read the article

  • Storing callbacks in a dictionary (Objective C for the iPhone)

    - by Casebash
    I am trying to store callbacks in a dictionary. I can't use blocks as the iPhone doesn't support this (unless you use plblocks). I tried using functions, but apparently NSMutableDictionary doesn't allow these pointers (wants an id) I tried using class methods, but I couldn't find a way to obtain a pointer to these I could try using functions with the c++ stl hashmap (if it is supported in Objective C++), but apparently this can slow compilation times. I could try storing both a class and a selector, but that seems rather messy. What would be the best way to do this?

    Read the article

  • What is Causing This Memory Leak in Delphi?

    - by lkessler
    I just can't figure out this memory leak that EurekaLog is reporting for my program. I'm using Delphi 2009. Here it is: Memory Leak: Type=Data; Total size=26; Count=1; The stack is: System.pas _UStrSetLength 17477 System.pas _UStrCat 17572 Process.pas InputGedcomFile 1145 That is all there is in the stack. EurekaLog is pointing me to the location where the memory that was not released was first allocated. According to it, the line in my program is line 1145 of InputGedcomFile. That line is: CurStruct0Key := 'HEAD' + Level0Key; where CurStruct0Key and Level0Key are simply defined in the procedure as local variables that should be dynamically handled by the Delphi memory manager when entering and leaving the procedure: var CurStruct0Key, Level0Key: string; So now I look at the _UStrCat procedure in the System Unit. Line 17572 is: CALL _UStrSetLength // Set length of Dest and I go to the _UStrSetLength procedure in the System Unit, and the relevant lines are: @@isUnicode: CMP [EAX-skew].StrRec.refCnt,1 // !!! MT safety JNE @@copyString // not unique, so copy SUB EAX,rOff // Offset EAX "S" to start of memory block ADD EDX,EDX // Double length to get size JO @@overflow ADD EDX,rOff+2 // Add string rec size JO @@overflow PUSH EAX // Put S on stack MOV EAX,ESP // to pass by reference CALL _ReallocMem POP EAX ADD EAX,rOff // Readjust MOV [EBX],EAX // Store MOV [EAX-skew].StrRec.length,ESI MOV WORD PTR [EAX+ESI*2],0 // Null terminate TEST EDI,EDI // Was a temp created? JZ @@exit PUSH EDI MOV EAX,ESP CALL _LStrClr POP EDI JMP @@exit where line 17477 is the "CALL _ReallocMem" line. So then what is the memory leak? Surely a simple concatenate of a string constant to a local string variable should not be causing a memory leak. Why is EurekaLog pointing me to the ReallocMem line in a _UStrSetLength routine that is part of Delphi? This is Delphi 2009 and I am using the new unicode strings. Any help or explanation here will be much appreciated.

    Read the article

  • Intercept page request behind firewall return altered content with php and apache

    - by Matthew
    I'm providing free wifi service and need an ad to be added to all page requests. Currently I have a router forwarding all http requests to an apache server, which redirects all requests to an index.php page. The index.php page reads the request, fetches the content from the appropriate site, and edits the content to include the ad. The problem is that all images and css files etc. cannot be accessed, because when the browser tries to get the image <img src="site.com/image.jpg"> it's just redirected back to the index.php. I can change settings for the router (running dd-wrt) and the webserver (apache2 and php 5.2). Is there a solution that allows content to be edited before returning to the client, and allows css and images to be accessed?

    Read the article

  • Why is EXC_BAD_ACCESS so unhelpful?

    - by Dustin
    First let me say I come from a background in Flash/AS3, which I realize is not as strict about most things as iPhone/Objective-C. I suspect my question actually applies to AS3 as well, but let me ask it as pertaining to Obj-c. Why is the error EXC_BAD_ACCESS, and others like it, so unhelpful? I realize that it normally means mismanagement of memory somewhere, but why can't it tell you more about the problem. For instance why doesn't it say "EXC_BAD_ACCESS, you tried to pass pointer suchAndSuch on line 123, however you're an idiot, because you released it on line 69 so it's not available anymore"? I realize I can use the debugger to get more clues about where my error occurred, but many times this is only marginally helpful. For instance sometimes none of the messages in the stack/thread/whatever are even my code. Other times it is my code but on the top of the stack will be a message that has 4+ parameters, ok thanks debugger you narrowed it down to 4 possible pointers by why can't you just tell me which one!? I'm guessing there's just some fundamental explanation that I missed because of the background I came from, not needing to worry about memory and such. Although there is an error that can happen a lot in AS3 development that is equally mysterious and along the same lines. "Error #1009: Cannot access a property or method of a null object reference" which almost always means a variable you were expecting to be holding something is actually null. Why doesn't it tell me WHICH variable?!

    Read the article

  • Embedded pdf object steals focus and will not let it go

    - by Kristian Hebert
    Hi guys, I was given the task of adding some usability to one of our applications, ie. make sure that every controll has a shortcut key, and that they can be reached by "tabbing" through the page. The gui runs in a IE. control on a winform, and consists of asp.net pages, so basically it is just asp.net always running in internet explorer. My problem is that one of the pages has an embeded pdf in it, like so: <object tabindex="-1" height="273" width="663" visible="false" type="Application/pdf" data="showpdf.ashx#navpanes=0"></object> showpdf.ashx is an httphandler, that streams the pdf contents to the response. It does not handle focus in any way. Now when I run this page, the pdf application steals focus, no matter what I do to set it to another control. And when it takes focus, I cannot take it back with the keyboard. Only a mouseclick on the page will set it to another control. I have tried to set focus in code behind OnPreRender, or in jevescript, but no luck. It seems that the http handler always runs after all the other code, and it sets focus on the pdf object. Any thought would be greatly appreciated.

    Read the article

  • Using LZMA SDK in C++

    - by Milad
    I am trying to use LZMA SDK to compress a file in my program. I have download the SDK but I don't know how to use it. Can anyone tell me what steps I need to take to make this work? Any help would be highly appreciated I am almost a newbie to C and C++ world

    Read the article

  • Facebook FQL - How do I fetch the posts I made to a friend's wall

    - by simianarmy
    I have a facebook desktop app with some test users all having granted the stream_read & offline access permissions. I can easily retrieve posts to each users' stream & profile. What I cannot do easily is retrieve posts that a user has made to one of their friend's walls. In fact, this used to work with a rather complex multiquery, but has stopped working now, or is working only intermittently... Does anyone care to share their method if one exists or discuss what restrictions there might be to this type of complex querying?

    Read the article

  • Entity Framework 4.0: Creating objects of correct type when using lazy loading

    - by DigiMortal
    In my posting about Entity Framework 4.0 and POCOs I introduced lazy loading in EF applications. EF uses proxy classes for lazy loading and this means we have new types in that come and go dynamically in runtime. We don’t have these types available when we write code but we cannot forget that EF may expect us to use dynamically generated types. In this posting I will give you simple hint how to use correct types in your code. The background of lazy loading and proxy classes As a first thing I will explain you in short what is proxy class. Business classes when designed correctly have no knowledge about their birth and death – they don’t know how they are created and they don’t know how their data is persisted. This is the responsibility of object runtime. When we use lazy loading we need a little bit different classes that know how to load data for properties when code accesses the property first time. As we cannot add this functionality to our business classes (they may be stored through more than one data access technology or by more than one Data Access Layer (DAL)) we create proxy classes that extend our business classes. If we have class called Product and product has lazy loaded property called Customer then we need proxy class, let’s say ProductProxy, that has same public signature as Product so we can use it INSTEAD OF product in our code. ProductProxy overrides Customer property. If customer is not asked then customer is null. But if we ask for Customer property then overridden property of ProductProxy loads it from database. This is how lazy loading works. Problem – two types for same thing As lazy loading may introduce dynamically generated proxy types we don’t know in our application code which type is returned. We cannot be sure that we have Product not ProductProxy returned. This leads us to the following question: how can we create Product of correct type if we don’t know the correct type? In EF solution is simple. Solution – use factory methods If you are using repositories and you are not using factories (imho it is pretty pointless with mapper) you can add factory methods to your EF based repositories. Take a look at this class. public class Event {     public int ID { get; set; }     public string Title { get; set; }     public string Location { get; set; }     public virtual Party Organizer { get; set; }     public DateTime Date { get; set; } } We have virtual member called Organizer. This property is virtual because we want to use lazy loading on this class so Organizer is loaded only when we ask it. EF provides us with method called CreateObject<T>(). CreateObject<T>() is member of ObjectContext class and it creates the object based on given type. In runtime proxy type for Event is created for us automatically and when we call CreateObject<T>() for Event it returns as object of Event proxy type. The factory method for events repository is as follows. public Event CreateEvent() {     var evt = _context.CreateObject<Event>();     return evt; } And we are done. Instead of creating factory classes we created factory methods that guarantee that created objects are of correct type. Conclusion Although lazy loading introduces some new objects we cannot use at design time because they live only in runtime we can write code without worrying about exact implementation type of object. This holds true until we have clean code and we don’t make any decisions based on object type. EF4.0 provides us with very simple factory method that create and return objects of correct type. All we had to do was adding factory methods to our repositories.

    Read the article

  • Microsoft SQL for PHP driver

    - by Jonas B
    Hello I am running a W2K3 x64 server with IIS 7 + FastCGI + PHP 5.3 (x64) I have trouble geting the SQL for php driver to work. It seems it doesn't get loaded, but no error is thrown. I've doublechedked the php.ini a multitude of times and I'm pretty sure I use the right version of the sql for php driver (version 1.1 CTP) and sql native client x64 is installed. Any ideas what could be wrong? Thanks

    Read the article

  • Postfix throttling for outgoing messages

    - by Sergey Kovalev
    I need Postfix to send outgoing messages (from local PHP) with a certain rate. Say, one message in 120 seconds. Any messages exceeding this rate should be queued (delayed) and delivered later. Policyd is not what I'm looking for. I don't need limiting overall number of messages sent. I need a pause (120s) between any two messages beeing sent. Tried this config, but it's not working: initial_destination_concurrency = 1 default_destination_concurrency_limit = 1 default_destination_rate_delay = 120 default_destination_recipient_limit = 1 default_process_limit = 1 Any suggestions?

    Read the article

  • Blackberry Enterprise Server v5.x not forwarding mail to devices

    - by TheWellington
    My BlackBerry enterprise server recently stopped forwarding messages to devices. In fact, the server claims that the last time it communicated with all the devices associated with it, was on Thursday night (2 nights ago.) The catch is this, the Exchange server is running properly (or as properly as Exchange can run :) ) The SQL server seems to be running properly. And the Blackberry Enterprise server seems to be running correctly. Other than the fact that the server has not communicated with my device since Thursday, and the fact that I am not getting messages, there is nothing wrong. How do I get these message to be forwarded to devices again? I have restarted the BES services int he order suggested by the BlackBerry folks

    Read the article

  • Restore deleted default folders

    - by Helena T.
    I was tinkering with my new laptop and, on purpose, deleted those default folders in my "home" directory: "My Music", "Links", "Favorites". This, because, i decided i wanted all my data on another partition, leaving C: only for applications and configs files. But now, some of the explorer functionalities are gone: i cannot use the Favorites tree in the left side pane, also discovered that "My Documents" stores some PowerShell config file. I feel like i misunderstood this folders' purpose and by deleting them, provoked some Explorer instability. Is there any way to restore them? I do not seem to find it. Thank you for taking the time to read this.

    Read the article

  • Are Visual Studio Setup Projects suitable for complex setups

    - by Robert
    Are "Visual Studio Setup" Projects suitable for complex setups in different versions? The application is rather large ( 500.000 lines of code) and is under continuous development. Every 6 to 10 month a new version gets released. We have multiple configuration files (INI and XML), registry keys, database migration scripts, etc. The application is in the progress of being migrated from VB6 to .NET . The old installer was build with Installshield. The feedback to Installshield is: Bad adaptability, bad reuse - thats way we are evaluating "Visual Studio Setup" as an alternative. Other products we consider: Free Solutions WiX NSIS Commercial Solutions Installshield (again..) Wise Advanced Installer sth. missing? Solutions we don't like to consider: Inno Setup (It just doesn't feel right)

    Read the article

  • Display iphone application settings within your application

    - by Dougnukem
    The iphone supports a means of defining your application's settings such that it will automatically create a UI in the Settings app. I want to also allow the user to edit the application settings within the application but it'd be nice to reuse the same UI that is automatically created. See: Application Settings Is there a way to have your application display the settings using the same UI that the Settings application does?

    Read the article

  • The problem with installing PIL using virtualenv or buildout.

    - by Alexander Artemenko
    When I install PIL using easy_install or buildout it installs in such way, that I must do 'import Image', not 'from PIL import Image'. However, if I do "apt-get install python-imaging" or use "pip -E test_pil install PIL", all work fine. Here are examples of how I trying to install PIL using virtualenv: # virtualenv --no-site-packages test_pil # test_pil/bin/easy_install PIL # test_pil/bin/python Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import PIL Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named PIL I see, that easy_install pack PIL into the Egg, and PIP does not. Same thing with buildbot, it uses eggs. How could I install PIL properly, using easy_install or buildout?

    Read the article

  • Really slow obtaining font metrics.

    - by Artur
    So the problem I have is that I start my application by displaying a simple menu. To size and align the text correctly I need to obtain font metrics and I cannot find a way to do it quickly. I tested my program and it looks like whatever method I use to obtain font metrics the first call takes over 500 milliseconds!? Because of it the time it takes to start-up my application is much longer than necessary. I don't know if it is platform specific or not, but just in case, I'm using Mac OS 10.6.2 on MacBook Pro (hardware isn't an issue here). If you know a way of obtaining font metrics quicker please help. I tried these 3 methods for obtaining the font metrics and the first call is always very slow, no matter which method I choose. import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import javax.swing.JFrame; public class FontMetricsTest extends JFrame { public FontMetricsTest() { setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Font font = new Font("Dialog", Font.BOLD, 10); long start = System.currentTimeMillis(); FontMetrics fontMetrics = g2.getFontMetrics(font); // LineMetrics fontMetrics1 = // font.getLineMetrics("X", new FontRenderContext(null, false, false)); // FontMetrics fontMetrics2 = g.getFontMetrics(); long end = System.currentTimeMillis(); System.out.println(end - start); g2.setFont(font); } public static void main(String[] args) { new FontMetricsTest(); } }

    Read the article

  • How to fix "containing working copy admin area is missing" in SVN ?

    - by e-satis
    I deleted manually a directory I just added, offline, in my repository. I can't restore the directory. Any attempt to do an update or a commit will fail with : "blabla/.svn" containing working copy admin area is missing. I understand why, but is there anyway to fix this. I don't want to checkout the entire repo and add my changes to it manually, it would take hours.

    Read the article

  • License Check before executing

    - by jaklucky
    Hi, We have an application (written in C# on .NET Framework 3.5) that is licensed using our custom licensing mechanism. In the current implementation, in each method we first check for if the machine has valid license or not. To me, it is little bit awkward. Is there any way to let the runtime check for the license before creating the object or excuting a method? Will writing a custom attribute solves this problem? Any ideas or solutions are greatly appreciated. Thank you, Suresh

    Read the article

  • Rle Encoding...What's the wrong?

    - by FILIaS
    I'm trying to make a Rle Encoder Programme.I read the way it works on notes on net. And i tried to fix my code! Regardless I think that the structure and logic of code are right,the code doesnt work! It appears some strange 'Z' as it runs. I really cant find what;s wrong! Could u please give me a piece of advice? Thanx in advance... #include <stdio.h> int main() { int count; unsigned char currChar,prevChar=EOF; while(currChar=getchar() != EOF) { if ( ( (currChar='A')&&(currChar='Z') ) || ( (currChar='a')&&(currChar='z') ) ) { printf("%c",currChar); if(prevChar==currChar) { count=0; currChar=getchar(); while(currChar!='EOF') { if (currChar==prevChar) count++; else { if(count<=9) printf("%d%c",count,prevChar); else { printf("%d%c",reverse(count),prevChar); } prevChar=currChar; break; } } } else prevChar=currChar; if(currChar=='EOF') { printf("%d",count); break; } } else { printf("Error Message:Only characters are accepted! Please try again! False input!"); break; } } return 0; } int reverse(int x) { int piliko,ypoloipo,r=0; x=(x<0)?-x:x; while (x>0) { ypoloipo=x%10; piliko=x/10; r=10*r+ypoloipo; x=piliko; } printf("%d",r); return 0; }

    Read the article

  • getline(cin, variable) not wanting to work properly in c++?

    - by Jeff
    Here's my program so far: int main() { char choice = 'D'; string inputString; cout << "Please input a string." << endl; getline(cin, inputString); LetterCount letterCount(inputString); while(choice != 'E') { cout << "Please choose from the following: " << endl << "A) Count the number of vowels in the string." << endl << "B) Count the number of consonants in the string." << endl << "C) Count both the vowels and consonants in the string." << endl << "D) Enter another string." << endl << "E) Exit the program." << endl; cin >> choice; if(choice == 'A' || choice == 'a') { cout << "There are " << letterCount.vowelCount() << " vowels in this string." << endl; } else if(choice == 'B' || choice == 'b') { cout << "There are " << letterCount.consonantCount() << " consonants in this string." << endl; } else if(choice == 'C' || choice == 'c') { cout << "There are " << letterCount.vowelCount() << " vowels and " << letterCount.consonantCount() << " consonants in this string, for a total of " << (letterCount.vowelCount() + letterCount.consonantCount()) << " letters." << endl; } else if(choice == 'D' || choice == 'd') { cout << "Please type in another string." << endl; getline(cin, inputString); letterCount.setInputString(inputString); } else { choice = 'E'; } } } I'm only including the main as it's the issue giver here, everything else functions properly. The problem comes up when I use choice 'D' (input a new string.) as soon as enter is hit, the program returns right to the choice prompt and sets the inputString variable to blank (not the word blank, but nothing in it) the first getline(cin, inputString) works perfectly fine, the second one is the issue giver...any suggestions?

    Read the article

  • How Drupal works?

    - by alice
    I have yet to see a comprehensive overview about how Drupal really works. Most of the tutorials are about lame things, like adding a module or configuring a site. Where is a flowchart about how the page gets generated? Most of the documentation is clumsy too. What's the best resource for learning how Drupal really works?

    Read the article

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