Search Results

Search found 18677 results on 748 pages for 'current'.

Page 98/748 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • AI navigation around a 2d map - Avoiding obstacles.

    - by Curt Walker
    Hey there, I know my question seems pretty vague but I can't think of a better way to put it so I'll start off by explaining what I'm trying to do. I'm currently working on a project whereby I've been given a map and I'm coding a 'Critter' that should be able to navigate it's way around the map, the critter has various other functions but are not relevant to the current question. The whole program and solution is being written in C#. I can control the speed of the critter, and retrieve it's current location on the map by returning it's current X and Y position, I can also set it's direction when it collides with the terrain that blocks it. The only problem I have is that I can't think of a way to intelligently navigate my way around the map, so far I've been basing it around what direction the critter is facing when it collides with the terrain, and this is in no way a good way of moving around the map! I'm not a games programmer, and this is for a software assignment, so I have no clue on AI techniques. All I am after is a push in the right direction on how I could go about getting this critter to find it's way around any map given to me. Here's an image of the map and critters to give you an idea of what i'm talking about. Here's a link to an image of what the maps and critters look like. Map and Critter image I'm in no way looking for anyone to give me a full solution, just a push in the general direction on map navigation. Thanks in advance!

    Read the article

  • JFLAP Turing Machine shortcut problem

    - by Robert Lamb
    In JFLAP (http://jflap.org), there are some shortcuts for Turing machine transitions. One of these shortcuts allows you to transition as long as the current tape symbol isn't the indicated symbol. For example, the transition !g,x;R basically says "Take this transition if the current tape symbol is not g". So far, so good. But the transition I want is !?,~;R which basically says "Move right as long as the current symbol is not the end-of-string (empty cell) symbol". The problem is I cannot figure out how to type in "!?". The JFLAP online documentation (http://www.jflap.org/tutorial/turing/one/index.html#syntax) has this to say: The first shortcut is that there exists the option of using the “!” character to convey the meaning of “any character but this character.” For example, concerning the transition (!a; x, R), if the head encounters any character but an “a”, it will replace the character with an “x” and move right. To write the expression “!?”, just type a “1” in when inputting a command. My question is...how do I actually do what that last sentence is trying to explain to me? Thanks for your help! Robert

    Read the article

  • Problem with richfaces ajax datatable + buttons

    - by Schyzotrop
    Hello i have another problem with RichFaces this is my application and it shows how i want it to work : http://www.screencast.com/users/Schyzotrop/folders/Jing/media/a299dc1e-7a10-440e-8c39-96b1ec6e85a4 this is video of some glitch that i can't solve http://screencast.com/t/MDFiMGMzY the problem is that when i am trying to press any buttons on others than 1st category it won't do anything IF 1st category has less rows than the one i am calling it from from 1st category it works always i am using follwoing code in jsp for collumns : <h:form id="categoryAttributeList"> <rich:panel> <f:facet name="header"> <h:outputText value="Category Attribute List" /> </f:facet> <rich:dataTable id="table" value="#{categoryAttributeBean.allCategoryAttribute}" var="cat" width="100%" rows="10" columnClasses="col1,col2,col2,col3"> <f:facet name="header"> <rich:columnGroup> <h:column>Name</h:column> <h:column>Description</h:column> <h:column>Category</h:column> <h:column>Actions</h:column> </rich:columnGroup> </f:facet> <rich:column filterMethod="#{categoryAttributeFilteringBean.filterNames}"> <f:facet name="header"> <h:inputText value="#{categoryAttributeFilteringBean.filterNameValue}" id="input"> <a4j:support event="onkeyup" reRender="table , ds" ignoreDupResponses="true" requestDelay="700" oncomplete="setCaretToEnd(event);" /> </h:inputText> </f:facet> <h:outputText value="#{cat.name}" /> </rich:column> <rich:column filterMethod="#{categoryAttributeFilteringBean.filterDescriptions}"> <f:facet name="header"> <h:inputText value="#{categoryAttributeFilteringBean.filterDescriptionValue}" id="input2"> <a4j:support event="onkeyup" reRender="table , ds" ignoreDupResponses="true" requestDelay="700" oncomplete="setCaretToEnd(event);" /> </h:inputText> </f:facet> <h:outputText value="#{cat.description}" /> </rich:column> <rich:column filterMethod="#{categoryAttributeFilteringBean.filterCategories}"> <f:facet name="header"> <h:selectOneMenu value="#{categoryAttributeFilteringBean.filterCategoryValue}"> <f:selectItems value="#{categoryAttributeFilteringBean.categories}" /> <a4j:support event="onchange" reRender="table, ds" /> </h:selectOneMenu> </f:facet> <h:outputText value="#{cat.categoryID.name}" /> </rich:column> <h:column> <a4j:commandButton value="Edit" reRender="pnl" action="#{categoryAttributeBean.editCategoryAttributeSetup}"> <a4j:actionparam name="categoryAttributeID" value="#{cat.categoryAttributeID}" assignTo="#{categoryAttributeBean.id}" /> <a4j:actionparam name="state" value="edit" /> <a4j:actionparam name="editId" value="#{cat.categoryAttributeID}" /> </a4j:commandButton> <a4j:commandButton reRender="categoryAttributeList" value="Delete" action="#{categoryAttributeBean.deleteCategoryAttribute}"> <a4j:actionparam name="categoryAttributeID" value="#{cat.categoryAttributeID}" assignTo="#{categoryAttributeBean.id}" /> </a4j:commandButton> </h:column> <f:facet name="footer"> <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller> </f:facet> </rich:dataTable> <rich:panel id="msg"> <h:messages errorStyle="color:red" infoStyle="color:green"></h:messages> </rich:panel> </rich:panel> </h:form> and here is code of my backing bean @EJB private CategoryBeanLocal categoryBean; private CategoryAttribute categoryAttribute = new CategoryAttribute(); private ArrayList<SelectItem> categories = new ArrayList<SelectItem>(); private int id; private int categoryid; // Actions public void newCategoryAttribute() { categoryAttribute.setCategoryID(categoryBean.findCategoryByID(categoryid)); categoryBean.addCategoryAttribute(categoryAttribute); FacesContext.getCurrentInstance().addMessage("newCategoryAttribute", new FacesMessage("CategoryAttribute " + categoryAttribute.getName() + " created.")); this.categoryAttribute = new CategoryAttribute(); } public void editCategoryAttributeSetup() { categoryAttribute = categoryBean.findCategoryAttributeByID(id); } public void editCategoryAttribute() { categoryAttribute.setCategoryID(categoryBean.findCategoryByID(categoryid)); categoryBean.updateCategoryAttribute(categoryAttribute); FacesContext.getCurrentInstance().addMessage("newCategoryAttribute", new FacesMessage("CategoryAttribute " + categoryAttribute.getName() + " edited.")); this.categoryAttribute = new CategoryAttribute(); } public void deleteCategoryAttribute() { categoryAttribute = categoryBean.findCategoryAttributeByID(id); categoryBean.removeCategoryAttribute(categoryAttribute); FacesContext.getCurrentInstance().addMessage("categoryAttributeList", new FacesMessage("CategoryAttribute " + categoryAttribute.getName() + " deleted.")); this.categoryAttribute = new CategoryAttribute(); } // Getters public CategoryAttribute getCategoryAttribute() { return categoryAttribute; } public List<CategoryAttribute> getAllCategoryAttribute() { return categoryBean.findAllCategoryAttributes(); } public ArrayList<SelectItem> getCategories() { categories.clear(); List<Category> allCategory = categoryBean.findAllCategory(); Iterator it = allCategory.iterator(); while (it.hasNext()) { Category cat = (Category) it.next(); SelectItem select = new SelectItem(); select.setLabel(cat.getName()); select.setValue(cat.getCategoryID()); categories.add(select); } return categories; } public int getId() { return id; } public int getCategoryid() { return categoryid; } // Setters public void setCategoryAttribute(CategoryAttribute categoryAttribute) { this.categoryAttribute = categoryAttribute; } public void setId(int id) { this.id = id; } public void setCategoryid(int categoryid) { this.categoryid = categoryid; } and here is filtering bean : @EJB private CategoryBeanLocal categoryBean; private String filterNameValue = ""; private String filterDescriptionValue = ""; private int filterCategoryValue = 0; private ArrayList<SelectItem> categories = new ArrayList<SelectItem>(); public boolean filterNames(Object current) { CategoryAttribute currentName = (CategoryAttribute) current; if (filterNameValue.length() == 0) { return true; } if (currentName.getName().toLowerCase().contains(filterNameValue.toLowerCase())) { return true; } else { System.out.println("name"); return false; } } public boolean filterDescriptions(Object current) { CategoryAttribute currentDescription = (CategoryAttribute) current; if (filterDescriptionValue.length() == 0) { return true; } if (currentDescription.getDescription().toLowerCase().contains(filterDescriptionValue.toLowerCase())) { return true; } else { System.out.println("desc"); return false; } } public boolean filterCategories(Object current) { if (filterCategoryValue == 0) { getCategories(); filterCategoryValue = new Integer(categories.get(0).getValue().toString()); } CategoryAttribute currentCategory = (CategoryAttribute) current; if (currentCategory.getCategoryID().getCategoryID() == filterCategoryValue) { return true; } else { System.out.println(currentCategory.getCategoryID().getCategoryID() + "cate" + filterCategoryValue); return false; } } public ArrayList<SelectItem> getCategories() { categories.clear(); List<Category> allCategory = categoryBean.findAllCategory(); Iterator it = allCategory.iterator(); while (it.hasNext()) { Category cat = (Category) it.next(); SelectItem select = new SelectItem(); select.setLabel(cat.getName()); select.setValue(cat.getCategoryID()); categories.add(select); } return categories; } public String getFilterDescriptionValue() { return filterDescriptionValue; } public String getFilterNameValue() { return filterNameValue; } public int getFilterCategoryValue() { return filterCategoryValue; } public void setFilterDescriptionValue(String filterDescriptionValue) { this.filterDescriptionValue = filterDescriptionValue; } public void setFilterNameValue(String filterNameValue) { this.filterNameValue = filterNameValue; } public void setFilterCategoryValue(int filterCategoryValue) { this.filterCategoryValue = filterCategoryValue; } unfortunetly i can't even imagine what could cause this problem that's why i even made videos to help u understand my problem thanks for help!

    Read the article

  • Multiple queries using same datacontext throws SqlException

    - by Raj
    I've search control with which I'm trying to implement search as user types something. I'm using Linq to SQL to fire queries against the database. Though it works fine usually, when user types the queries really fast some random SqlException is thrown. These are the two different error message I stumbled across recently: A severe error occurred on the current command. The results, if any, should be discarded. Invalid attempt to call Read when reader is closed. Edit: Included code DataContextFactory class: public DataContextFactory(IConnectionStringFactory connectionStringFactory) { this.dataContext = new RegionDataContext(connectionStringFactory.ConnectionString); } public DataContext Context { get { return this.dataContext; } } public void SaveAll() { this.dataContext.SubmitChanges(); } Registering IDataContextFactory with Unity // Get connection string from Application.Current settings ConnectionInfo connectionInfo = Application.Current.Properties["ConnectionInfo"] as ConnectionInfo; // Register ConnectionStringFactory with Unity container as a Singleton this.container.RegisterType<IConnectionStringFactory, ConnectionStringFactory>(new ContainerControlledLifetimeManager(), new InjectionConstructor(connectionInfo.ConnectionString)); // Register DataContextFactory with Unity container this.container.RegisterType<IDataContextFactory, DataContextFactory>(); Connection string: Data Source=.\SQLEXPRESS2008;User Instance=true;Integrated Security=true;AttachDbFilename=C:\client.mdf;MultipleActiveResultSets=true; Using datacontext from a repository class: // IDataContextFactory dependency is injected by Unity public CompanyRepository(IDataContextFactory dataContextFactory) { this.dataContextFactory = dataContextFactory; } // return List<T> of companies var results = this.dataContextFactory.Context.GetTable<CompanyEntity>() .Join(this.dataContextFactory.Context.GetTable<RegionEntity>(), c => c.regioncode, r => r.regioncode, (c, r) => new { c = c, r = r }) .Where(t => t.c.summary_region != null) .Select(t => new { Id = t.c.compcode, Company = t.c.compname, Region = t.r.regionname }).ToList(); What is the work around?

    Read the article

  • Mapping enum with fluent nhibernate

    - by Puneet
    I am following the http://wiki.fluentnhibernate.org/Getting%5Fstarted tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with fields Id AccountTypeName Right now the account types can be Savings or Current So the table AccountTypes stores 2 rows 1 - Savings 2 - Current For AccoutType table I have defined enum public enum AccountType { Savings=1, Current=2 } For Account table I define the entity class public class Account { public virtual int Id {get; private set;} public virtual string AccountHolderName {get; set;} public virtual string AccountType {get; set;} } The fluent nhibernate mappings are: public AgencyMap() { Id(o => o.Id); Map(o => o.AccountHolderName); Map(o => o.AccountType); } When I try to run the solution, it gives an exception - InnerException = {"(XmlDocument)(2,4): XML validation error: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'ur... I guess that is because I have not speciofied any mapping for AccountType. The questions are: How can I use AccountType enum instead of a AccountType class? Maybe I am going on wrong track. Is there a better way to do this? Thanks!

    Read the article

  • Converted PowerBuilder to ASP.Net browsing Errors

    - by user493325
    I had a powerbuilder application which i converted to web application in the format of ASP.Net (aspx) files. after deploying and publishing the converted web application (copy it and add ASP.Net and network Service AND IUser permissions to enable users to access it) in IIS V6.0 over Windows server 2003 and The ASP.Net version is 2.0 The error messages I get when I browse default.aspx web page are as the following:- Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off". <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration> Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL. <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration> Another error message appears on the server is:- Server Error in '/' Application. Configuration Error <roleManager enabled="true"> <membership> </roleManager> Thanks in Advance...

    Read the article

  • Developing Job References

    - by Joe Smith
    How do you develop references for jobs? I have 6 years of programming experience spanning two jobs, but sadly I don't have a lot of people I can draw on as references. It's been several years since I left my last job, which was at a small company, and I've lost touch with the few people I knew there. I now work at another small company. I think I've gone as far as I can in my current position, and would like to look for greener pastures, but I can't exactly use my current boss as a reference, even though I have a very good repore with him. I'm sure he'd make a great reference down the road, but I'm afraid I'd insult him or jeopardize my current job by mentioning that I'm thinking of leaving and would like him to help me. I've applied to some jobs, and I have gotten several replies like, "Oh, you're exactly what we're looking for. Send us a couple references and we'll schedule an interview. Oh, no references? You must be a psychopath, nevermind." I've tried doing some small freelance work on the side, just so I can have a contact who can vouch for my work, but the competition for even small projects is pretty fierce and I can rarely devote adequate time to freelancing while holding a full time job. In addition, I often encounter a Catch-22 where a lot of freelancing jobs also require references. So how do programmers maintain existing references and develop new ones, especially while holding a full time job?

    Read the article

  • How can I diff against a revision of a single file using only the default Git GUI tools?

    - by Rich
    I want to view the history of a single file, and then compare a single revision from that history against the current version. On the command line, this is easy: Run: git log -- <filename> Locate the version you want to compare, Run: git diff <commitid> -- <filename> But how can this be done using only the default Git gui tools, git gui and gitk? I know of two methods using gitk, but they're both horribly clunky: Either: Select the New View option from the View menu, Type in the full path to your file into the box labelled Enter files and directories to include, one per line, Locate the version you want to compare by looking at the highlighted items in the top pane, and click on it to select it, Right-click on the current version and select Diff selected - this, Or: Select Tree in the bottom right-hand pane, Locate the file you want to look at, right-click on it, and select Highlight this only, Locate the version you want to compare by looking at the highlighted items in the top pane, and click on it to select it, Right-click on the current version and select Diff selected - this, Click on the file in the bottom right-hand pane to jump to it in the diff output, or scroll manually. Is a better method than this?

    Read the article

  • Java: Help constructing a fillTextFields() method

    - by Holly
    I have a Java project where I am to connect to a database and create buttons (next, new, save, delete, previous) to navigate through the database content where there are appropriate text fields and labels for the specific information. I'll use the code below as an example (each button is set up very similar)... I have it as follows: JButton jbtnNext = new JButton("Next ->"); jbtnNext.addActionListener(this); if (e.getSource() == jbtnNext) jbtnNext_Click(); private void jbtnNext_Click() { JOptionPane.showMessageDialog(null, "Next" ,"Button Pressed", JOptionPane.INFORMATION_MESSAGE); try { if (rset.next()) { fillTextFields(true); }else{ //Display result in a dialog box JOptionPane.showMessageDialog(null, "Not found"); } } catch (SQLException ex) { ex.printStackTrace(); } } The professor gave the following outline of logic to construct the fillTextFields() method: Construct the method to provide reusable code that would fill the JTextFields on the GUI with appropriate values from current record from the database (when "Previous or "Next" buttons are pressed) or blank values (when the new Button is pressed). To determine when the current record was to provide values (next and previous) or the value would be blank (new button) pass a boolean argument into the method. If data from the current record was to be used as fill values, pass true for both previous and next button code after moving the record pointer. If the new button was pressed and want to fill with blank values, pass false to the method. Inside the method, use a conditional expression to evaluate the boolean variable. If true, The appropriate get----() resultset method is used to fill the JTextFields. If false, fill them with "". The .setText() method of the JTextField is used to fill each JTextField. Make sure the fillTextFields method throws the appropriate exception. I understand and have the previous and next button methods passing true, while the new button method is passing false, but I don't quite understand how to set up the fillTextFields() method correctly or how to "throw the appropriate exception"... Any help would really be appreciated, thank you!

    Read the article

  • switching C compiler causes: Error Initializer cannot be specified for a flexible array member

    - by user1054210
    I am trying to convert our code from one IDE to be used in a different one. The current one uses gcc which allows for this structure to be initialized from a variable array. The new tool does not use gcc gives me an error "Initializer cannot be specified for a flexible array member". So can someone help me understand how to set this up? Should I set up a blank array of variable size and then somewhere assign the #define array as seen below? Here would be an example of the code…(this is current implementation current IDE) In one header file that is Build switchable so we can build this on different hardware platforms we have the following #define #define GPIOS \ /* BANK, PIN, SPD, MODE,… */ GPIOINIT( A, 0, 2, AIN, …) \ GPIOINIT( A, 1, 2, AIN, …) \ GPIOINTINIT(A, 2, 2, AIN, …) \ . . . Then in a different header file that is used in all builds we have PLATFORM_CONFIG_T g_platformConfig = { .name = {PLATFORM_NAME}, (bunch of other stuff), .allGpios = { GPIOS /* here I get the error */ }, }; So I am thinking I can make the error line a variable array and assign to it later in some other way? The problem is the actual array "GPIO" is of different types and pin orders on different designs are different.

    Read the article

  • Efficient algorithm for Next button on a MySQL result set

    - by David Grayson
    I have a website that lets people view rows in a table (each row is a picture). There are more than 100,000 rows. You can view different subsets of the rows, and you can view them with different sort orders. While you are viewing one of the rows, you can click the "Next" or "Previous" buttons to go the next/previous row in the list. How would you implement the "Next" and "Previous" features of the website? More specifically, if you have an arbitrary query that returns a list of up to 100,000+ rows, and you know some information about the current row someone is viewing, how do you determine the NEXT row efficiently? Here is the pseudo-code of the solution I came up with when the website was young, and it worked well when there were only 1000 rows, but now that there are 100,000 rows I think it is eating up too much memory. int nextRowId(string query, int currentRowId) { array allRowIds = mysql_query(query); // Takes up a lot of memory! int currentIndex = (index of currentRowId in allRowIds); // Takes time! return allRowIds[currentIndex+1]; } While you are thinking about this problem, remember that the website can store more information about the current row than just its ID (for example, the position of the current row in the result set), and this information can be used as a hint to help determine the ID of the next row. Edit: Sorry for not mentioning this earlier, but this isn't just a static website: rows can often be added to the list, and rows can be re-ordered in the list. (Much rarer, rows can be removed from the list.) I think that I should worry about that kind of thing, but maybe you can convince me otherwise.

    Read the article

  • Validate a XDocument against schema without the ValidationEventHandler (for use in a HTTP handler)

    - by Vaibhav Garg
    Hi everyone, (I am new to Schema validation) Regarding the following method, System.Xml.Schema.Extensions.Validate( ByVal source As System.Xml.Linq.XDocument, ByVal schemas As System.Xml.Schema.XmlSchemaSet, ByVal validationEventHandler As System.Xml.Schema.ValidationEventHandler, ByVal addSchemaInfo As Boolean) I am using it as follows inside a IHttpHandler - Try Dim xsd As XmlReader = XmlReader.Create(context.Server.MapPath("~/App_Data/MySchema.xsd")) Dim schemas As New XmlSchemaSet() : schemas.Add("myNameSpace", xsd) : xsd.Close() myXDoxumentOdj.Validate(schemas, Function(s As Object, e As ValidationEventArgs) SchemaError(s, e, context), True) Catch ex1 As Threading.ThreadAbortException 'manage schema error' Return Catch ex As Exception 'manage other errors' End Try The handler- Function SchemaError(ByVal s As Object, ByVal e As ValidationEventArgs, ByVal c As HttpContext) As Object If c Is Nothing Then c = HttpContext.Current If c IsNot Nothing Then HttpContext.Current.Response.Write(e.Message) HttpContext.Current.Response.End() End If Return New Object() End Function This is working fine for me at present but looks very weak. I do get errors when I feed it bad XML. But i want to implement it in a more elegant way. This looks like it would break for large XML etc. Is there some way to validate without the handler so that I get the document validated in one go and then deal with errors? To me it looks Async such that the call to Validate() would pass and some non deterministic time later the handler would get called with the result/errors. Is that right? Thanks and sorry for any goofy mistakes :).

    Read the article

  • MySQL get point in time totals from related tables

    - by batfastad
    Hi everyone We have an order book and invoicing system and I've been tasked with trying to output monthly rolling totals from these tables. But I don't know really where to start with this. I think there's some SQL syntax that I don't even know about yet. I'm familiar with INNER/LEFT/JOINS and GROUP BY etc but grouping by date is confusing since I don't know how to limit the data to only the current date that's being grouped by at that point. I think this will involve joining the tables to themselves or possibly a sub-select. I always thought it best to avoid sub-selects apart from when absolutely necessary. Basically the system has 3 tables orders: order_id, currency, order_stamp orders_lines: order_line_id, invoice_id, order_id, price invoices: invoice_id, invoice_stamp order_stamp and invoice_stamp are UTC unix timestamps stored as integers, not MySQL timestamps. I'm trying to get a listing by year/month showing the total of current unbilled orders (sum of price), at that point in time. Current orders are ones where order_stamp is less than or equal to 00:00 on the 1st of the month. Unbilled orders are ones where invoice_stamp is null or invoice_stamp is greater than 00:00 on the 1st of the month. At that point in time there may not be a related invoice yet and invoice_id might be null. Anyone got any suggestions on what I should join to what and what I need to group by? Cheers, B

    Read the article

  • Javascript timezone solution needed(taking into account the actual difference in UTC timestamps)

    - by user198729
    I have unix timestamps from time zone X which is not known, the current timestamp(now()) in TZ X is known 1275143019, how to approach a javascript function so that it can generate the datetime in the users current TZ in the format 2010-05-29 15:32:35 ? UPDATE I'm not a unix timestamp expert,if unix timestamp is always the same in different TZ, then I have to change the question a little,so that the current datetime in TZ X is known(like 2010-05-29 22:32:28),and the other datetime is also in this format,how to convert them to the user's TZ based on the difference between now() ? UPDATE Something strange from MySQL: On server: mysql> select now(); +---------------------+ | now() | +---------------------+ | 2010-05-29 18:34:30 | +---------------------+ 1 row in set (0.00 sec) mysql> select UNIX_TIMESTAMP(); +------------------+ | UNIX_TIMESTAMP() | +------------------+ | 1275143674 | +------------------+ 1 row in set (0.00 sec) On local: mysql> select now(); +---------------------+ | now() | +---------------------+ | 2010-05-29 22:41:30 | +---------------------+ 1 row in set (0.00 sec) mysql> select UNIX_TIMESTAMP(); +------------------+ | UNIX_TIMESTAMP() | +------------------+ | 1275144091 | +------------------+ 1 row in set (0.00 sec) Why the difference between now() (2010-05-29 22:41:30-2010-05-29 18:34:30=6hours) and UNIX_TIMESTAMP() (1275144091 - 1275143674 = 417seconds) is not the same ?

    Read the article

  • My QFileSystemModel doesn't work as expected in PyQt

    - by Skilldrick
    I'm learning the Qt Model/View architecture at the moment, and I've found something that doesn't work as I'd expect it to. I've got the following code (adapted from Qt Model Classes): from PyQt4 import QtCore, QtGui model = QtGui.QFileSystemModel() parentIndex = model.index(QtCore.QDir.currentPath()) print model.isDir(parentIndex) #prints True print model.data(parentIndex).toString() #prints name of current directory childIndex = model.index(0, 0, parentIndex) print model.data(childIndex).toString() rows = model.rowCount(parentIndex) print rows #prints 0 (even though the current directory has directory and file children) The question: Is this a problem with PyQt, have I just done something wrong, or am I completely misunderstanding QFileSystemModel? According to the documentation, model.rowCount(parentIndex) should return the number of children in the current directory. The QFileSystemModel docs say that it needs an instance of a Gui application, so I've also placed the above code in a QWidget as follows, but with the same result: import sys from PyQt4 import QtCore, QtGui class Widget(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) model = QtGui.QFileSystemModel() parentIndex = model.index(QtCore.QDir.currentPath()) print model.isDir(parentIndex) print model.data(parentIndex).toString() childIndex = model.index(0, 0, parentIndex) print model.data(childIndex).toString() rows = model.rowCount(parentIndex) print rows def main(): app = QtGui.QApplication(sys.argv) widget = Widget() widget.show() sys.exit(app.exec_()) if __name__ == '__main__': main()

    Read the article

  • Query String to Object with strongly typed properties

    - by Kamar
    Let’s say we track 20 query string parameters in our site. Each request which comes will have only a subset of those 20 parameters. But we definitely look for all/most of the parameters which comes in each request. We do not want to loop through the collection each time we are looking for a particular parameter initially or somewhere down the pipeline in the code. So we loop once through the query string collection, convert string values to their respective types (enums, int, string etc.), populate to QueryString object which is added to the context. After that wherever its needed we will have a strongly typed properties in the QueryString object which is easy to use and we maintain a standard. public class QueryString { public int Key1{ get; private set; } public SomeType Key2{ get; private set; } private QueryString() { } public static QueryString GetQueryString() { QueryString l_QS = new QueryString(); foreach (string l_Key in HttpContext.Current.Request.QueryString.AllKeys) { switch (l_Key) { case "key1": l_QS.Key1= DoSomething(l_Key, HttpContext.Current.Request.QueryString[l_Key]); break; case "key2": l_QS.Key2 = DoAnotherThing(l_Key, HttpContext.Current.Request.QueryString[l_Key]); break; } } return l_QS; } } Any other solution to achieve this?

    Read the article

  • Trying to override onbeforeunload in first step of form wizard

    - by Dirty Bird Design
    This pertains to a form wizard with 5 steps, I don't want the user to hit back and lose form data in any step 2-4. I have added a flag for the submit function and need to add this one for the first step. If they get there by accident and try and leave I dont want the cofirm dialog popping up. <script type="text/javascript"> $(document).ready(function(){ var action_is_post = false; $("form").submit(function () { action_is_post = true; }); //this is the trouble spot. on the first step the "navigation" of the form has a class of current (on step one = current) $(this).ready(function () { if ($("#stepDesc0").is(".current")) { action_is_post = true; } ); window.onbeforeunload = confirmExit; function confirmExit() { if (!action_is_post) return 'Using the browsers back, refresh or close button will cause you to lose all form data. Please use the Next and Back buttons on the form.'; } }); </script>

    Read the article

  • Unit testing an MVC action method with a Cache dependency?

    - by Steve
    I’m relatively new to testing and MVC and came across a sticking point today. I’m attempting to test an action method that has a dependency on HttpContext.Current.Cache and wanted to know the best practice for achieving the “low coupling” to allow for easy testing. Here's what I've got so far... public class CacheHandler : ICacheHandler { public IList<Section3ListItem> StateList { get { return (List<Section3ListItem>)HttpContext.Current.Cache["StateList"]; } set { HttpContext.Current.Cache["StateList"] = value; } } ... I then access it like such... I'm using Castle for my IoC. public class ProfileController : ControllerBase { private readonly ISection3Repository _repository; private readonly ICacheHandler _cache; public ProfileController(ISection3Repository repository, ICacheHandler cacheHandler) { _repository = repository; _cache = cacheHandler; } [UserIdFilter] public ActionResult PersonalInfo(Guid userId) { if (_cache.StateList == null) _cache.StateList = _repository.GetLookupValues((int)ELookupKey.States).ToList(); ... Then in my unit tests I am able to mock up ICacheHandler. Would this be considered a 'best practice' and does anyone have any suggestions for other approaches? Thanks in advance. Cheers

    Read the article

  • Touch draw in Quatz 2D/Core Graphics

    - by OgreSwamp
    Hello, I'm trying to implement "hand draw tool". At the moment algorythm looks like that (I don't insert any code because methods are quite big, will try to explain an idea): Drawing In touchesStarted: method I create NSMutableArray *pointsArray and add point into it. Call setNeedsDisplay: method. In touchesMoved: method I calculate points between last added point from the pointsArray and current point. Add all points to the pointsArray. Call setNeedsDisplay: method. In touchesFinished: event I calculate points between last added point from the array and current point. Set flag touchesWereFinished. Call setNeedsDisplay:. Render: drawRect: method checks is pointsArray != nil and is there any data in it. If there is - it starts to traw circles in each point of this array. If flag touchesWereFinished is set - save current context to the UIImage, release pointsArray, set it to nil and reset the flag. There are a lot disadvantages of this method: It is slow It becomes extremely slow when user touches and move finger for long time. Array becomes enormous "Lines" composed by circles are ugly I would like to change my algorithm to make it bit faster and line smoother. In result I would like to have lines like on the picture at following URL (sorry, not enough reputation to insert an image): http://2.bp.blogspot.com/_r5VzEAUYXJ4/SrOYp8tJCPI/AAAAAAAAAMw/ZwDKXiHlhV0/s320/SketchBook+Mobile(4).png Can you advice me, ho I can draw lines this way (smooth and slim on the edges)? I thought to draw circles with alpha gradient on the edges (to make lines smoother), but it will be extremely slowly IMHO. Thanks for help

    Read the article

  • Dynamic WCF base addresses in SharePoint

    - by Paul Bevis
    I'm attempting to host a WCF service in SharePoint. I have configured the service to be compatible with ASP.NET to allow me access to HttpContext and session information [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class MISDataService : IMISDataService { ... } And my configuration looks like this <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <services> <service name="MISDataService"> <endpoint address="" binding="webHttpBinding" contract="MISDataViews.IMISDataService" /> </service> </services> </system.serviceModel> Whilst this gives me access to the current HTTP context, the serivce is always hosted under the root domain, i.e. http://www.mydomain.com/_layouts/MISDataService.svc. In SharePoint the URL being accessed gives you specific context information about the current site via the SPContext class. So with the service hosted in a virtual directory, I would like it to be available on mulitple addresses e.g. http://www.mydomain.com/_layouts/MISDataService.svc http://www.mydomain.com/sites/site1/_layouts/MISDataService.svc http://www.mydomain.com/sites/site2/_layouts/MISDataService.svc so that the service can figure out what data to return based upon the current context. Is it possible to configure the endpoint address dynamically? Or is the only alternative to host the service in one location and then pass the "context" to it some how?

    Read the article

  • How can I show print statements in debug mode of OPNET Modeler?

    - by Here now
    I'm writing C++ code in OPNET Modeler. I try to simulate my scenario in debugger mode & I need to trace the function that I wrote it. I need to show print statements which I put it in my code. I used in debugger mode: ***ltr function_name()*** then ***c*** But the result looks like: Type 'help' for Command Summary ODB> ltr enqueue_packet() Added trace #0: trace on label (enqueue_packet()) ODB> c |-----------------------------------------------------------------------------| | Progress: Time (1 min. 52 sec.); Events (500,002) | | Speed: Average (82,575 events/sec.); Current (82,575 events/sec.) | | Time : Elapsed (6.1 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Progress: Time (1 min. 55 sec.); Events (1,000,002) | | Speed: Average (69,027 events/sec.); Current (59,298 events/sec.) | | Time : Elapsed (14 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Progress: Time (1 min. 59 sec.); Events (1,500,002) | | Speed: Average (51,464 events/sec.); Current (34,108 events/sec.) | | Time : Elapsed (29 sec.) | | DES Log: 28 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Simulation Completed - Collating Results. | | Events: Total (1,591,301); Average Speed (48,803 events/sec.) | | Time : Elapsed (33 sec.); Simulated (2 min. 0 sec.) | | DES Log: 29 entries | |-----------------------------------------------------------------------------| |-----------------------------------------------------------------------------| | Reading network model. | |-----------------------------------------------------------------------------| I need to show the print statements in my code. Where it has to be appeared? Is there any step before run the simulation to insure that OPNET debugger using Visual Studio & go through my code??

    Read the article

  • jQuery arrays - newbie needs a kick start

    - by Jonny Wood
    I've only really started using this site and alredy I am very impressed by the community here! This is my third question in less than three days. Hopefully I'll be able to start answering questions soon instead of just asking them! I'm fairly new to jQuery and can't find a decent tutorial on Arrays. I'd like to be able to create an array that targets several ID's on my page and performs the same effect for each. For example I have tabs set up with the following: $('.tabs div.tab').hide(); $('.tabs div:first').show(); $('.tabs ul li:first a').addClass('current'); $('.tabs ul li a').click(function(){ $('.tabs ul li a').removeClass('current'); $(this).addClass('current'); var currentTab = $(this).attr('href'); $('.tabs div.tab').hide(); $(currentTab).show(); return false; }); I've used the class .tag to target the tabs as there are several sets on the same page, but I've heard jQuery works much faster when targetting ID's How would I add an array to the above code to target 4 different ID's? I've looked at var myArray = new Array('#id1', 'id2', 'id3', 'id4'); And also var myValues = [ '#id1', 'id2', 'id3', 'id4' ]; Which is correct and how do I then use the array in the code for my tabs...?

    Read the article

  • stored procedure issue, has to do with my where clause and if statement

    - by MyHeadHurts
    right now my stored procedure is returning 2 different result sets one for @booked and the other for @booked1 if you look closely my query is doing the same thing for each @booked and @booked but one is for a user selected year and the other for the current year. I don't want two different result sets, i want to join the selected year and the current year side by side by SDESCR(which is a column that they have in common) another hurdle i am facing is i am use @mode to decide whether the user wants netsales, sales... so on. I know i need sometype of join but, it isnt working because i have a where statement that says where dyyyy= @yeartoget which won't allow the current year data to work ALTER PROCEDURE [dbo].[test1] @mode varchar(20), @YearToGet int AS SET NOCOUNT ON Declare @Booked Int Set @Booked = CONVERT(int,DateAdd(year, @YearToGet - Year(getdate() + 1), DateAdd(day, DateDiff(day, 1, getdate()), 1) ) ) Declare @Booked1 Int Set @Booked1 = CONVERT(int,DateAdd(year, (year( getdate() )) - Year(getdate() + 1), DateAdd(day, DateDiff(day, 1, getdate()), 1) ) ) If @mode = 'Sales' Select Division, SDESCR, DYYYY, Sum(Case When Booked <= @Booked Then NetAmount End) ASofNetSales, SUM(NetAmount) AS YENetSales, Sum(Case When Booked <= @Booked Then PARTY End) AS ASofPAX, SUM(PARTY) AS YEPAX From dbo.B101BookingsDetails Where DYYYY = @YearToGet Group By SDESCR, DYYYY, Division Order By Division, SDESCR, DYYYY else if @mode = 'netsales' Select Division, SDESCR, DYYYY, Sum(Case When Booked <= @Booked Then NetAmount End) ASofNetSales, SUM(NetAmount) AS YENetSales, Sum(Case When Booked <= @Booked Then PARTY End) AS ASofPAX, SUM(PARTY) AS YEPAX From dbo.B101BookingsDetails Where DYYYY = @YearToGet Group By SDESCR, DYYYY, Division Order By Division, SDESCR, DYYYY If @mode = 'Sales' Select Division, SDESCR, DYYYY, Sum(Case When Booked <= @Booked1 Then NetAmount End) currentNetSales, Sum(Case When Booked <= @Booked1 Then PARTY End) AS currentPAX From dbo.B101BookingsDetails Where DYYYY = (year( getdate() )) Group By SDESCR, DYYYY, Division Order By Division, SDESCR, DYYYY else if @mode = 'netsales' Select Division, SDESCR, DYYYY, Sum(Case When Booked <= @Booked1 Then NetAmount End) currentNetSales, Sum(Case When Booked <= @Booked1 Then PARTY End) AS currentPAX From dbo.B101BookingsDetails Where DYYYY = (year( getdate() )) Group By SDESCR, DYYYY, Division Order By Division, SDESCR, DYYYY Else if @mode = 'Inssales' Select Division, SDESCR, DYYYY, Sum(Case When Booked <= @Booked1 Then InsAmount End) currentInsSales, Sum(Case When Booked <= @Booked1 Then PARTY End) AS currentPAX From dbo.B101BookingsDetails Where DYYYY = (year( getdate() )) Group By SDESCR, DYYYY, Division Order By Division, SDESCR, DYYYY

    Read the article

  • SQL Server service broker reporting as off when I have written a query to turn it on

    - by dotnetdev
    I have made a small ASP.NET website. It uses sqlcachedependency The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications. Source Error: Line 12: System.Data.SqlClient.SqlDependency.Start(connString); This is the erroneous line in my global.asax. However, in sql server (2005), I enabled service broker like so (I connect and run the SQL Server service when I debug my site): ALTER DATABASE mynewdatabase SET ENABLE_BROKER with rollback immediate And this was successful. What am I missing? I am trying to use sql caching dependency and have followed all procedures. Thanks

    Read the article

  • Modified map2 (without truncation of lists) in F# - how to do it idiomatically?

    - by Maciej Piechotka
    I'd like to rewrite such function into F#: zipWith' :: (a -> b -> c) -> (a -> c) -> (b -> c) -> [a] -> [b] -> [c] zipWith' _ _ h [] bs = h `map` bs zipWith' _ g _ as [] = g `map` as zipWith' f g h (a:as) (b:bs) = f a b:zipWith f g h as bs My first attempt was: let inline private map2' (xs : seq<'T>) (ys : seq<'U>) (f : 'T -> 'U -> 'S) (g : 'T -> 'S) (h : 'U -> 'S) = let xenum = xs.GetEnumerator() let yenum = ys.GetEnumerator() seq { let rec rest (zenum : IEnumerator<'A>) (i : 'A -> 'S) = seq { yield i(zenum.Current) if zenum.MoveNext() then yield! (rest zenum i) else zenum.Dispose() } let rec merge () = seq { if xenum.MoveNext() then if yenum.MoveNext() then yield (f xenum.Current yenum.Current); yield! (merge ()) else yenum.Dispose(); yield! (rest xenum g) else xenum.Dispose() if yenum.MoveNext() then yield! (rest yenum h) else yenum.Dispose() } yield! (merge ()) } However it can hardly be considered idiomatic. I heard about LazyList but I cannot find it anywhere.

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >