Search Results

Search found 627 results on 26 pages for 'ray vega'.

Page 12/26 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Creating New Objects in JavaScript

    - by Ken Ray
    I'm a relatively newbie to object oriented programming in JavaScript, and I'm unsure of the "best" way to define and use objects in JavaScript. I've seen the "canonical" way to define objects and instantiate a new instance, as shown below. function myObjectType(property1, propterty2) { this.property1 = property1, this.property2 = property2 } // now create a new instance var myNewvariable = new myObjectType('value for property1', 'value for property2'); But I've seen other ways to create new instances of objects in this manner: var anotherVariable = new someObjectType({ property1: "Some value for this named property", property2: "This is the value for property 2" }); I like how that second way appears - the code is self documenting. But my questions are: Which way is "better"? Can I use that second way to instantiate a variable of an object type that has been defined using the "classical"way of defining the object type with that implicit constructor? If I want to create an array of these objects, are there any other considerations? Thanks in advance.

    Read the article

  • Application.ProcessMessages hangs???

    - by X-Ray
    my single threaded delphi 2009 app (not quite yet complete) has started to have a problem with Application.ProcessMessages hanging. my app has a TTimer object that fires every 100 ms to poll an external device. i use Application.ProcessMessages to update the screen when something changes so the app is still responsive. one of these was in a grid OnMouseDown event. in there, it had an Application.ProcessMessages that essentially hung. removing that was no problem except that i soon discovered another Application.ProcessMessages that was also blocking. i think what may be happening to me is that the TTimer is--in the app mode i'm currently debugging--probably taking too long to complete. i have prevented the TTimer.OnTimer event hander from re-entering the same code (see below): procedure TfrmMeas.tmrCheckTimer(Sender: TObject); begin if m_CheckTimerBusy then exit; m_CheckTimerBusy:=true; try PollForAndShowMeasurements; finally m_CheckTimerBusy:=false; end; end; what places would it be a bad practice to call Application.ProcessMessages? OnPaint routines springs to mind as something that wouldn't make sense. any general recommendations? i am surprised to see this kind of problem arise at this point in the development!

    Read the article

  • Interpreters: How much simplification?

    - by Ray
    In my interpreter, code like the following x=(y+4)*z echo x parses and "optimizes" down to four single operations performed by the interpreter, pretty much assembly-like: add 4 to y multiply <last operation result> with z set x to <last operation result> echo x In modern interpreters (for example: CPython, Ruby, PHP), how simplified are the "opcodes" for which are in end-effect run by the interpreter? Could I achieve better performance when trying to keep the structures and commands for the interpreter more complex and high-level? That would be surely a lot harder, or?

    Read the article

  • How- XLST Transformation

    - by Yuan Ray
    Just wanted to ask on how to get the author names in the given xml sample below and put an attribut of eq="yes". EQ means Equal Contributors. This is the XML. <ArticleFootnote Type="Misc"> <Para>John Doe and Jane Doe are equal contributors.</Para> </ArticleFootnote> This should be the output in other form of XML. <AuthorGroups> <Authors eq="yes">John Doe</Authors> <Authors eq="yes">Jane Doe</Authors> </AuthorGroups> Assuming that JOhn Doe and Jane Doe are already defined in the list of authors but after the transformation, author tag should have the attribute eq="yes". Please help as I don't know much writing in xlst. Thanks in advance.

    Read the article

  • release vs setting-to-nil to free memory

    - by Dan Ray
    In my root view controller, in my didReceiveMemoryWarning method, I go through a couple data structures (which I keep in a global singleton called DataManager), and ditch the heaviest things I've got--one or maybe two images associated with possibly twenty or thirty or more data records. Right now I'm going through and setting those to nil. I'm also setting myself a boolean flag so that various view controllers that need this data can easily know to reload. Thusly: DataManager *data = [DataManager sharedDataManager]; for (Event *event in data.eventList) { event.image = nil; event.thumbnail = nil; } for (WondrMark *mark in data.wondrMarks) { mark.image = nil; } [DataManager sharedDataManager].cleanedMemory = YES; Today I'm thinking, though... and I'm not actually sure all that allocated memory is really being freed when I do that. Should I instead release those images and maybe hit them with a new alloc and init when I need them again later?

    Read the article

  • overwrite existing entity via bulkloader.Loader

    - by Ray Yun
    I was going to CSV based export/import for large data with app engine. My idea was just simple. First column of CSV would be key of entity. If it's not empty, that row means existing entity and should overwrite old one. Else, that row is new entity and should create new one. I could export key of entity by adding key property. class FrontExporter(bulkloader.Exporter): def __init__(self): bulkloader.Exporter.__init__(self, 'Front', [ ('__key__', str, None), ('name', str, None), ]) But when I was trying to upload CSV, it had failed because bulkloader.Loader.generate_key() was just for "key_name" not "key" itself. That means all exported entities in CSV should have unique 'key_name' if I want to modify-and-reupload them. class FrontLoader(bulkloader.Loader): def __init__(self): bulkloader.Loader.__init__(self, 'Front', [ ('_UNUSED', lambda x: None), ('name', lambda x: x.decode('utf-8')), ]) def generate_key(self,i,values): # first column is key keystr = values[0] if len(keystr)==0: return None return keystr I also tried to load key directly without using generate_key(), but both failed. class FrontLoader(bulkloader.Loader): def __init__(self): bulkloader.Loader.__init__(self, 'Front', [ ('Key', db.Key), # not working. just create new one. ('__key__', db.Key), # same... So, how can I overwrite existing entity which has no 'key_name'? It would be horrible if I should give unique name to all entities..... From the first answer, I could handle this problem. :) def create_entity(self, values, key_name=None, parent=None): # if key_name is None: # print 'key_name is None' # else: # print 'key_name=<',key_name,'> : length=',len(key_name) Validate(values, (list, tuple)) assert len(values) == len(self._Loader__properties), ( 'Expected %d columns, found %d.' % (len(self._Loader__properties), len(values))) model_class = GetImplementationClass(self.kind) properties = { 'key_name': key_name, 'parent': parent, } for (name, converter), val in zip(self._Loader__properties, values): if converter is bool and val.lower() in ('0', 'false', 'no'): val = False properties[name] = converter(val) if key_name is None: entity = model_class(**properties) #print 'create new one' else: entity = model_class.get(key_name) for key, value in properties.items(): setattr(entity, key, value) #print 'overwrite old one' entities = self.handle_entity(entity) if entities: if not isinstance(entities, (list, tuple)): entities = [entities] for entity in entities: if not isinstance(entity, db.Model): raise TypeError('Expected a db.Model, received %s (a %s).' % (entity, entity.__class__)) return entities def generate_key(self,i,values): # first column is key if values[0] is None or values[0] in ('',' ','-','.'): return None return values[0]

    Read the article

  • Facebook requests 3 post_authorize/post_remove. How can I stop it?

    - by Ray Yun
    When user authorize or remove application, Facebook always request post_authorize or post_remove callback 3 times. Only I throws HTTP 500 error, it stop calling them. Yeah, it would be easy to ignore subsequent requests when I successfully handled that. So this maybe academic question. Is there any method to stop facebook requests with http status code??? :)

    Read the article

  • Why am I getting this warning about my app delegate and CLLocationManageDelegate?

    - by Dan Ray
    Observe this perfectly simple UIViewController subclass method: -(IBAction)launchSearch { OffersSearchController *search = [[OffersSearchController alloc] initWithNibName:@"OffersSearchView" bundle:nil]; EverWondrAppDelegate *del = [UIApplication sharedApplication].delegate; [del.navigationController pushViewController:search animated:YES]; [search release]; } On the line where I get *del, I am getting a compiler warning that reads, Type 'id <UIApplicationDelegate>' does not conform to the 'CLLocationManagerDelegate' protocol. In fact, my app delegate DOES conform to that protocol, AND what I'm doing here has nothing at all to do with that. So what's up with that message? Secondary question: sometimes I can get to my navigationController via self.navigationController, and sometimes I can't, and have to go to my app delegate's property to get it like I'm doing here. Any hint about why that is would be very useful.

    Read the article

  • Visual Studio 2008 Solution Explorer Randomly Expands Folders

    - by Ray
    VS 2008 is randomly opening sub-folders for me. Sometimes just a few, sometimes every sub-folder in my project or solution. This happens even when I am not using it - last night when I knoocked off, my solution explorer was closed up tight - this morning, one large project had dozens of sub-folders open. This is not a matter of restoring a previously saved state - most of the folders that get opened are not part of the project, and I have never looked at them with VS. I have downloaded and installed the PowerCommands add-in, and it lets me collapse everything nicely. But I don't want to have to do this several times per day - it closes up folders that I want to be open as well. So, does anyone know why this happens and how to stop it? I found this question from a few months ago which is about the same as this one, but was not answered. I am hoping someone has figured out a solution.

    Read the article

  • Handling Dialogs in WPF with MVVM

    - by Ray Booysen
    In the MVVM pattern for WPF, handling dialogs is one of the more complex operations. As your view model does not know anything about the view, dialog communication can be interesting. I can expose an ICommand that when the view invokes it, a dialog can appear. Does anyone know of a good way to handle results from dialogs? I am speaking about windows dialogs such as MessageBox. One of the ways we did this was have an event on the viewmodel that the view would subscribe to when a dialog was required. public event EventHandler<MyDeleteArgs> RequiresDeleteDialog; This is OK, but it means that the view requires code which is something I would like to stay away from.

    Read the article

  • error with redirect using listener JSF 2.0

    - by Ray
    I have a index.xhtml page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <f:view> <ui:insert name="metadata" /> <f:event type="preRenderView" listener="#{item.show}" /> <h:body></h:body> </f:view> </html> And in bean class with scope session this method public void show() throws IOException, DAOException { ExternalContext externalContext = FacesContext.getCurrentInstance() .getExternalContext(); //smth String rootPath = externalContext.getRealPath("/"); String realPath = rootPath + "pages\\template\\body\\list.xhtml"; externalContext.redirect(realPath); } i think that I should redirect to next page but I have "browser can't show page" and list.xhtml (if I do this page as welcome-page I haven't error, it means that error connected with redirect) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:body> <ui:composition template="/pages/layouts/mainLayout.xhtml"> <ui:define name="content"> <h:form></h:form></ui:define></ui:composition> </h:body> </html> in consol i didn't have any error. in web.xml <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> What can be the reason this problem?

    Read the article

  • Is there a faster way to parse through a large file with regex quickly?

    - by Ray Eatmon
    Problem: Very very, large file I need to parse line by line to get 3 values from each line. Everything works but it takes a long time to parse through the whole file. Is it possible to do this within seconds? Typical time its taking is between 1 minute and 2 minutes. Example file size is 148,208KB I am using regex to parse through every line: Here is my c# code: private static void ReadTheLines(int max, Responder rp, string inputFile) { List<int> rate = new List<int>(); double counter = 1; try { using (var sr = new StreamReader(inputFile, Encoding.UTF8, true, 1024)) { string line; Console.WriteLine("Reading...."); while ((line = sr.ReadLine()) != null) { if (counter <= max) { counter++; rate = rp.GetRateLine(line); } else if(max == 0) { counter++; rate = rp.GetRateLine(line); } } rp.GetRate(rate); Console.ReadLine(); } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } } Here is my regex: public List<int> GetRateLine(string justALine) { const string reg = @"^\d{1,}.+\[(.*)\s[\-]\d{1,}].+GET.*HTTP.*\d{3}[\s](\d{1,})[\s](\d{1,})$"; Match match = Regex.Match(justALine, reg, RegexOptions.IgnoreCase); // Here we check the Match instance. if (match.Success) { // Finally, we get the Group value and display it. string theRate = match.Groups[3].Value; Ratestorage.Add(Convert.ToInt32(theRate)); } else { Ratestorage.Add(0); } return Ratestorage; } Here is an example line to parse, usually around 200,000 lines: 10.10.10.10 - - [27/Nov/2002:16:46:20 -0500] "GET /solr/ HTTP/1.1" 200 4926 789

    Read the article

  • Making a view scrollable when keyboard active

    - by Dan Ray
    I have a view with half a dozen text fields and labels, and a button. I want it to be that when the keyboard pops up, the view becomes scrollable, so you can scroll the view up and see the bottom half of the fields without having to dismiss the keyboard to get to them. Just putting it inside a UIScrollView doesn't seem to do it.

    Read the article

  • jquery show/hide/toggle etc.

    - by Ray
    JQUERY: $("li h2").click(function() { $(this).toggleClass("active").siblings().removeClass("active"); $(this).next("div").slideToggle("fast").siblings("div").slideUp("fast"); }); HTML: <ul> <li> <h2>headingA</h2> <div>contentA</div> <h2>headingB</h2> <div>contentB</div> </li> </ul> NOTES: Bascially I'd want: when click on h2 show the div next to it and hide all others, not only show/hide toggle as well. thanks!

    Read the article

  • How to implement arrays in an interpreter?

    - by Ray
    I have managed to write several interpreters including Tokenizing Parsing, including more complicated expressions such as ((x+y)*z)/2 Building bytecode from syntax trees Actual bytecode execution What I didn't manage: Implementation of dictionaries/lists/arrays. I always got stuck with getting multiple values into one variable. My value structure (used for all values passed around, including variables) looks like this, for example: class Value { public: ValueType type; int integerValue; string stringValue; } Works fine with integers and strings, but how could I implement arrays? (From now on with array I mean arrays in my experimental language, not in C++) How can I fit the array concept into the Value class above? Is it possible? How should I make arrays able to be passed around just as you could pass around integers and strings in my language, using the class above? Accessing array elements or memory allocation wouldn't be the problem, I just don't know how to store them.

    Read the article

  • bool as object vs string as object testing equality

    - by Ray Pendergraph
    I am relatively new to C# and I noticed something interesting today that I guess I have never noticed or perhaps I am missing something. Here is an NUnit test to give an example: object boolean1 = false; object booloan2 = false; Assert.That(boolean1 == booloan2); This unit test fails, but this one passes: object string1 = "string"; object string2 = "string"; Assert.That(string1 == string2); I'm not that surprised in and of itself that the first one fails seeing as boolean1 and boolean2 are different references. But it is troubling to me that the first one fails and the second one passes. I read (on MSDN somewhere) that some magic was done to the String class to facilitate this. I think my question really is why wasn't this behavior replicated in bool? As a note... if the boolean1 and 2 are declared as "bool" then there is no problem. Does anyone know the reason for these differences or why it was implemented that way? Can anyone think of a situation where you would want to reference a bool object for anything except its value?

    Read the article

  • SQL Server Query Slow from PHP, but FAST from SQL Mgt Studio - WHY???

    - by Ray
    I have a fast running query (sub 1 sec) when I execute the query in SQL Server Mgt Studio, but when I run the exact same query in PHP (on the same db instace) using FreeTDS v8, mssql_query(), it takes much longer (70+ seconds). The tables I'm hitting have an index on a date field that I'm using in the Where clause. Could it be that PHP's mssql functions aren't utilizing the index? I have also tried putting the query inside a stored procedure, then executing the SP from PHP - the same results in time difference occurs. I have also tried adding a WITH ( INDEX( .. ) ) clause on the table where that has the date index, but no luck either. Here's the query: SELECT 1 History, h.CUSTNMBR CustNmbr, CONVERT(VARCHAR(10), h.ORDRDATE, 120 ) OrdDate, h.SOPNUMBE OrdNmbr, h.SUBTOTAL OrdTotal, h.CSTPONBR PONmbr, h.SHIPMTHD Shipper, h.VOIDSTTS VoidStatus, h.BACHNUMB BatchNmbr, h.MODIFDT ModifDt FROM SOP30200 h WITH (INDEX (AK2SOP30200)) WHERE h.SOPTYPE = 2 AND h.DOCDATE >= DATEADD(dd, -61, GETDATE()) AND h.VOIDSTTS = 0 AND h.MODIFDT = CONVERT(VARCHAR(10), DATEADD(dd, -1*@daysAgo, GETDATE()) , 120 ) ;

    Read the article

  • Generating 8000 text files from xml files

    - by Ray
    Hi all, i need to generate the same number of text files as the xml files i have. Within the text files, i need the title and maybe some other tags of it. I can generate text files with the elements i wanted but not all xml files can be generated. Only some of them are generated. Something might be wrong with my parser so help out please thanks. This is my code. Please have a look and give me suggestions. Thanks in advance. import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; import java.io.*; public class AccessingXmlFile1 { public static void main(String argv[]) { try { //File file = new File("C:\\MyFile.xml"); // create a file that is really a directory File aDirectory = new File("C:/Documents and Settings/I2R/Desktop/test"); // get a listing of all files in the directory String[] filesInDir = aDirectory.list(); System.out.println(""+filesInDir.length); // sort the list of files (optional) // Arrays.sort(filesInDir); //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // have everything i need, just print it now for ( int a=0; a<filesInDir.length; a++ ) { String xmlFile = filesInDir[a]; String newLine = System.getProperty("line.separator"); File file = new File(xmlFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(file); document.getDocumentElement().normalize(); //System.out.println("Root element " + document.getDocumentElement().getNodeName()); NodeList node = document.getElementsByTagName("metadata"); System.out.println("Information of Xml File"); System.out.println(xmlFile.substring(0, xmlFile.length() - 4)); //////////////////////////////////////////////////////////////////////////////////// String titleStoreText = ""; String descriptionStoreText = ""; String collectionStoreText = ""; String textToWrite = ""; //////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < node.getLength(); i++) { Node firstNode = node.item(i); if (firstNode.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) firstNode; NodeList titleElementList = element.getElementsByTagName("title"); Element titleElement = (Element) titleElementList.item(0); NodeList title = titleElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(titleElement == null) titleStoreText = " There is no title for this file."+ newLine; else titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue() + newLine; //titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue()+ newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Title : " + titleStoreText); NodeList collectionElementList = element.getElementsByTagName("collection"); Element collectionElement = (Element) collectionElementList.item(0); NodeList collection = collectionElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(collectionElement == null) collectionStoreText = " There is no collection for this file."+ newLine; else collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue() + newLine; //collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue()+ newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Collection : " + collectionStoreText); NodeList descriptionElementList = element.getElementsByTagName("description"); Element descriptionElement = (Element) descriptionElementList.item(0); NodeList description = descriptionElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(descriptionElement == null) descriptionStoreText = " There is no description for this file."+ newLine; else descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine; //descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Description : " + descriptionStoreText); //////////////////////////////////////////////////////////////////////////////////// textToWrite = "=====Title=====" + newLine + titleStoreText + newLine + "=====Collection=====" + newLine + collectionStoreText + newLine + "=====Description=====" + newLine + descriptionStoreText;// + newLine + "=====Subject=====" + newLine + subjectStoreText; //////////////////////////////////////////////////////////////////////////////////// } } ///////////////////////////////////////////write to file part is here///////////////////////////////////////// Writer output = null; File file2 = new File(xmlFile.substring(0, xmlFile.length() - 4)+".txt"); output = new BufferedWriter(new FileWriter(file2)); output.write(textToWrite); output.close(); System.out.println("Your file has been written"); //////////////////////////////////////////////////////////////////////////////////// } } catch (Exception e) { e.printStackTrace(); } } }

    Read the article

  • Wait for all WPF animations to stop

    - by Ray
    Given a WPF window, which may or may not have animations, I'd like to wait until they are all done before continuing processing. Is there a generic way to do this. Currently I can do something like this: void WaitForAnimation(Storyboard storyboard) { WaitUntil(() => storyboard.GetCurrentState() == ClockState.Stopped); } But this assumes I know the storyboards or have some way of finding them. Is there a way of doing that?

    Read the article

  • JSF dynamic ui:include

    - by Ray
    In my app I have tutor and student as roles of user. And I decide that main page for both will be the same. But menu will be different for tutors and users. I made to .xhtml page tutorMenu.xhtml and student.xhtml. And want in dependecy from role include menu. For whole page I use layout and just in every page change content "content part" in ui:composition. In menu.xhtml <h:body> <ui:composition> <div class="menu_header"> <h2> <h:outputText value="#{msg['menu.title']}" /> </h2> </div> <div class="menu_content"> <?:if test="#{authenticationBean.user.role.roleId eq '2'}"> <ui:include src="/pages/content/body/student/studentMenu.xhtml"/> </?:if> <?:if test= "#{authenticationBean.user.role.roleId eq '1'}"> <ui:include src="/pages/content/body/tutor/tutorMenu.xhtml" /> </?:if> </div> </ui:composition> I know that using jstl my be not better solution but I can't find other. What is the best decision of my problem?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >