Search Results

Search found 2264 results on 91 pages for 'odd rationale'.

Page 7/91 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Odd PHP Error Message

    - by John
    When I run some php code I've written, I get the following message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition, price, name, email) VALUES('Fake Title', 'Fake Subhead', 'Fake Author' at line 1 I do not see anything wrong with my syntax, however, which is like: mysql_query("INSERT INTO table (x1, x2, x3) VALUES('$y1', '$y2', '$y3')"); Any ideas?

    Read the article

  • Sum of a matrix, even or odd

    - by user1790201
    This function receives a numeric matrix represented as a list of rows, where each row is in turn a list. Assume that it is a square matrix: all rows have the same length and there are as many rows as elements in each row. Also assume that the matrix is at least of dimension 2 by 2 (i.e. minimally the matrix has 2 rows with 2 elements each) The function should return a list with as many elements as number of rows. Element i in the resulting list should have the sum of the values in row i. For example, if the matrix is 1 2 3 10 20 30 100 200 300 then this function should return the list [6,60,600] That is, addValuesInAllRows( [ [1,2,3], [10,20,30], [100,200,300] ] ) should return [6,60,600] Isn't this sort of similar but how would you sum up the list individually

    Read the article

  • Django stupid mark_safe?

    - by Mark
    I wrote this little function for writing out HTML tags: def html_tag(tag, content=None, close=True, attrs={}): lst = ['<',tag] for key, val in attrs.iteritems(): lst.append(' %s="%s"' % (key, escape_html(val))) if close: if content is None: lst.append(' />') else: lst.extend(['>', content, '</', tag, '>']) else: lst.append('>') return mark_safe(''.join(lst)) Which worked great, but then I read this article on efficient string concatenation (I know it doesn't really matter for this, but I wanted consistency) and decided to update my script: def html_tag(tag, body=None, close=True, attrs={}): s = StringIO() s.write('<%s'%tag) for key, val in attrs.iteritems(): s.write(' %s="%s"' % (key, escape_html(val))) if close: if body is None: s.write(' />') else: s.write('>%s</%s>' % (body, tag)) else: s.write('>') return mark_safe(s.getvalue()) But now my HTML get escaped when I try to render it from my template. Everything else is exactly the same. It works properly if I replace the last line with return mark_safe(unicode(s.getvalue())). I checked the return type of s.getvalue(). It should be a str, just like the first function, so why is this failing?? Also fails with SafeString(s.getvalue()) but succeeds with SafeUnicode(s.getvalue()). I'd also like to point out that I used return mark_safe(s.getvalue()) in a different function with no odd behavior.

    Read the article

  • Java OutOfMemoryError message changes when trying to create Arrays of different sizes

    - by Gordon
    In the question by DKSRathore How to simulate the Out Of memory : Requested array size exceeds VM limit some odd behavior was noted when creating an arrays. When creating an array of size Integer.MAX_VALUE an exception with the error java.lang.OutOfMemoryError Requested array size exceeds VM limit was thrown. However when an array was created with a size less than the max but still above the virtual machine memory limit the error message read java.lang.OutOfMemoryError: Java heap space. Testing further I managed to narrow down where the error messages changes. long[] l = new long[2147483645]; exceptions message reads - Requested array size exceeds VM limit long[] l = new long[2147483644]; exceptions message reads - Java heap space errors I increased my virtual machine memory and still produced the same result. Has anyone any idea why this happens? Some extra info: Integer.MAX_VALUE = 2147483647. Edit: Here's the code I used to find the value, might be helpful. int max = Integer.MAX_VALUE; boolean done = false; while (!done) { try { max--; // Throws an error long[] l = new long[max]; // Exit if an error is no longer thrown done = true; } catch (OutOfMemoryError e) { if (!e.getMessage().contains("Requested array size exceeds VM limit")) { System.out.println("Message changes at " + max); done = true; } } }

    Read the article

  • What is the economic rationale behind programmers who work on a open source project (free) instead of a commercial project (not free)?

    - by Kim Jong Woo
    I can't understand why some people dedicate so much hour into a completely open source project without closing it and yielding greater profit from it. I don't think profiting from your code is evil, I think it's a great motivator. Why do some people feel that commercial software and generating money from it is bad? There seems to be this black and white thinking that open source = good, commercial = bad. I hardly find this convincing, and often commercial companies which are supported by sales produce very good results. An open source software in the same niche can't compete against the corporation. Of course, sometimes this is completely the other way around where private companies produce inferior product compared to open source counterparts. So help me understand, why do programmers open source their code when there is commercial prospects for it? Shouldn't the rational programmer or human being make every effort to capitalize on their opportunity cost? Working on a open source project for months when you could've spent the same number of hours at commidity wage or some other monetary compensation?

    Read the article

  • What is the rationale behind Apache Jena's *everything is an interface if possible* design philosophy?

    - by David Cowden
    If you are familiar with the Java RDF and OWL engine Jena, then you have run across their philosophy that everything should be specified as an interface when possible. This means that a Resource, Statement, RDFNode, Property, and even the RDF Model, etc., are, contrary to what you might first think, Interfaces instead of concrete classes. This leads to the use of Factories quite often. Since you can't instantiate a Property or Model, you must have something else do it for you --the Factory design pattern. My question, then, is, what is the reasoning behind using this pattern as opposed to a traditional class hierarchy system? It is often perfectly viable to use either one. For example, if I want a memory backed Model instead of a database-backed Model I could just instantiate those classes, I don't need ask a Factory to give me one. As an aside, I'm in the process of writing a library for manipulating Pearltrees data, which is exported from their website in the form of an RDF/XML document. As I write this library, I have many options for defining the relationships present in the Peartrees data. What is nice about the Pearltrees data is that it has a very logical class system: A tree is made up of pearls, which can be either Page, Reference, Alias, or Root pearls. My question comes from trying to figure out if I should adopt the Jena philosophy in my library which uses Jena, or if I should disregard it, pick my own design philosophy, and stick with it.

    Read the article

  • OpenGL behaving strangely

    - by Mk12
    OpenGL is acting very strangely for some reason. In my subclass of NSOpenGLView, I have the following code in -prepareOpenGL: - (void)prepareOpenGL { GLfloat lightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat lightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat lightPosition[] = { 0.0f, 0.0f, 2.0f }; quality = 0; zCoord = -6; [self loadTextures]; glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); glEnable(GL_LIGHT1); gameState = kGameStateRunning; int i = 0; // HERE ******** [NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(processKeys) userInfo:nil repeats:YES]; // Synchronize buffer swaps with vertical refresh rate GLint swapInt = 1; [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // Setup and start displayLink [self setupDisplayLink]; } I wanted to assign the timer that processes key input to an ivar so that I could invalidate it when the game is paused (and reinstantiate it on resume), however when I did that (as apposed to leaving it at [NSTimer scheduledTimer…), OpenGL doesn't display the cube I draw. When I take it away, it's fine. So i tried just adding a harmless statement, int i = 0; (maked // HERE *******), and that makes the lighting not work! When I take it away, everything is fine, but when I put it back, everything is dark. Can someone come up with a rational explanation for this? Thanks.

    Read the article

  • A maximum character limit on the preg functions?

    - by animuson
    On my site I use output buffering to grab all the output and then run it through a process function before sending it out to the browser (I don't replace anything, just break it into more manageable pieces). In this particular case, there is a massive amount of output because it is listing out a label for every country in the database (around 240 countries). The problem is that in full, my preg_match functions seems to get skipped over, it does absolutely nothing and returns no matches. However, if I remove parts of the labels (no particular part, just random pieces to reduce characters) then the preg_match functions works again. It doesn't seem to matter what I remove from the label, it just seems to be that as long as I remove so many characters. Is there some sort of cap on what the preg functions can handle or will it time out if there is too much data to be scanned over?

    Read the article

  • Very strange client/browser issue

    - by Jeriko
    One of our clients has logged a very strange issue with us- We launched a preview for their website, but when it's viewed on their main PC, peculiar things start to happen... At first, the stylesheet wasn't being found, and so accessing any page resulted in one void of all styles. We sent them a direct link to the stylesheet, which was viewable from all our computers in the office - but gave a "File Not Found" error on their side. I then deleted the file, and replaced it with a new blank file, which he could then access. Copy-pasted screen.css contents into this file, and he could then view it fine, and stylesheets magically worked on the site again. Now, he can view styles, but not the referenced header images. The strange thing is that this problem doesn't exist on any other PC we've tested, or on any other site on the problem computer, but obviously we'd like our client's site to work for them. The strange thing is, they can view other sites of ours, hosted on the same server, built on top of the same CMS (and so most of the files are the same) without problem - but are getting 404s for files that most definitely do exist. Stylesheets are not turned off, nor is anything specifically deactivated on their browser (as other sites are fine) Reloading with CTRL+F5 doesn't help The client is using the latest version of firefox Any ideas here on what to try / how to narrow the problem down?

    Read the article

  • How to avoid automatic renaming of sub signature parameters in visual basic 6.

    - by systempuntoout
    In Visual basic 6, i declare a sub like this: Private Sub test1(ByRef XmlFooOutput As String) ... End Sub after that, i declare another sub like the following one: Private Sub test2(ByRef xmlFooOutput As String) ... End Sub automagically, the first method is transformed in: Private Sub test1(ByVal xmlFooOutput As String) ... End Sub so the XmlFooOutput parameter is transformed in xmlFooOutput. This is a pretty dangerous feature because, method like those could be mapped to different XSL presentation files that read XML values through Xpath. So when test1 parameter is renamed, XSL bound to test1 method goes broken because Xpath point to XmlFooOuput but the correct value is now in xmlFooOutput. Is it possible to remove this weird feature? I'm using microsoft visual basic 6.0 (SP6). This question has some duplicate: http://stackoverflow.com/questions/1064858/stop-visual-basic-6-from-changing-my-casing http://stackoverflow.com/questions/248760/vb6-editor-changing-case-of-variable-names from what i see, there's no practical solution to disable this Intellisense evil feature.

    Read the article

  • Computer makes odd noise. Replace almost every component. Computer still makes odd noise.

    - by ShimmerGeek
    My PC was getting pretty old, 5 years or so, and over the course of it's life I replaced the graphics card, HDD and a couple of sticks of RAM; but the PSU, processor, motherboard, fans etc. were all original. A few weeks ago, I started hearing an odd noise. I struggle to describe it, it sounded sortof like the 'click of death' you hear when a HDD may fail, but not quite... (And it was far less irregular) Also, I was sure I heard it once or twice a minute or two after I shut down the PC. This was going on very irregularly for a couple weeks. Some days I would hear no noise at all, others I would hear it often, maybe once every 30 seconds or so. I could find no common denominator - i.e. it did not happen more during gaming or any other intensive use. Anyway, I need my PC to sit some classes over the summer, so I put it in for them to run a HDD stress test and to replace a bunch of the components. I ended up replacing almost everything - the only elements I still have are my blu-ray drive and graphics card. They said when they started to run the HDD stress test it failed instantly (They started the test and it immediately said 'Test Complete' so they assumed it was at fault, and put a new HDD in since I was still under warranty with them.) I took it home a few hours ago, and I am still hearing the noise!!! Do you guys have any theories? I'm getting a little worried, I can't afford for my PC to suddenly fail during the next month - I have a lot of coursework to do. Any thoughts? Is it possible it could be the fan on the graphics card? I'm confused because it's so irregular. Any help would be much appreciated.

    Read the article

  • Odd issue,Wubi Installation won't boot, when another ext4 drive is plugged?

    - by Uri Herrera
    It's an odd issue, i installed Ubuntu 11.04 trough Wubi yesterday,it actually worked unlike the last time i tried to when it didn't boot at all. But there is one thing that bugs me, see, i have 2 HDD's ,a 320GB one with Windows 7, and the other, a 500GB HDD with Ubuntu 10.10. I have partitioned the 500GB HDD, and contains a NTFS partition, and a EXT4 plus the Swap partitions. The 320GB is not partitioned, as it only has Windows 7. Since i installed Wubi on Windows 7, when i have my Ubuntu drive connected, Wubi won't boot the installation, giving me a "no wubdir" error. However, if i phisically unplug the Ubuntu drive, then Wubi boots just fine. So, how is the Ubuntu drive interfering with Wubi, to the extent of Wubi not even working when the drive is plugged?.

    Read the article

  • Why is my arrow texture being drawn in odd places?

    - by tyjkenn
    This is a script I wrote that places an arrow on the screen, pointing to an enemy off-screen, or, if the enemy is on-screen, it places an arrow hovering above the enemy. Everything seems to work, except for some odd reason, I see random arrows floating around, often skewed and resized (which I really don't understand, because I only rotate and place in this script). Even when I only have one enemy in the scene, I still see these random arrows. It should only be drawing one per enemy. Note: when all enemies are removed, no arrows appear. var arrow : Texture; var cam : Camera; var dim : int = 30; function OnGUI() { var objects = GameObject.FindGameObjectsWithTag("Enemy"); for(var ob : GameObject in objects) { var pos = cam.WorldToViewportPoint(ob.transform.position); if(gameObject.GetComponent(FollowCamera).target != null){ var tar = gameObject.GetComponent(FollowCamera).target.parent; } if(pos.z>1 && ob.transform != tar){ var xDiff = (pos.x*cam.pixelWidth)-(cam.pixelWidth/2); var yDiff = (pos.y*cam.pixelHeight)-(cam.pixelHeight/2); var angle = Mathf.Rad2Deg*Mathf.Atan(yDiff/xDiff)+180; if(xDiff>0) angle += 180; var dist = Mathf.Sqrt(xDiff*xDiff + yDiff*yDiff); var slope = yDiff/xDiff; var camSlope = cam.pixelHeight/cam.pixelWidth; var theX = -1000.0; var theY = -1000.0; var mult = 0; var temp; if(Mathf.Abs(xDiff)>(cam.pixelWidth/2)||Mathf.Abs(yDiff)>(cam.pixelHeight/2)){ //touching right if(slope<camSlope && slope>-camSlope) { if(xDiff>(cam.pixelWidth/2)) { theX = cam.pixelWidth - (dim/2); mult = -1; }else if(xDiff<-(cam.pixelWidth/2)) { theX = (dim/2); mult = 1; } temp = ((cam.pixelWidth/2)*yDiff)/xDiff; theY =(cam.pixelHeight/2)+(mult*temp); } else{ if(yDiff>(cam.pixelHeight/2)) { theY = (dim/2); mult = 1; }else if(yDiff<-(cam.pixelHeight/2)) { theY = cam.pixelHeight - (dim/2); mult = -1; } temp = ((cam.pixelHeight/2)*xDiff)/yDiff; theX =(cam.pixelWidth/2)+(mult*temp); } } else { angle = -90; theX = (cam.pixelWidth/2)+xDiff; theY = (cam.pixelHeight/2)-yDiff-dim; } GUIUtility.RotateAroundPivot(-angle, Vector2(theX, theY)); Graphics.DrawTexture(Rect(theX-(dim/2),theY-(dim/2),dim,dim),arrow,null); GUIUtility.RotateAroundPivot(angle, Vector2(theX, theY)); } } }

    Read the article

  • Precise: Evolution laggy due to IMAP -profile or due to some odd Sync -issue?

    - by Izzy
    I'm fighting with Evolution. Basically it's working fine -- but it is very slow to react in certain situations. There is apparently some problem with syncing and IMAP. Helper questios Could be that changing away from Bonobo has to do with slowing-down? There might be some trouble with the new engine and "asynchronous actions". What to do about it? I want to get the previous "working mood" back. How can I speed this thing up? Different scenarios when sending a mail, the composer window hangs there inactive for a couple of seconds, everything grayed out. Though there is a green check mark saying it's sent, I'm not sure a) why it's still blocking everything and b) whether I could simply close it without "breaking"/"losing" anything. In earlier versions, the composer window was closing pretty fast, and one could see the message being stored into the local "outbox" until it was sent, and one could immediately continue with the next task. I prefer that behaviour over the current. switching between modules. Coming from mail and switching to the address book takes a couple of seconds. Same for switching to the calendar. I read about different "possible causes" and tried a few things: I only have 3 local address books, so no networking should be involved here. To make sure, I switched to offline mode and then tried to access the address book. No noticeable difference. I use 3 Google Calendars. Switching to offline mode made a minor difference, but so minor that it also could be "imagination" since one might have expected this in this case according to some reports, disabling the tasks should help. Well, it didn't in my case, as I don't use them regularly (just two local items stored here)

    Read the article

  • Evolution laggy due to IMAP -profile or due to some odd Sync -issue?

    - by Izzy
    I'm fighting with Evolution. Basically it's working fine -- but it is very slow to react in certain situations. Helper questions Could it be that changing away from Bonobo has to do with slowing-down? There might be some trouble with the new engine and "asynchronous actions". What to do about it? Are there e.g. any configuration files? I want to get the previous "working mood" back. How can I speed this thing up? Different scenarios when sending a mail, the composer window hangs there inactive for a couple of seconds, everything grayed out. Though there is a green check mark saying it's sent, I'm not sure a) why it's still blocking everything and b) whether I could simply close it without "breaking"/"losing" anything. In earlier versions, the composer window was closing pretty fast, and one could see the message being stored into the local "outbox" until it was sent, and one could immediately continue with the next task. I prefer that behaviour over the current, where I cannot do anything in the application until the window closes. switching between modules. Coming from mail and switching to the address book takes a couple of seconds. Same for switching to the calendar. I read about different "possible causes" and tried a few things: I only have 3 local address books, so no networking should be involved here. To make sure, I switched to offline mode and then tried to access the address book. No noticeable difference. I use 3 Google Calendars. Switching to offline mode made a minor difference, but so minor that it also could be "imagination" since one might have expected this in this case according to some reports, disabling the tasks should help. Well, it didn't in my case, as I don't use them regularly (just two local items stored here) Maybe I should also mention that I'm using the KDE4 desktop (so no Unity or Gnome, though both is installed on the computer). And I did not have this issue before I updated to 12.04.

    Read the article

  • How odd this function is? It works in a test project, however, it goes wrong in my project?(Windows Socket) [closed]

    - by user67449
    int SockSend(DataPack &dataPack, SOCKET &sock, char *sockBuf){ int bytesLeft=0, bytesSend=0; int idx=0; bytesLeft=sizeof(dataPack); // ?DataPack?????sockBuf??? memcpy(sockBuf, &dataPack, sizeof(dataPack)); while(bytesLeft>0){ memset(sockBuf, 0, sizeof(sockBuf)); bytesSend=send(sock, &sockBuf[idx], bytesLeft, 0); cout<<"??send()??, bytesSend: "<<bytesSend<<endl; if(bytesSend==SOCKET_ERROR){ cout<<"Error at send()."<<endl; cout<<"Error # "<<WSAGetLastError()<<" happened."<<endl; return 1; } bytesLeft-=bytesSend; idx+=bytesSend; } cout<<"DataPack ???????"<<endl; return 0; } This is the function I defined, which is used to send a user_defined structure DataPack. My code in test project is as follows: char sendBuf[100000]; int res=SockSend(dataPack, sockConn, sendBuf); if(res==1){ cout<<"SockSend()???"<<endl; }else{ cout<<"SockSend()???"<<endl; } My code in my current project is: err=SockSend(dataPackSend, sockConn, sockBuf); if(err==1){ cout<<"SockSend()??"<<endl; exit(0); }else{ cout<<"??? "<<dataPackSend.packNum<<" ?DataPack(??)"<<endl; } Can you tell me where does this function go wrong? I will be appreciated for you answer.

    Read the article

  • Understanding Ruby Enumerable#map (with more complex blocks)

    - by mstksg
    Let's say I have a function def odd_or_even n if n%2 == 0 return :even else return :odd end end And I had a simple enumerable array simple = [1,2,3,4,5] And I ran it through map, with my function, using a do-end block: simple.map do |n| odd_or_even(n) end # => [:odd,:even,:odd,:even,:odd] How could I do this without, say, defining the function in the first place? For example, # does not work simple.map do |n| if n%2 == 0 return :even else return :odd end end # Desired result: # => [:odd,:even,:odd,:even,:odd] is not valid ruby, and the compiler gets mad at me for even thinking about it. But how would I implement an equivalent sort of thing, that works?

    Read the article

  • How to test if an array contains a pair of numbers whose product is odd?

    - by John
    How can I write a function that takes an array of integers and returns true if their exists a pair of numbers whose product is odd? What are the properties of odd integers? And of course, how do you write this function in Java? Also, maybe a short explanation of how you went about formulating an algorithm for the actual implementation. Yes, this is a function out of a textbook. No, this is not homework—I'm just trying to learn, so please no "do your own homework comments."

    Read the article

  • Odd one: IE6 showing the "view source" command enabled when I was expecting it to be disabled.

    - by caerphilly
    Hi, OK, I admit this problem is odd. I'm just trying to understand why IE is behaving the way it is. I realise that logic may not apply here :) I have Internet Explorer 6 (Sp1) running on Windows 2000. The IE option "Do not store encrypted pages to disk" is checked (enabled). The temporary internet files folder is empty. TEMP and TMP environment variables are set to valid folders. I'm connected to a web server over SSL. The web server is serving a page over SSL with the HTTP cache-control header set to "no-cache, no-store". I was expecting the "view source" command to be greyed out in this circumstance (as it is on another machine). But it works. When I "view source", I get an entry in the Temporary Internet Files folder with an "internet address" property of "view-source:https://myserver/...." and the content of the page. I wasn't expecting that. I can't understand why one machine is different to another in this regard. Obviously there is some environment/setup difference, but I can't track it down. Anyone have any bright ideas?

    Read the article

  • C++ std::equal -- rationale behind not testing for the 2 ranges having equal size?

    - by ShaChris23
    I just wrote some code to test the behavior of std::equal, and came away surprised: int main() { try { std::list<int> lst1; std::list<int> lst2; if(!std::equal(lst1.begin(), lst1.end(), lst2.begin())) throw std::logic_error("Error: 2 empty lists should always be equal"); lst2.push_back(5); if(std::equal(lst1.begin(), lst1.end(), lst2.begin())) throw std::logic_error("Error: comparing 2 lists where one is not empty should not be equal"); } catch(std::exception& e) { std::cerr << e.what(); } } The output (a surprise to me): Error: comparing 2 lists where one is not empty should not be equal Observation: why is it the std::equal does not first check if the 2 containers have the same size() ? Was there a legitimate reason?

    Read the article

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