Daily Archives

Articles indexed Saturday May 8 2010

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

  • Using Jquery to get JSON objects from local file.

    - by ThoughtCrhyme
    I'm trying to get a list of JSON objects (products) from a local file using Jquery and store all the objects in a single array called allItems. The file is co-located in the same directory as the code, and it's called "allItems.json". Here's how I'm doing it now: function getAllSupportedItems(){ var allItems = new Array(); $.getJSON("allItems.json", function(data){ $.each(data.items, function(item){ allItems.push(item); }); }); return allItems; } Based on this example: http://api.jquery.com/jQuery.getJSON/

    Read the article

  • How to force a DIV block to extend to the bottom of a page, even if it has no content?

    - by Sir Psycho
    Hi, I'm trying to get the content div to stretch all the way to the bottom of the page but so far, its only stretching if theres actual content to display. The reason I want to do this is so if there isn't much content to display, the vertical border still goes all the way down. Here is my code <body> <form id="form1"> <div id="header"> <a title="Home" href="index.html" /> </div> <div id="menuwrapper"> <div id="menu"> </div> </div> <div id="content"> </div> and my CSS body { font-family: Trebuchet MS, Verdana, MS Sans Serif; font-size:0.9em; margin:0; padding:0; } div#header { width: 100%; height: 100px; } #header a { background-position: 100px 30px; background: transparent url(site-style-images/sitelogo.jpg) no-repeat fixed 100px 30px; height: 80px; display: block; } #header, #menuwrapper { background-repeat: repeat; background-image: url(site-style-images/darkblue_background_color.jpg); } #menu #menuwrapper { height:25px; } div#menuwrapper { width:100% } #menu, #content { width:1024px; margin: 0 auto; } div#menu { height: 25px; background-color:#50657a; } Thanks for taking a looksi

    Read the article

  • Use of XMLHttpRequest in Dashboard widget failing

    - by Peter Zion
    I am unable to get an XMLHttpRequest object to work correctly in a Dashboard widget I am writing. I've isolated it to a trivial example not working in the global scope of the main.js file: xhr = new XMLHttpRequest; xhr.open( 'GET', "http://google.com", false ); xhr.send(''); When the last line is executed I get the error "ABORT_ERR: XMLHttpRequest Exception 102" (this is in the Dashcode debugger). Does anyone have any idea what could be wrong here?

    Read the article

  • Pass deeply nested element to function in JQuery

    - by klez
    I have this form: <form action="contact.php" method="post" id="contactform"> <ol> <li> <label for="name">First Name * </label> <input id="name" name="name" class="text" /> </li> <li> <label for="email">Your email * </label> <input id="email" name="email" class="text" /> </li> <li> <label for="company">Company</label> <input id="company" name="company" class="text" /> </li> <li> <label for="subject">Subject</label> <input id="subject" name="subject" class="text" /> </li> <li> <label for="message">Message * </label> <textarea id="message" name="message" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField" id="imageField" src="images/send.gif" /> </li> </ol> </form> This javascript function that does some basic validation: function validateRequired(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt); return false; } return true; } } And this script (written with jquery) to intercept the submit event jQuery(document).ready(function(){ $('#contactform').submit(function(){ ... }); }); The problem is that, inside the last script I want to call validateRequired passing each required input/textarea (namely: name, email and message) as first parameter. I tried like this: validateRequired($('#name')); but it doesn't work. How can I do this?

    Read the article

  • How do I make a form transparent while keeping the controls fully visible?

    - by Power-Mosfet
    I would like to have a form in which the controls on the form are fully visible but the form itself is invisible. If I change the form's Opacity, this makes both the form and the controls on it semi-transparent, so this doesn't work. I can't do this by setting the form's TransparencyKey, since I have a PictureBox on the form. If the image in the PictureBox happens to contain pixels that match the TransparencyKey, they appear as openings in the form, which I don't want.

    Read the article

  • Fastest way to convert a list of doubles to a unique list of integers?

    - by javanix
    I am dealing with a MySQL table here that is keyed in a somewhat unfortunate way. Instead of using an auto increment table as a key, it uses a column of decimals to preserve order (presumably so its not too difficult to insert new rows while preserving a primary key and order). Before I go through and redo this table to something more sane, I need to figure out how to rekey it without breaking everything. What I would like to do is something that takes a list of doubles (the current keys) and outputs a list of integers (which can be cast down to doubles for rekeying). For example, input {1.00, 2.00, 2.50, 2.60, 3.00} would give output {1, 2, 3, 4, 5). Since this is a database, I also need to be able to update the rows nicely: UPDATE table SET `key`='3.00' WHERE `key`='2.50'; Can anyone think of a speedy algorithm to do this? My current thought is to read all of the doubles into a vector, take the size of the vector, and output a new vector with values from 1 => doubleVector.size. This seems pretty slow, since you wouldn't want to read every value into the vector if, for instance, only the last n/100 elements needed to be modified. I think there is probably something I can do in place, since only values after the first non-integer double need to be modified, but I can't for the life of me figure anything out that would let me update in place as well. For instance, setting 2.60 to 3.00 the first time you see 2.50 in the original key list would result in an error, since the key value 3.00 is already used for the table.

    Read the article

  • Memory leak with ContextMenuStrip

    - by Dave
    I'm creating a lot of custom controls and adding them to a FlowLayoutPanel. There is also a ContextMenuStrip created and populated at design time. Every time a control is added to the panel it has its ContextMenuStrip property assigned to this menu, so that all controls "share" the same menu. But I noticed when the controls are removed from the panel and disposed of, the memory in use in Task Manager doesn't drop. It rises around 50kB every time a control is created and added to the layout panel. I downloaded the trial of .NET Memory Profiler and it showed there were references to the menu strip hanging around after the controls were disposed. I changed the code to explicitly set the ContextMenuStrip property to null before disposing of the control, and yep, the memory is now released. Why is this? Shouldn't the GC clean up this type of thing?

    Read the article

  • Learn Actionscript 3.0+Flash Vs. C#

    - by user335932
    I have a background in python and I'm looking for a new language. I am almost only intrested in making games. I have come to 2 languages. C# and Action Script. C# because Microsoft allows you to make Indie XBLA games programmed in C# ONLY. Action Script so I can make flash games for new grounds and ect. What do you think is better to learn in the long run?

    Read the article

  • Visual Studio HTML Cursor-within-HTML-Element Syntax-highlighting color

    - by David Murdoch
    I can't, for the life of me, figure out how to change grey highlight color in the screenshot below to something that will make the text a little more legible. Does anyone know what the "Display Item" name is that I need to change? To get to the "theme editor" select Tools = Options = Environment = Fonts and Colors. I can't find what to edit. I've also looked through Tools = Options = Text Editor = HTML = Formatting to no avail. In case you are wondering the theme is a slightly modified Coding Instinct Theme

    Read the article

  • Slow Speeds when unzipping with PHP onto a NFS, how can I speed it up?

    - by bunwich
    Hi, I'm trying to figure out how to boost my NFS speed and php uploads. File is uploaded to the webserver's local tmp dir With PHP I copy the file userxxx.zip to the NFS With PHP I extract the userxxx.zip on the NFS to another dir on the NFS. What I'm finding is the file is in Step 3, the file is being read through the NFS by the web server, processed by the web server, and uploaded back across the NFS. Speeds as expected are very slow. Might a possible solution be to get the Fileserver to extract the zip? a) Webserver copies the file to the NFS b) Webserver makes a web service call to the Fileserver c) Fileserver can now unzip the file like it's local and the speeds should be much faster. I would appreciate any suggestion anyone how people have approached this problem. (I'm aware that php ZipArchive() is very slow, and I'll likely use java or php exec unzip to speed it up) Thanks

    Read the article

  • Finding the centroid of a polygon?

    - by user146780
    I have tried: for each vertex, add to total, divide by number of verities to get center. I'v also tried: Find the topmost, bottommost - get midpoint... find leftmost, rightmost, find midpoint. Both of these did not return the perfect center because I'm relying on the center to scale a polygon. I want to scale my polygons so I may put a border around them. What is the best way to find the centroid of a polygon given that the polygon may be concave, convex and have many many sides of various lengths. Thanks

    Read the article

  • Load resources? - wxPython / Python

    - by Francisco Aleixo
    Hello everyone. I am using wxPython and Py2exe to create my application and my only problem is loading for example bitmaps. Ok so lets say I want to add an image to my application, and thats fairly easy using wxPython, and lets say it is on the same directory of my .py so for example: image = wx.StaticBitmap(self, -1, wx.Bitmap('image.bmp') Now, this works obviously fine, problem is when I convert to Py2exe, I would like to use the resources from the dlls that I included in the Py2Exe compilation. So basically what I want to do is to instead of including the images on the same folder as my application in order to work, I would like to use it from the resources so people won't see the images on the folder.

    Read the article

  • What algorithm can I use to determine points within a semi-circle?

    - by khayman218
    I have a list of two-dimensional points and I want to obtain which of them fall within a semi-circle. Originally, the target shape was a rectangle aligned with the x and y axis. So the current algorithm sorts the pairs by their X coord and binary searches to the first one that could fall within the rectangle. Then it iterates over each point sequentially. It stops when it hits one that is beyond both the X and Y upper-bound of the target rectangle. This does not work for a semi-circle as you cannot determine an effective upper/lower x and y bounds for it. The semi-circle can have any orientation. Worst case, I will find the least value of a dimension (say x) in the semi-circle, binary search to the first point which is beyond it and then sequentially test the points until I get beyond the upper bound of that dimension. Basically testing an entire band's worth of points on the grid. The problem being this will end up checking many points which are not within the bounds.

    Read the article

  • UIImageView Animation Question

    - by James
    Is it possible to run an NSArray UIImageView Animation that plays pictures 1 through 5 only once, plays pictures 5 through 7 on repeat over and over (while holding down IBAction button) then when button is released it plays 7-10 only once?

    Read the article

  • Android App Widget: Data storage

    - by Jeffrey
    Hello everyone, I'm implementing a home screen app widget. I was wondering which is better to store/read data: SharedPreferences or a SQLite database? The data is accessed from an AppWidgetProvider (similar to a BroadcastReceiver), and any given instance of the widget displays different data based on appWidgetId. Is one way or the other frowned upon? Thanks for your time.

    Read the article

  • Fastest way to modify a decimal-keyed table in MySQL?

    - by javanix
    I am dealing with a MySQL table here that is keyed in a somewhat unfortunate way. Instead of using an auto increment table as a key, it uses a column of decimals to preserve order (presumably so its not too difficult to insert new rows while preserving a primary key and order). Before I go through and redo this table to something more sane, I need to figure out how to rekey it without breaking everything. What I would like to do is something that takes a list of doubles (the current keys) and outputs a list of integers (which can be cast down to doubles for rekeying). For example, input {1.00, 2.00, 2.50, 2.60, 3.00} would give output {1, 2, 3, 4, 5). Since this is a database, I also need to be able to update the rows nicely: UPDATE table SET `key`='3.00' WHERE `key`='2.50'; Can anyone think of a speedy algorithm to do this? My current thought is to read all of the doubles into a vector, take the size of the vector, and output a new vector with values from 1 => doubleVector.size. This seems pretty slow, since you wouldn't want to read every value into the vector if, for instance, only the last n/100 elements needed to be modified. I think there is probably something I can do in place, since only values after the first non-integer double need to be modified, but I can't for the life of me figure anything out that would let me update in place as well. For instance, setting 2.60 to 3.00 the first time you see 2.50 in the original key list would result in an error, since the key value 3.00 is already used for the table.

    Read the article

  • Improving my first Clojure program

    - by StackedCrooked
    After a few weekends exploring Clojure I came up with this program. It allows you to move a little rectangle in a window. Here's the code: (import java.awt.Color) (import java.awt.Dimension) (import java.awt.event.KeyListener) (import javax.swing.JFrame) (import javax.swing.JPanel) (def x (ref 0)) (def y (ref 0)) (def panel (proxy [JPanel KeyListener] [] (getPreferredSize [] (Dimension. 100 100)) (keyPressed [e] (let [keyCode (.getKeyCode e)] (if (== 37 keyCode) (dosync (alter x dec)) (if (== 38 keyCode) (dosync (alter y dec)) (if (== 39 keyCode) (dosync (alter x inc)) (if (== 40 keyCode) (dosync (alter y inc)) (println keyCode))))))) (keyReleased [e]) (keyTyped [e]))) (doto panel (.setFocusable true) (.addKeyListener panel)) (def frame (JFrame. "Test")) (doto frame (.add panel) (.pack) (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (.setVisible true)) (defn drawRectangle [p] (doto (.getGraphics p) (.setColor (java.awt.Color/WHITE)) (.fillRect 0 0 100 100) (.setColor (java.awt.Color/BLUE)) (.fillRect (* 10 (deref x)) (* 10 (deref y)) 10 10))) (loop [] (drawRectangle panel) (Thread/sleep 10) (recur)) Despite being an experienced C++ programmer I found it very challenging to write even a simple application in a language that uses a radically different style than what I'm used to. On top of that, this code probably sucks. I suspect the globalness of the various values is a bad thing. It's also not clear to me if it's appropriate to use references here for the x and y values. Any hints for improving this code are welcome.

    Read the article

  • Application runs fine manually but fails as a scheduled task

    - by user42540
    I wasn't sure if this should go here or on stackoverflow. I have an application that loads some files from a network share (the input folder), extracts certain data from them and saves new files (zips them with SharpZLib) on a different network share (output folder). This application runs fine when you open it directly, but when it is set to a scheduled task, it fails in numerous places. This application is scheduled on a Win 2003 server. Let me say right off the bat, the scheduled task is set to use the same login account that I am currently logged in with, so it's not because it's using the LocalSystem account. Something else is going on here. Originally, the application was assigning a drive letter to the input folder using WNetGetConnectionA(). I don't remember why this was done, someone else on our team did that and she's gone now. I think there was some issue with using the WinZip command line with a UNC path. I switched from the WinZip command line utility to using SharpZLib because there were other issues with using the WinZip command line. Anyway, the application failed when trying to assign a drive letter with the error "connection already established." That wasn't true and even after trying WNetCancelConnection(), it still didn't work. Then I decided to just map the drive manually on the server. Then when the app calls Directory.Exists(inputFolderPath) it returns false, even though it does exist. So, for whatever reason, I cannot read this directory from within the application. I can manually navigate to this folder in Windows Explorer and open files. The app log file shows that the user executing it on the schedule is the user I expect, not LocalSystem. Any ideas?

    Read the article

  • How to forward/redirect an HTTP PUT Request with PHP?

    - by benjisail
    Hi, I receive HTTP PUT requests on a server and I would like to redirect / forward these requests to an other server. I handle the PUT request on both server with PHP. The PUT request is using basic HTTP authentication. Here is an example : www.myserver.com/service/put/myfile.xml redirect to www.myotherserver.com/service/put/myfile.xml How can I do this without saving the file on my first server and resending a PUT request using CURL? Thanks!

    Read the article

  • Ruby RegEx not matching valid expression

    - by Matthew Carriere
    I have the following expression: ^\w(\s(+|-|\/|*)\s\w)*$ This simply looks to match a mathematical expression, where a user is prompted for terms separated by basic operators (ex: price + tax) The user may enter more than just 2 terms and one operator (ex: price + tax + moretax) I tested this expression in Rubular http://rubular.com/ With the terms: a + a (MATCH) a + a + a (MATCH) a + a + a + a a a + a a Everything works, but when I use it in Ruby it does not work! expression =~ /^\w(\s(+|-|\/|*)\s\w)*$/ I started picking the expression apart and noticed that if I remove the start of line caret it finds matches but isn't correct. a + a (MATCH) a a (MATCH) <-- this is not correct Why is this expression not working in Ruby code? (I am using Ruby 1.8.7 p174)

    Read the article

  • toString() Method question

    - by cdominguez13
    I've been working on this assignemnt here's code: public class Student { private String fname; private String lname; private String studentId; private double gpa; public Student(String studentFname,String studentLname,String stuId,double studentGpa) { fname = studentFname; lname = studentLname; studentId = stuId; gpa = studentGpa; } public double getGpa() { return gpa; } public String getStudentId() { return studentId; } public String getName() { return lname + ", " + fname; } public void setGpa(double gpaReplacement) { if (gpaReplacement >= 0.0 && gpaReplacement <= 4.0) gpa = gpaReplacement; else System.out.println("Invalid GPA! Please try again."); System.exit(0); } } Now I need to create a toString() method that returns a String formatted something like this: Name: Wilson, Mary Ann ID number: 12345 GPA: 3.5

    Read the article

  • try...else...except syntax error

    - by iform
    I can't understand this... Cannot get this code to run and I've no idea why it is a syntax error. try: newT.read() #existingArtist = newT['Exif.Image.Artist'].value #existingKeywords = newT['Xmp.dc.subject'].value except KeyError: print "KeyError" else: #Program will NOT remove existing values newT.read() if existingArtist != "" : newT['Exif.Image.Artist'] = artistString print existingKeywords keywords = os.path.normpath(relativePath).split(os.sep) print keywords newT['Xmp.dc.subject'] = existingKeywords + keywords newT.write() except: print "Cannot write tags to ",filePath Syntax error occurs on the last "except:". Again...I have no idea why python is throwing a syntax error (spent ~3hrs on this problem).

    Read the article

  • receiving error #1009 in flash cs4 actionscript3

    - by Leah
    I'm having a weird issue where my buttons will work initially and direct me to an appropriate page, but when i go back to that page and try to use the buttons the roll-overs work but none of the buttons direct to a different page. This is the actionscript on the initial page with the buttons. If I choose any of these buttons they work. For example the profile_btn will take me to the go_to_page" stop(); import flash.events.MouseEvent; //button instancese listed below profile_btn.addEventListener(MouseEvent.CLICK, aClick); function aClick(event:MouseEvent):void{ gotoAndPlay("go_to_page"); } color_btn.addEventListener(MouseEvent.CLICK, cClick); function cClick(event:MouseEvent):void{ gotoAndPlay("color_page"); } drawing_btn.addEventListener(MouseEvent.CLICK, dClick); function dClick(event:MouseEvent):void{ gotoAndPlay("drawing_page"); } letsgo_btn.addEventListener(MouseEvent.CLICK, fClick); function fClick(event:MouseEvent):void{ gotoAndPlay("home_page"); } //go to flash fish animation digital_btn.addEventListener(MouseEvent.CLICK,onMouseClick2); function onMouseClick2(e:MouseEvent):void { var request:URLRequest=new URLRequest("aquarium2.swf"); navigateToURL(request,"blank");} //go to resume document resume_btn.addEventListener(MouseEvent.CLICK,onMouseClick3); function onMouseClick3(e:MouseEvent):void { var request:URLRequest=new URLRequest("LeahHonseyResume.pdf"); navigateToURL(request,"blank"); once at the go_to_page, it plays through a motion tween and ends up at the profile_page. from this page, there is a home_btn. Here is the actionscript for the profile_page. stop(); home_btn.addEventListener(MouseEvent.CLICK, gClick); function gClick(event:MouseEvent):void{ gotoAndPlay("return_frame"); } But when I click on the home_btn I get an output: TypeError: Error #1009: Cannot access a property or method of a null object reference. at flash7_fla::MainTimeline/frame38() It does take me to the correct page, but none of the button then on this page are working. the actionscript for the return_frame page is: stop(); import flash.events.MouseEvent; //button instances listed below profile_btn.addEventListener(MouseEvent.CLICK, hClick); function hClick(event:MouseEvent):void{ gotoAndPlay("profile_page"); } color_btn.addEventListener(MouseEvent.CLICK, iClick); function iClick(event:MouseEvent):void{ gotoAndPlay("color_page"); } drawing_btn.addEventListener(MouseEvent.CLICK, jClick); function jClick(event:MouseEvent):void{ gotoAndPlay("drawing_page"); } letsgo_btn.addEventListener(MouseEvent.CLICK, kClick); function kClick(event:MouseEvent):void{ gotoAndPlay("home_page"); } //go to flash fish animation digital_btn.addEventListener(MouseEvent.CLICK,onMouseClick4); function onMouseClick4(e:MouseEvent):void { var request:URLRequest=new URLRequest("aquarium2.swf"); navigateToURL(request,"blank");} //go to resume document resume_btn.addEventListener(MouseEvent.CLICK,onMouseClick5); function onMouseClick5(e:MouseEvent):void { var request:URLRequest=new URLRequest("LeahHonseyResume.pdf"); navigateToURL(request,"blank");} Can anyone help me figure out why this script is not working? Thank you. I am a beginner flash user, and am trying to build my portfolio site for a homework assignment on Monday. Leah

    Read the article

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