Daily Archives

Articles indexed Monday April 5 2010

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

  • image/jpeg returned by groovy/grails is OK on development system, but corrupt on prod system. What c

    - by ?????
    I have a groovy/grails application that needs to serve images It works fine on my dev box, the image is returned properly. Here's the start of the returned JPEG, as seen by od -cx 0000000 377 330 377 340 \0 020 J F I F \0 001 001 001 001 , d8ff e0ff 1000 464a 4649 0100 0101 2c01 but on the production box, there's some garbage in front, and the d8ff e0ff before the 1000 is missing 0000000 ? ** ** ? ** ** ? ** ** ? ** ** \0 020 J F bfef efbd bdbf bfef efbd bdbf 1000 464a 0000020 I F \0 001 001 001 \0 H \0 H \0 \0 ? ** ** ? 4649 0100 0101 4800 4800 0000 bfef efbd It's the exact same code. I just moved the .war over and run it on a different machine. (Isn't Java supposed to be write once, run everywhere?) Any ideas? An "encoding" problem? The code is sent to the response like this: response.contentType = "image/jpeg"; response.outputStream << out;

    Read the article

  • Problem with the nonresponding threads

    - by Oxygen
    Hello there, I have a web application which runs multiple threads on button click each thread making IO call on different ipAddresses ie(login windows account and then making file operations). There is a treshold value of 30 seconds. I assume that while login attempt if the treshold is exceeded, device on ipAddress does not match my conditions thus I dont care it. Thread.Abort() does not fit my situation where it waits for the IO call to finish which might take long time. I tried doing the db operations acording to states of the threads right after the treshold timeout. It worked fine but when I checked out the log file, I noticed that the thread.IsAlive property of the nonresponding threads were still true. After several debuggings on my local pc, I encountered a possible deadlock situation (which i suspect) that my pc crashed badly. In short, do you have any idea about killing (forcefully) nonresponding threads (waiting for the IO opreation) right after the execution of the button_click? (PS: I am not using the threadpool) Oguzhan

    Read the article

  • UI_USER_INTERFACE_IDIOM() does not work with iPhone OS SDK < 3.2

    - by drootang
    Apple advises using the following code to detect whether running on an iPad or iPhone/iPod Touch: if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // The device is an iPad running iPhone 3.2 or later. // [for example, load appropriate iPad nib file] } else { // The device is an iPhone or iPod touch. // [for example, load appropriate iPhone nib file] } The problem is that UI_USER_INTERFACE_IDIOM() and UIUserInterfaceIdiomPad are NOT defined in the SDKs priory to 3.2. This seems to completely defeat the purpose of such a function. They can only be compiled and run on iPhone OS 3.2 (iPhone OS 3.2 can only be run on iPad). So if you can use UI_USER_INTERFACE_IDIOM(), the result will always be to indicate an iPad. If you include this code and target OS 3.1.3 (the most recent iPhone/iPod Touch OS) in order to test your iPhone-bound universal app code, you will get compiler errors since the symbols are not defined in 3.1.3 or earlier. If this is the recommended-by-Apple approach to runtime device-detection, what am I doing wrong? Has anyone succeeded using this approach to device-detection?

    Read the article

  • When is Visual Studio 2010 expected to RTM?

    - by Chris Pietschmann
    Microsoft originally slated the final release build for April 12, 2010. Somasegar said the Visual Studio 2010 and .NET Framework 4 releases will now be pushed back "a few weeks." I know the version / product name says "2010", but that doesn't necessarily mean that it will RTM in 2010. After all VS'2008 RTM'd in November 2007. The last Beta of VS'2008 came out in July 2007, and it RTM'd in November. So based on the previous version that places VS'2010 to RTM in September 2010 at the very earliest since the first Beta just came out in May. Anyone have any other speculations?

    Read the article

  • Should I learn C?

    - by Justin Standard
    Original Question: Should I Learn C? In the theme of the stackoverflow podcast, here's a fun question: should I learn C? I expect Jeff & Joel will have something to say on this. Some info on my background: Primarily a Java programmer on "enterprisy" systems. Favorite languages: python, scheme 7 years programming experience A very small amount of C++ experience, practically no C experience No immediate "need" to learn C So should I learn C? If so, why? If not, why? C or Assembly? Lots of folks recomending Assembler, so add on question: Is it better to learn C or Assembler? If Assembler, which one? Recommended assemblers so far: Motorolla 68000 Intel Assembler (does he mean x86?) MASM32

    Read the article

  • Small program for rotating images

    - by ldigas
    I need a small program (well, it doesn't have to be small, ... that's just there to avoid suggestions like Photoshop or Autocad) for cropping and rotating images by degrees. (have a bunch of scanned images that I'm just touching up for some paper) What would be the least-fuss suggestion for this ?

    Read the article

  • Reading In A String and comparing it C

    - by ahref
    Im trying to create a C based string menu where a user inputs a command and then a block of code runs. Whatever i do the conditional is never true: char *input= ""; fgets(input, 50, stdin); printf("%s",input); printf("%d",strcmp( input,"arrive\0")); if(strcmp( input,"arrive\0")==0){.... Im fairly new to c and am finding strings really annoying. What am i doing wrong?

    Read the article

  • Storing info in a PostgreSQl database issue

    - by MrEnder
    Ok I am making a registry for my website. First page asks for some personal info if($error==false) { $query = pg_query("INSERT INTO chatterlogins(firstName, lastName, gender, password, ageMonth, ageDay, ageYear, email, createDate) VALUES('$firstNameSignup', '$lastNameSignup', '$genderSignup', md5('$passwordSignup'), $monthSignup, $daySignup, $yearSignup, '$emailSignup', now());"); $query = pg_query("INSERT INTO chatterprofileinfo(email, lastLogin) VALUES('$emailSignup', now());"); $userNameSet = $emailSignup; $_SESSION['$userNameSet'] = $userNameSet; header('Location: signup_step2.php'.$rdruri); } The first query works. The second query works but doesn't save the email... the session doesn't work but the header works and sends me to the next page I get no errors even if I comment out header next page @session_start(); $conn = pg_connect("host=localhost dbname=brittains_db user=brittains password=XXXX" ); $signinCheck = false; $checkForm = ""; if(isset($_SESSION['$userName'])) { $userName = $_SESSION['$userName']; $signinCheck = true; $query = pg_query("UPDATE chatterprofileinfo SET lastLogin='now()' WHERE email='$userName'"); } if(isset($_SESSION['$userNameSet'])) { $userName = $_SESSION['$userNameSet']; $signinCheck = true; $query = pg_query("UPDATE chatterprofileinfo SET lastLogin='now()' WHERE email='$userName'"); } This is the top starting the session depending on if your logged in or not. then if I enter in the info here and put it through this if($error==false) { $query = pg_query("UPDATE chatterprofileinfo SET aboutSelf='$aboutSelf', hobbies='$hobbies', music='$music', tv='$tv', sports='$sports', lastLogin='now()' WHERE email='$userName'") or exit(pg_last_error()); //header('Location: signup_step3.php'.$rdruri); } nothing shows up for on my database from this. I have no idea where I went wrong the website is http://opentech.durhamcollege.ca/~intn2201/brittains/chatter/

    Read the article

  • Are you as productive in Javascript as you are in .Net or Java?

    - by bglenn
    I code primarily in javascript and in vb.net. I've found that if I can achieve the same thing in both javascript and vb.net that I feel far more productive and expressive using javascript for the task. I often find myself researching server-side javascript implementations to see if anything has gone mainstream so that I can code my back-end business logic and data access in javascript. Given all the advanced tooling and language features in .Net this preference seems somewhat paradoxical to me. I'm not suggesting one is better than the other (I've been a vb programmer since I started programming), I'm just wondering if my preference is entirely subjective or if anyone else shares it. So, does anyone else enjoy coding in javascript to the point where you prefer it to the .Net and Java environment, and if, so why?

    Read the article

  • Remove all html tags from attributes in rails

    - by Hock
    I have a Project model and it has some text attributes, one is summary. I have some projects that have html tags in the summary and I want to convert that to plain text. I have this method that has a regex that will remove all html tags. def strip_html_comments_on_data self.attributes.each{|key,value| value.to_s.gsub!(/(<[^>]+>|&nbsp;|\r|\n)/,"")} end I also have a before_save filter before_save :strip_html_comments_on_data The problem is that the html tags are still there after saving the project. What am I missing? And, is there a really easy way to have that method called in all the models? Thanks, Nicolás Hock Isaza

    Read the article

  • Invalid Cast Exception ASP.NET C#

    - by Shadow Scorpion
    I have a problem in this code: public static T[] GetExtras <T>(Type[] Types) { List<T> Res = new List<T>(); foreach (object Current in GetExtras(typeof(T), Types)) { Res.Add((T)Current);//this is the error } return Res.ToArray(); } public static object[] GetExtras(Type ExtraType, Type[] Types) { lock (ExtraType) { if (!ExtraType.IsInterface) return new object[] { }; List<object> Res = new List<object>(); bool found = false; found = (ExtraType == typeof(IExtra)); foreach (Type CurInterFace in ExtraType.GetInterfaces()) { if (found = (CurInterFace == typeof(IExtra))) break; } if (!found) return new object[] { }; foreach (Type CurType in Types) { found = false; if (!CurType.IsClass) continue; foreach (Type CurInterface in CurType.GetInterfaces()) { try { if (found = (CurInterface.FullName == ExtraType.FullName)) break; } catch { } } try { if (found) Res.Add(Activator.CreateInstance(CurType)); } catch { } } return Res.ToArray(); } } When I'm using this code in windows application it works! But I cant use it on ASP page. Why?

    Read the article

  • How does one get UI_USER_INTERFACE_IDIOM() to work with iPhone OS SDK < 3.2

    - by drootang
    Apple advises using the following code to detect whether running on an iPad or iPhone/iPod Touch: if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // The device is an iPad running iPhone 3.2 or later. // [for example, load appropriate iPad nib file] } else { // The device is an iPhone or iPod touch. // [for example, load appropriate iPhone nib file] } The problem is that UI_USER_INTERFACE_IDIOM() and UIUserInterfaceIdiomPad are NOT defined in the SDKs priory to 3.2. This seems to completely defeat the purpose of such a function. They can only be compiled and run on iPhone OS 3.2 (iPhone OS 3.2 can only be run on iPad). So if you can use UI_USER_INTERFACE_IDIOM(), the result will always be to indicate an iPad. If you include this code and target OS 3.1.3 (the most recent iPhone/iPod Touch OS) in order to test your iPhone-bound universal app code, you will get compiler errors since the symbols are not defined in 3.1.3 or earlier. If this is the recommended-by-Apple approach to runtime device-detection, what am I doing wrong? Has anyone succeeded using this approach to device-detection?

    Read the article

  • Separate Query for Count

    - by Anraiki
    Hello, I am trying to get my query to grab multiple rows while returning the maximum count of that query. My query: SELECT *, COUNT(*) as Max FROM tableA LIMIT 0 , 30 However, it is only outputting 1 record. I would like to return multiple record as it was the following query: SELECT * FROM tableA LIMIT 0 , 30 Do I have to use separate queries?

    Read the article

  • SWFupload adding extra extension?

    - by st4ck0v3rfl0w
    Hi Everyone, I've been struggling with this for a half day and can't seem to figure out why SWFupload is adding an extra extension to my uploads? (e.g. burer.jpg.jpg) I've reviewed the below code a thousand times and can't figure out why my files (whether png, gif or jpg) get an added .jpg extension? <?php $POST_MAX_SIZE = ini_get('post_max_size'); $unit = strtoupper(substr($POST_MAX_SIZE, -1)); $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1))); if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) { header("HTTP/1.1 500 Internal Server Error"); // This will trigger an uploadError event in SWFUpload echo "POST exceeded maximum allowed size."; exit(0); } // Settings $save_path = "/home/images/"; $upload_name = "image"; $max_file_size_in_bytes = 2147483647; // 2GB in bytes $extension_whitelist = array("jpg", "gif", "png", "jpeg"); // Allowed file extensions $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format) // Other variables $MAX_FILENAME_LENGTH = 260; $file_name = ""; $file_extension = ""; $uploadErrors = array( 0=>"There is no error, the file uploaded successfully", 1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini", 2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 3=>"The uploaded file was only partially uploaded", 4=>"No file was uploaded", 6=>"Missing a temporary folder" ); // Validate the upload if (!isset($_FILES[$upload_name])) { HandleError("No upload found in \$_FILES for " . $upload_name); exit(0); } else if (isset($_FILES[$upload_name]["error"]) && $_FILES[$upload_name]["error"] != 0) { HandleError($uploadErrors[$_FILES[$upload_name]["error"]]); exit(0); } else if (!isset($_FILES[$upload_name]["tmp_name"]) || !@is_uploaded_file($_FILES[$upload_name]["tmp_name"])) { HandleError("Upload failed is_uploaded_file test."); exit(0); } else if (!isset($_FILES[$upload_name]['name'])) { HandleError("File has no name."); exit(0); } // Validate the file size (Warning: the largest files supported by this code is 2GB) $file_size = @filesize($_FILES[$upload_name]["tmp_name"]); if (!$file_size || $file_size > $max_file_size_in_bytes) { HandleError("File exceeds the maximum allowed size"); exit(0); } if ($file_size <= 0) { HandleError("File size outside allowed lower bound"); exit(0); } // Validate file name (for our purposes we'll just remove invalid characters) $file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", $_FILES[$upload_name]['name']); if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) { HandleError("Invalid file name"); exit(0); } // Validate file extension $path_info = pathinfo($_FILES[$upload_name]['name']); $file_extension = $path_info["extension"]; $is_valid_extension = false; foreach ($extension_whitelist as $extension) { if (strcasecmp($file_extension, $extension) == 0) { $is_valid_extension = true; break; } } if (!$is_valid_extension) { HandleError("Invalid file extension"); exit(0); } if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) { HandleError("File could not be saved."); exit(0); } HandleError($_FILES[$upload_name]['name']); exit(0); function HandleError($message) { echo $message; } ?>

    Read the article

  • Unique ID for MS Word 2007 paragraph

    - by Ganish
    I am writing large MS Word 2007 documents, which are often being changed. I have to number paragraphs with stationary unique numbers, that will not change while changing the documents. The numbers should be unique, and will not change even if previous numbers are deleted. The order of the list is not mandatory, and addition of a new number before existing numbers is possible (for instance: the sequence 1, 4, 3 means that paragraphs 1-3 were written, then #2 was deleted, then #5 was added. #3 was not affected by the later editing) The mechanism should be internal to the document, as I am working on line and off line. The numbers are allocated to every document individually. Since I don't know to program under MS Word, I'd appreciate getting a complete solution.

    Read the article

  • How to write a Media Center plugin like the Netflix plugin? Source code/reference samples?

    - by Vin
    I am looking to write a Windows Media Center plugin just like the Netflix WMC plugin. Once logged in, I know the streaming urls that I need to hook in to. Any source code, reference samples would be great. Found one on codeplex for swedish TV channels, but right now it's not working for some reason... Previously asked the following question, with no answers, so updated with a question asked in a easy to relate fashion Host a streaming video in my client, from a streaming url that is behind a login session? I am building a Silverlight 4 desktop client to show streaming video from a site that is login based. So that website has a Silverlight player that does streaming video, the player is behind a login sesion, so just by getting the url from fiddler and trying to play it in my Silverlight 4 desktop client won't work. Actually after that, I want to build a Windows Media Center plugin to build a Netflix-like client, that allows login through WMC and then allows you to watch streaming video. Any pointers on how to go about doing any of this?

    Read the article

  • JavaScript to detect if the parent frame is of the same origin?

    - by tlrobinson
    I'm looking for a cross-browser way to detect whether the parent frame is the same origin as my frame, preferably without printing warnings on the JavaScript error console. The following seems to work but I'd like to avoid printing errors to the console (at least Safari and Chrome do when accessing location.href on the parent frame. Firefox throws an exception which can be caught): function parentIsSameOrigin() { var result = true; try { result = window.parent.location.href !== undefined; } catch (e) { result = false; } return result; }

    Read the article

  • Pointer arithmetic and arrays: what's really legal?

    - by bitcruncher
    Consider the following statements: int *pFarr, *pVarr; int farr[3] = {11,22,33}; int varr[3] = {7,8,9}; pFarr = &(farr[0]); pVarr = varr; At this stage, both pointers are pointing at the start of each respective array address. For *pFarr, we are presently looking at 11 and for *pVarr, 7. Equally, if I request the contents of each array through *farr and *varr, i also get 11 and 7. So far so good. Now, let's try pFarr++ and pVarr++. Great. We're now looking at 22 and 8, as expected. But now... Trying to move up farr++ and varr++ ... and we get "wrong type of argument to increment". Now, I recognize the difference between an array pointer and a regular pointer, but since their behaviour is similar, why this limitation? This is further confusing to me when I also consider that in the same program I can call the following function in an ostensibly correct way and in another incorrect way, and I get the same behaviour, though in contrast to what happened in the code posted above!? working_on_pointers ( pFarr, farr ); // calling with expected parameters working_on_pointers ( farr, pFarr ); // calling with inverted parameters . void working_on_pointers ( int *pExpect, int aExpect[] ) { printf("%i", *pExpect); // displays the contents of pExpect ok printf("%i", *aExpect); // displays the contents of aExpect ok pExpect++; // no warnings or errors aExpect++; // no warnings or errors printf("%i", *pExpect); // displays the next element or an overflow element (with no errors) printf("%i", *aExpect); // displays the next element or an overflow element (with no errors) } Could someone help me to understand why array pointers and pointers behave in similar ways in some contexts, but different in others? So many thanks. EDIT: Noobs like myself could further benefit from this resource: http://www.panix.com/~elflord/cpp/gotchas/index.shtml

    Read the article

  • How to turn off particular monitor in C#?

    - by Boris
    OK, I know there are quite a few posts on this topic. However, none of them provide the solution to my issue: I don't want just to turn off my monitor(s), I wish my code to turn off a specific monitor. The URL the most people refer to, http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html, doesn't help here, as it turns off all the displays. So, I have my laptop screen and an additional external monitor. While I'm watching movies, I switch the display to the external monitor and my laptop screen goes black, however, it's still on and glowing in the dark. I wish to turn it off. Could anyone help please? Thanks.

    Read the article

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