Daily Archives

Articles indexed Monday March 22 2010

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

  • What does template<class key, class type> mean before a method in C++?

    - by zengr
    Hi, I have got this code and I am trying to understand the convention followed, all the method defined in the .cpp file have template<class KeyType, class DataType> written before them. What does that mean? Example: //Constructor template<class key, class type> MyOperation<key, type>::MyOperation() { //method implementation } //A method template<class key, class type> MyOperation<key, type>::otherOperation() { //method implementation } Thanks

    Read the article

  • Custom array sorting based on instance properties

    - by St. John Johnson
    I'm trying to perform a usort on an array inside an instance of a class. But the sort is dependent on the properties of said instance. Code (which doesn't work): class foo { private $array; private $key; private $dir; function sort() { usort($this->array, array("foo", "orderArray")); } function orderArray($a, $b) { return strcmp($a[$this->key], $b[$this->key]) * $this->dir; } } From the orderArray class, you can't access $key or $dir. The question is, how can I write this so I can?

    Read the article

  • Static Function Help C++

    - by Alex
    I can't get past this issue I am having. Here's a simple example: class x { public: void function(void); private: static void function2(void); void x::function(void) { x::function2(void); } static void function2(void) { //something } } I get errors in which complain about function2 being private. If I make it public (which I don't really want to do) I get errors about an undefined reference to function2. What am I doing wrong? Thank you!

    Read the article

  • jquery sortable scroll problem

    - by Sam Vloeberghs
    Hi I'm having problems using the sortable function of jQ:uery UI. The scroll doesn't seem to work.. If the second list ( lists are created on the table rows in a tbody and each tbody is connect ) isn't visible I want it to be possible to scroll towards it for dropping my table row. This is my HTML set up: <ul> <li> <ul> <li> <table class="treeleerling"> <tbody class="oder0"> <tr class="suborder0"> </tr> <tr class="sub1order"> </tr> </tbody> </table> </li> </ul> </li> <li> <ul> <li> <table class="treeleerling"> <tbody class="oder1"> <tr class="suborder0"> </tr> <tr class="suborder1"> </tr> </tbody> </table> </li> </ul> </li> </ul> And jQuery code $(document).ready(function() { $("#left tbody").sortable({ connectWith : '#left tbody', scroll : true, scrollSensitivity: 40, }); }); The sorting works fine, but the scrolling doesnt.. I'm doing something wrong or what? Plz help and advice.. Thx in advance!

    Read the article

  • URL to load resources from the classpath in Java

    - by Thilo
    In Java, you can load all kinds of resources using the same API but with different URL protocols: file:///tmp.txt http://127.0.0.1:8080/a.properties jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class This nicely decouples the actual loading of the resource from the application that needs the resource, and since a URL is just a String, resource loading is also very easily configurable. Is there a protocol to load resources using the current classloader? This is similar to the Jar protocol, except that I do not need to know which jar file or class folder the resource is coming from. I can do that using Class.getResourceAsStream("a.xml"), of course, but that would require me to use a different API, and hence changes to existing code. I want to be able to use this in all places where I can specify a URL for the resource already, by just updating a property file.

    Read the article

  • How to clone a Model using Entity Framework and ASP.Net Mvc 2

    - by Picflight
    I have the following class: [MetadataType(typeof(PortalMetaData))] [System.Web.Mvc.Bind(Exclude = "PortalId")] public partial class Portal { public Portal() { this.Created = DateTime.Now; } } public class PortalMetaData { [Required(ErrorMessage = "Portal name is required")] [StringLength(50, ErrorMessage = "Portal name must be under 50 characters")] public object PortalName { get; set; } [Required(ErrorMessage = "Description is required")] public object Description { get; set; } } I have a corresponding Table in the database Portal I use the Portal table with a PortalController for the Site Admin to update the records in the Portal Table. I want another user with a different Role (AsstAdmin) to be able to update this table as well. To facilitate that I am thinking of creating a separate partial class that somehow links back to the Portal Model. This would allow me to display limited Fields for update by the AsstAdmin and I can display a different name for the Field as well. How can I accomplish this task? If I add the following class which inherits from Portal than I get an exception: Unable to cast object of type 'Project1.Mvc.Models.Portal' to type 'Prpject1.Mvc.Models.Site'. [MetadataType(typeof(SiteMetaData))] public class Site : Portal { public Site() { } } public class SiteMetaData { [Required(DisplayName = "Site Description")] public object Description { get; set; } }

    Read the article

  • Hibernate "JOIN ... ON"?

    - by CaptainAwesomePants
    I have an application that uses Hibernate for its domain objects. One part of the app is common between a few apps, and it has no knowledge of the other systems. In order to handle relations, our class looks like this: @Entity public class SystemEvent { @Id @GeneratedValue public int entity_id; @Column(name="event_type") public String eventType; @Column(name="related_id") public int relatedObjectId; } relatedObjectId holds a foreign key to one of several different objects, depending on the type of event. When a system wants to know about events that are relevant to its interests, it grabs all the system events with eventType "NewAccounts" or some such thing, and it knows that all of those relatedObjectIds are IDs to a "User" object or similar. Unfortunately, this has caused a problem down the line. I can't figure out a way to tell Hibernate about this mapping, which means that HQL queries can't do joins. I'd really like to create an HQL query that looks like this: SELECT users FROM SystemEvent event join Users newUsers where event.eventType = 'SignUp' However, Hibernate has no knowledge of the relationship between SystemEvent and Users, and as far as I can tell, there's no way to tell it. So here's my question: Is there any way to tell Hibernate about a relationship when your domain objects reference each other via ID numbers and not class references?

    Read the article

  • Selecting info from multiple tables for one unique ID with PHP and MySQL

    - by Mark
    I'm using PHP and MySQL. Is this the best method to select information about "user_1" from four different tables? I know it works, because I have tried it. But is this the preferred method of selecting information from multiple tables for "user_1"? $query = "SELECT table_1.username, table_2.city, table_3.state, table_4.country FROM table_1 JOIN table_2 ON table_1.username=table_2.city JOIN table_3 ON table_1.username=table_3.state JOIN table_4 ON table_1.username=table_4.country WHERE table_1.username = 'user_1'";

    Read the article

  • jQuery .post gets null data

    - by Andrew Flusche
    Hey everyone. This is my first post here, so I hope I'm doing it appropriately. I have several jQuery $.post calls that work just fine. They send data to a PHP script that modifies a database and returns some data. No problem. But this one doesn't work. The returned data is just NULL. $.post("act_addTaskLog.php", {description: $("#logFormDescription").val(), complete: $("#logFormComplete").is(':checked'), taskId: $("#logFormTaskId").val(), user: <?php echo $_SESSION['user']; ?>}, function(data) { alert("data: " + data); } ); I've tried everything I can think of, to no avail. I've even tried just one line in my PHP script: die("true"); Firebug shows that the script is being executed, but it's not completing. The alert message displays just with the label "data:" in it, no actual data. Thanks in advance for your help!

    Read the article

  • Why is casting Derived** to Base*const* forbidden ?

    - by smerlin
    After reading this question, i saw the answer by Naveen containing a link to this page, which basically says, that casting from Derived** to Base** is forbidden since could change a pointer to an pointer to a Derived1 object point to a pointer to a Derived2 object (like: *derived1PtrPtr=derived2Ptr). OK, i understand this is evil ... But when casting Derived** to Base*const* this is not even possible, so whats the reason that this is not allowed anyway ?

    Read the article

  • What algorithms do "the big ones" use to cluster news?

    - by marco92w
    I want to cluster texts for a news website. At the moment I use this algorithm to find the related articles. But I found out that PHP's similar_text() gives very good results, too. What sort of algorithms do "the big ones", Google News, Topix, Techmeme, Wikio, Megite etc., use? Of course, you don't know exactly how the algorithms work. It's secret. But maybe someone knows approximately the way they work? The algorithm I use at the moment is very slow. It only compares two articles. So for having the relations between 5,000 articles you need about 12,500,000 comparisons. This is quite a lot. Are there alternatives to reduce the number of necessary comparisons? [I don't look for improvements for my algorithm.] What do "the big ones" do? I'm sure they don't always compare one article to another and this 12,500,000 times for 5,000 news. It would be great if somebody can say something about this topic.

    Read the article

  • WPF Commands firing via Keyboard shortcuts don't set the Command Parameter

    - by Aran Mulholland
    I have a command binding on the main form of my application. It is used to open details of the item that i am viewing. It has an associated keyboard shortcut. When i use the command in sub-forms i pass the object i want to open details for as a CommandParameter. This works if i attach the command to a button or a context menu, as i can specify the command parameter with a binding. However when the command is invoked as a result of a Keyboard shortcut i never get the chance to specify the parameter. How can i specify the command parameter at the sub-form level for a keyboard fired command. I need the CommandBinding with the CanExecute and Execute specified on the main form to globally handle all the open details events.

    Read the article

  • Serving static content from cookie less domain and mod_deflate

    - by Saif Bechan
    I have two domain. One domain with my main website and the other with js/css/etc.. files, static content. mod_deflate is enabled for both domains, but when i run ySlow in FireFox it says none of my static content is compressed. When i bring back the js or css file to my normal domain it gets compressed right. Only when its served from the other domain is it not compressed. Do i have to do some more configuration for this to work? I am using this line in my .htaccess file AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml text/plain application/x-httpd-php I tried to but the line in my httpd.conf file but it gives me the same results. PS. If this is more of a serverfault question i am sorry for this. But i see a lot of questions here concerning mod_deflate and ySlow

    Read the article

  • How to use multiple DisplayName attribute using Entity Framework and ASP.Net Mvc 2

    - by Picflight
    Depending on where I use my Class, I want to be able to show a different DisplayName. I have the following class: [MetadataType(typeof(PortalMetaData))] [System.Web.Mvc.Bind(Exclude = "PortalId")] public partial class Portal { public Portal() { this.Created = DateTime.Now; } } public class PortalMetaData { [Required(ErrorMessage = "Portal name is required")] [StringLength(50, ErrorMessage = "Portal name must be under 50 characters")] public object PortalName { get; set; } [Required(ErrorMessage = "Description is required")] public object Description { get; set; } } I have a corresponding Table in the database Portal I use the Portal table with a PortalController for the Site Admin to update the records in the Portal Table. I want another user with a different Role (AsstAdmin) to be able to update this table as well. To facilitate that I am thinking of creating a separate partial class that somehow links back to the Portal Model. This would allow me to display limited Fields for update by the AsstAdmin and I can display a different name for the Field as well. How can I accomplish this task? If I add the following class which inherits from Portal than I get an exception: Unable to cast object of type 'Project1.Mvc.Models.Portal' to type 'Prpject1.Mvc.Models.Site'. [MetadataType(typeof(SiteMetaData))] public class Site : Portal { public Site() { } } public class SiteMetaData { [Required(DisplayName = "Site Description")] public object Description { get; set; } }

    Read the article

  • Serving static content from cookie less domain and mod_deflate

    - by Saif Bechan
    I have two domain. One domain with my main website and the other with js/css/etc.. files, static content. mod_deflate is enabled for both domains, but when i run ySlow in FireFox it says none of my static content is compressed. When i bring back the js or css file to my normal domain it gets compressed right. Only when its served from the other domain is it not compressed. Do i have to do some more configuration for this to work? I am using this line in my .htaccess file AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml text/plain application/x-httpd-php I tried to but the line in my httpd.conf file but it gives me the same results. PS. If this is more of a serverfault question i am sorry for this. But i see a lot of questions here concerning mod_deflate and ySlow

    Read the article

  • ASP.net access controls dynamically

    - by c11ada
    hey all, i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID ="Question1Text"></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell ColumnSpan="2"> <asp:RadioButtonList ID="RadioButtonList1" runat="server"><asp:ListItem>Yes</asp:ListItem><asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> </asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell> <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server"></asp:TextBox></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell>Question 2</asp:TableCell><asp:TableCell ID ="Question2Text"></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell ColumnSpan="2"> <asp:RadioButtonList ID="RadioButtonList2" runat="server"><asp:ListItem>Yes</asp:ListItem><asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> </asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell> <asp:TextBox ID="TextBox2" TextMode="MultiLine" runat="server"></asp:TextBox></asp:TableCell></asp:TableRow> i want to be able to systematically acces table cells with ID's for example for (int i = 1; i<3 ; i++) { // i want to be able to access the table cell with the ID Question1Text then Question2Text and so on } is this even possible ??

    Read the article

  • How to redirect if javaScript is disabled?

    - by Chris
    I have a site which relies heavily on javaScript. I created a mirror site, which has all the JS as well as all the elements that require JS removed. What is a good, easy way to redirect users to the mirror site if they don't have javaScript enabled? I tried this, but it doesn't seem very good: <noscript> <meta http-equiv="refresh" content="0; URL=nojs/index.php"> </noscript> I also tried to putting header-redirect into the meta tag, but that didn't work.

    Read the article

  • Differing paths for lua script and app

    - by Person
    My problem is that I'm having trouble specifying paths for Lua to look in. For example, in my script I have a require("someScript") line that works perfectly (it is able to use functions from someScript when the script is run standalone. However, when I run my app, the script fails. I believe this is because Lua is looking in a location relative to the application rather than relative to the script. Hardcoding the entire path down to the drive isn't an option since people can download the game wherever they like so the highest I can go is the root folder for the game. We have XML files to load in information on objects. In them, when we specify the script the object uses, we only have to do something like Content\Core\Scripts\someScript.lua where Content is in the same directory as Debug and the app is located inside Debug. If I try putting that (the Content\Core...) in Lua's package.path I get errors when I try to run the script standalone. I'm really stuck, and am not sure how to solve this. Any help is appreciated. Thanks. P.S. When I print out the default package.path in the app I see syntax like ;.\?.lua in a sequence like... ;.\?.lua;c:...(long file path)\Debug\?.lua; I assume the ; means the end of the path, but I have no idea what the .\?.lua means. Any Lua file in the directory?

    Read the article

  • Where can I get source code for apps on the andorid emulator?

    - by Kaustubh
    Hello, greetings. I have 2 question to put forward: I was very interested, even intrigued by the Maps application on the android emulator. Where can I get the source code for it? There is a Maps Editor on the Android Market, it cannot be downloaded to the emualtor. but again, where can I find the source code to that? Thank You, Kaustubh.

    Read the article

  • FormsAuthentication.SignOut() does not log the user out.

    - by Jason
    Smashed my head against this a bit too long. How do I prevent a user from browsing a site's pages after they have been logged out using FormsAuthentication.SignOut? I would expect this to do it: FormsAuthentication.SignOut(); Session.Abandon(); FormsAuthentication.RedirectToLoginPage(); But it doesn't. If I type in a URL directly, I can still browse to the page. I haven't used roll-your-own security in a while so I forget why this doesn't work.

    Read the article

  • How to call RequiredFieldValidator on client before postback

    - by Si
    I've inherited some code which breaks a page up into tabs using divs. On the first page there are many required field and regex validators. The problem is a user can switch to another tab, trigger a postback and fail the validators on the first page, leaving things in a mess. What I want to be able to do is perform the validation on the first page as a user selects another tab, thus preventing them from moving to a new tab until the first page is valid. <ul> <li><a href="#tab1">Tab 1</a> </li> <li><a href="#tab2" onclick="return isValid();">Tab 2</a></li> <li><a href="#tab3" onclick="return isValid();">Tab 3</a></li> </ul> Where isValid needs to fire off the validators. Thanks!

    Read the article

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