Search Results

Search found 90 results on 4 pages for 'ingo vals'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • I want to fix a bug. Where do I start?

    - by Ingo Gerth
    Although I am not a professional programmer, I have written a program or two. Yet, nowadays every engineer and scientist learns to program a bit as well, and as such I am used to writing programs in Python, C and MATLAB. Now I want to give back a bit to Ubuntu and its great folks and fix a bug! I had a look at the list of the bitesize campaign and had to find that most of them are not that easy for me to fix as I suspect they require a lot of time to get into the matter, and I do not have that. Still I discovered this one and it looks manageable and like a cool feature to me. As I have never written a patch or released a program to the wild before though, I have no idea where to start. What should be my first step to tackle that problem? Bottom line: Where and how do I start fixing that guy?

    Read the article

  • Can not update Natty running from a USB stick

    - by Ingo Gerth
    In a blogpost Jono explained a nice way to test the latest version of Natty. Under point four he proposes: Step 4: Update Although you installed the latest daily you should ensure it is up to date, and you can do this with: sudo apt-get update sudo apt-get upgrade Now, I followed all the steps and am actually writing this question from a session running on a 4GB USB stick. When trying to update the installation though (I just tried to do that using the Update Manager), it always fails because I do not have enough disc space remaining. How can I get Ubuntu to update properly on my USB stick?

    Read the article

  • XMLRPC java insert issue

    - by Sanjai Palliyil
    I am trying to insert customer details into OpenERP server using XMLPRC and java. I am able to do an authentication. But when i call the execute method to insert the record by passing the parameters, am getting Exception in thread "main" java.lang.NullPointerException on line res_create = client_1.execute("execute", params_create); Please find my code below res = client.execute("login", params); String url_1 = "http://agilewebdevelopment.net:8514/xmlrpc/object"; XmlRpcClientConfigImpl config_1 = new XmlRpcClientConfigImpl(); try { config_1.setServerURL(new URL(url_1)); } catch (MalformedURLException e) { System.out.println("First"); e.printStackTrace(); } System.out.println(res); HashMap<String, Object> vals = new HashMap<String, Object>(); vals.put("name", "Mantavya Gajjar"); vals.put("ref", "MGA"); XmlRpcClient client_1 = new XmlRpcClient(); client.setConfig(config_1); Object[] params_create = new Object[]{"erp_performance", "1", "admin", "res.partner", "create", vals}; Object res_create = null; try { res_create = client_1.execute("execute", params_create); } catch (XmlRpcException e) { e.printStackTrace(); } Any helps is appreciated

    Read the article

  • jqeury select list item entering problem

    - by mazhar
    $().ready(function() { $('#remove').click(function() { return !$('#FeatureLists option:selected').remove(); }); $("#add").click(function() { var vals = $("#txtaddfeature").val(); if(vals !='') $("#FeatureLists").prepend("" + vals + ""); $("#txtaddfeature").val()="" }); }); the thing is that if i enter Add it will go into the option without any problem, but if i enter Manage People only Manage will go as there is a space gap between Manage and People . how will i solve this bug?

    Read the article

  • Help needed in pivoting (SQL Server 2005)

    - by Newbie
    I have a table like ID Grps Vals --- ---- ----- 1 1 1 1 1 3 1 1 45 1 2 23 1 2 34 1 2 66 1 3 10 1 3 17 1 3 77 2 1 144 2 1 344 2 1 555 2 2 11 2 2 22 2 2 33 2 3 55 2 3 67 2 3 77 The desired output being ID Record1 Record2 Record3 --- ------- ------- ------- 1 1 23 10 1 3 34 17 1 45 66 77 2 144 11 55 2 344 22 67 2 555 33 77 I have tried(using while loop) but the program is running slow. I have been asked to do so by using SET based approach. My approach so far is SELECT ID,[1] AS [Record1], [2] AS [Record2], [3] as [Record3] FROM ( Select Row_Number() Over(Partition By ID Order By Vals) records ,* From myTable)x PIVOT (MAX(vals) FOR Grps IN ([1],[2],[3])) p But it is not working. Can any one please help to solve this.(SQL SERVER 2005)

    Read the article

  • Reducer getting fewer records than expected

    - by sathishs
    We have a scenario of generating unique key for every single row in a file. we have a timestamp column but the are multiple rows available for a same timestamp in few scenarios. We decided unique values to be timestamp appended with their respective count as mentioned in the below program. Mapper will just emit the timestamp as key and the entire row as its value, and in reducer the key is generated. Problem is Map outputs about 236 rows, of which only 230 records are fed as an input for reducer which outputs the same 230 records. public class UniqueKeyGenerator extends Configured implements Tool { private static final String SEPERATOR = "\t"; private static final int TIME_INDEX = 10; private static final String COUNT_FORMAT_DIGITS = "%010d"; public static class Map extends Mapper<LongWritable, Text, Text, Text> { @Override protected void map(LongWritable key, Text row, Context context) throws IOException, InterruptedException { String input = row.toString(); String[] vals = input.split(SEPERATOR); if (vals != null && vals.length >= TIME_INDEX) { context.write(new Text(vals[TIME_INDEX - 1]), row); } } } public static class Reduce extends Reducer<Text, Text, NullWritable, Text> { @Override protected void reduce(Text eventTimeKey, Iterable<Text> timeGroupedRows, Context context) throws IOException, InterruptedException { int cnt = 1; final String eventTime = eventTimeKey.toString(); for (Text val : timeGroupedRows) { final String res = SEPERATOR.concat(getDate( Long.valueOf(eventTime)).concat( String.format(COUNT_FORMAT_DIGITS, cnt))); val.append(res.getBytes(), 0, res.length()); cnt++; context.write(NullWritable.get(), val); } } } public static String getDate(long time) { SimpleDateFormat utcSdf = new SimpleDateFormat("yyyyMMddhhmmss"); utcSdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); return utcSdf.format(new Date(time)); } public int run(String[] args) throws Exception { conf(args); return 0; } public static void main(String[] args) throws Exception { conf(args); } private static void conf(String[] args) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(); Job job = new Job(conf, "uniquekeygen"); job.setJarByClass(UniqueKeyGenerator.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); // job.setNumReduceTasks(400); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); job.waitForCompletion(true); } } It is consistent for higher no of lines and the difference is as huge as 208969 records for an input of 20855982 lines. what might be the reason for reduced inputs to reducer?

    Read the article

  • How do I iterate over an Array field reflectively?

    - by kunjaan
    I have Class<? extends Object> class1 = obj.getClass(); Field[] fields = class1.getDeclaredFields(); for (Field aField : fields) { aField.setAccessible(true); if (!Modifier.isStatic(aField.getModifiers()) && Modifier.isPublic((aField.getModifiers()))) { if (aField.getType().isArray()) { for (?? vals : aField) { System.out.println(vals); } } } }

    Read the article

  • ArchBeat Link-o-Rama for 2012-09-12

    - by Bob Rhubart
    15 Lessons from 15 Years as a Software Architect | Ingo Rammer In this presentation from the GOTO Conference in Copenhagen, Ingo Rammer shares 15 tips regarding people, complexity and technology that he learned doing software architecture for 15 years. Adding a runtime picker to a taskflow parameter in WebCenter | Yannick Ongena Oracle ACE Yannick Ongena shows how to create an Oracle WebCenter popup to allow users to "select items or do more complex things." Oracle Identity Manager 11g R2 Catalog | Daniel Gralewski Oracle Fusion Middleware A-Team blogger Daniel Gralewski shares a detailed overview of the new Catalog feature, one of the most talked about features in the latest release of Oracle Identity Manager 11g. Cloud API and service designers, stop thinking small | Cloud Computing - InfoWorld "The focus must shift away from fine-grained APIs that provide some type of primitive service, such as pushing data to a block of storage or perhaps making a request to a cloud-rooted database," says InfoWorld's David Linthicum. "To go beyond primitives, you must understand how these services should be used in a much larger architectural context. In other words, you need to understand how businesses will employ these services to form real workplace solutions -- inside and outside the enterprise." Oracle Solaris 8 P2V with Oracle database 10.2 and ASM | Orgad Kimchi Orgad Kimchi's technical post illustrates the migration of "a Solaris 8 physical system, with Oracle database version 10.2.0.5 with ASM file-system located on a SAN storage, into a Solaris 8 branded zone inside a Solaris 10 guest domain on top of a Solaris 11 control domain." Thought for the Day "The hardest single part of building a software system is deciding precisely what to build. " — Fred Brooks Source: SoftwareQuotes.com

    Read the article

  • Creating A SharePoint Parent/Child List Relationship&ndash; SharePoint 2010 Edition

    - by Mark Rackley
    Hey blog readers… It has been almost 2 years since I posted my most read blog on creating a Parent/Child list relationship in SharePoint 2007: Creating a SharePoint List Parent / Child Relationship - Out of the Box And then a year ago I improved on my method and redid the blog post… still for SharePoint 2007: Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX Since then many of you have been asking me how to get this to work in SharePoint 2010, and frankly I have just not had time to look into it. I wish I could have jumped into this sooner, but have just recently began to look at it. Well.. after all this time I have actually come up with two solutions that work, neither of them are as clean as I’d like them to be, but I wanted to get something in your hands that you can start using today. Hopefully in the coming weeks and months I’ll be able to improve upon this further and give you guys some better options. For the most part, the process is identical to the 2007 process, but you have probably found out that the list view web parts in 2010 behave differently, and getting the Parent ID to your new child form can be a pain in the rear (at least that’s what I’ve discovered). Anyway, like I said, I have found a couple of solutions that work. If you know of a better one, please let us know as it bugs me that this not as eloquent as my 2007 implementation. Getting on the same page First thing I’d recommend is recreating this blog: Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX in SharePoint 2010… There are some vague differences, but it’s basically the same…  Here’s a quick video of me doing this in SP 2010: Creating Lists necessary for this blog post Now that you have the lists created, lets set up the New Time form to use a QueryString variable to populate the Parent ID field: Creating parameters in Child’s new item form to set parent ID Did I talk fast enough through both of those videos? Hopefully by now that stuff is old hat to you, but I wanted to make sure everyone could get on the same page.  Okay… let’s get started. Solution 1 – XSLTListView with Javascript This solution is the more elegant of the two, however it does require the use of a little javascript.  The other solution does not use javascript, but it also doesn’t use the pretty new SP 2010 pop-ups.  I’ll let you decide which you like better. The basic steps of this solution are: Inserted a Related Item View Insert a ContentEditorWebPart Insert script in ContentEditorWebPart that pulls the ID from the Query string and calls the method to insert a new item on the child entry form Hide the toolbar from data view to remove “add new item” link. Again, you don’t HAVE to use a CEWP, you could just put the javascript directly in the page using SPD.  Anyway, here is how I did it: Using Related Item View / JavaScript Here’s the JavaScript I used in my Content Editor Web Part: <script type="text/javascript"> function NewTime() { // Get the Query String values and split them out into the vals array var vals = new Object(); var qs = location.search.substring(1, location.search.length); var args = qs.split("&"); for (var i=0; i < args.length; i++) { var nameVal = args[i].split("="); var temp = unescape(nameVal[1]).split('+'); nameVal[1] = temp.join(' '); vals[nameVal[0]] = nameVal[1]; } var issueID = vals["ID"]; //use this to bring up the pretty pop up NewItem2(event,"http://sp2010dev:1234/Lists/Time/NewForm.aspx?IssueID=" + issueID); //use this to open a new window //window.location="http://sp2010dev:1234/Lists/Time/NewForm.aspx?IssueID=" + issueID; } </script> Solution 2 – DataFormWebPart and exact same 2007 Process This solution is a little more of a hack, but it also MUCH more close to the process we did in SP 2007. So, if you don’t mind not having the pretty pop-up and prefer the comforts of what you are used to, you can give this one a try.  The basics steps are: Insert a DataFormWebPart instead of the List Data View Create a Parameter on DataFormWebPart to store “ID” Query String Variable Filter DataFormWebPart using Parameter Insert a link at bottom of DataForm Web part that points to the Child’s new item form and passes in the Parent Id using the Parameter. See.. like I told you, exact same process as in 2007 (except using the DataFormWeb Part). The DataFormWebPart also requires a lot more work to make it look “pretty” but it’s just table rows and cells, and can be configured pretty painlessly.  Here is that video: Using DataForm Web Part One quick update… if you change the link in this solution from: <tr> <td><a href="http://sp2010dev:1234/Lists/Time/NewForm.aspx?IssueID={$IssueIDParam}">Click here to create new item...</a> </td> </tr> to: <tr> <td> <a href="javascript:NewItem2(event,'http://sp2010dev:1234/Lists/Time/NewForm.aspx?IssueID={$IssueIDParam}');">Click here to create new item...</a> </td> </tr> It will open up in the pretty pop up and act the same as solution one… So… both Solutions will now behave the same to the end user. Just depends on which you want to implement. That’s all for now… Remember in both solutions when you have them working, you can make the “IssueID” invisible to users by using the “ms-hidden” class (it’s my previous blog post on the subject up there). That’s basically all there is to it! No pithy or witty closing this time… I am sorry it took me so long to dive into this and I hope your questions are answered. As I become more polished myself I will try to come up with a cleaner solution that will make everyone happy… As always, thanks for taking the time to stop by.

    Read the article

  • Monitoring Html Element CSS Changes in JavaScript

    - by Rick Strahl
    [ updated Feb 15, 2011: Added event unbinding to avoid unintended recursion ] Here's a scenario I've run into on a few occasions: I need to be able to monitor certain CSS properties on an HTML element and know when that CSS element changes. For example, I have a some HTML element behavior plugins like a drop shadow that attaches to any HTML element, but I then need to be able to automatically keep the shadow in sync with the window if the  element dragged around the window or moved via code. Unfortunately there's no move event for HTML elements so you can't tell when it's location changes. So I've been looking around for some way to keep track of the element and a specific CSS property, but no luck. I suspect there's nothing native to do this so the only way I could think of is to use a timer and poll rather frequently for the property. I ended up with a generic jQuery plugin that looks like this: (function($){ $.fn.watch = function (props, func, interval, id) { /// <summary> /// Allows you to monitor changes in a specific /// CSS property of an element by polling the value. /// when the value changes a function is called. /// The function called is called in the context /// of the selected element (ie. this) /// </summary> /// <param name="prop" type="String">CSS Properties to watch sep. by commas</param> /// <param name="func" type="Function"> /// Function called when the value has changed. /// </param> /// <param name="interval" type="Number"> /// Optional interval for browsers that don't support DOMAttrModified or propertychange events. /// Determines the interval used for setInterval calls. /// </param> /// <param name="id" type="String">A unique ID that identifies this watch instance on this element</param> /// <returns type="jQuery" /> if (!interval) interval = 200; if (!id) id = "_watcher"; return this.each(function () { var _t = this; var el$ = $(this); var fnc = function () { __watcher.call(_t, id) }; var itId = null; var data = { id: id, props: props.split(","), func: func, vals: [props.split(",").length], fnc: fnc, origProps: props, interval: interval }; $.each(data.props, function (i) { data.vals[i] = el$.css(data.props[i]); }); el$.data(id, data); hookChange(el$, id, data.fnc); }); function hookChange(el$, id, fnc) { el$.each(function () { var el = $(this); if (typeof (el.get(0).onpropertychange) == "object") el.bind("propertychange." + id, fnc); else if ($.browser.mozilla) el.bind("DOMAttrModified." + id, fnc); else itId = setInterval(fnc, interval); }); } function __watcher(id) { var el$ = $(this); var w = el$.data(id); if (!w) return; var _t = this; if (!w.func) return; // must unbind or else unwanted recursion may occur el$.unwatch(id); var changed = false; var i = 0; for (i; i < w.props.length; i++) { var newVal = el$.css(w.props[i]); if (w.vals[i] != newVal) { w.vals[i] = newVal; changed = true; break; } } if (changed) w.func.call(_t, w, i); // rebind event hookChange(el$, id, w.fnc); } } $.fn.unwatch = function (id) { this.each(function () { var el = $(this); var fnc = el.data(id).fnc; try { if (typeof (this.onpropertychange) == "object") el.unbind("propertychange." + id, fnc); else if ($.browser.mozilla) el.unbind("DOMAttrModified." + id, fnc); else clearInterval(id); } // ignore if element was already unbound catch (e) { } }); return this; } })(jQuery); With this I can now monitor movement by monitoring say the top CSS property of the element. The following code creates a box and uses the draggable (jquery.ui) plugin and a couple of custom plugins that center and create a shadow. Here's how I can set this up with the watcher: $("#box") .draggable() .centerInClient() .shadow() .watch("top", function() { $(this).shadow(); },70,"_shadow"); ... $("#box") .unwatch("_shadow") .shadow("remove"); This code basically sets up the window to be draggable and initially centered and then a shadow is added. The .watch() call then assigns a CSS property to monitor (top in this case) and a function to call in response. The component now sets up a setInterval call and keeps on pinging this property every time. When the top value changes the supplied function is called. While this works and I can now drag my window around with the shadow following suit it's not perfect by a long shot. The shadow move is delayed and so drags behind the window, but using a higher timer value is not appropriate either as the UI starts getting jumpy if the timer's set with too small of an increment. This sort of monitor can be useful for other things as well where operations are maybe not quite as time critical as a UI operation taking place. Can anybody see a better a better way of capturing movement of an element on the page?© Rick Strahl, West Wind Technologies, 2005-2011Posted in ASP.NET  JavaScript  jQuery  

    Read the article

  • Listview of items from a object selected in another listview

    - by Ingó Vals
    Ok the title maybe a little confusing. I have a database with the table Companies wich has one-to-many relotionship with another table Divisions ( so each company can have many divisions ) and division will have many employees. I have a ListView of the companies. What I wan't is that when I choose a company from the ListView another ListView of divisions within that company appears below it. Then I pick a division and another listview of employees within that division appaers below that. You get the picture. Is there anyway to do this mostly inside the XAML code declaritively (sp?). I'm using linq so the Company entity objects have a property named Division wich if I understand linq correctly should include Division objects of the divisions connected to the company. So after getting all the companies and putting them as a itemsource to CompanyListView this is where I currently am. <ListView x:Name="CompanyListView" DisplayMemberPath="CompanyName" Grid.Row="0" Grid.Column="0" /> <ListView DataContext="{Binding ElementName=CompanyListView, Path=SelectedItem}" DisplayMemberPath="Division.DivisionName" Grid.Row="1" Grid.Column="0" /> I know I'm way off but I was hoping by putting something specific in the DataContext and DisplayMemberPath I could get this to work. If not then I have to capture the Id of the company I guess and capture a select event or something. Another issue but related is the in the seconde column besides the lisview I wan't to have a details/edit view for the selected item. So when only a company is selected details about that will appear then when a division under the company is picked It will go there instead, any ideas?

    Read the article

  • Ajax actionlinks straight from a DropDownList

    - by Ingó Vals
    I've got a small linkbox on the side of my page that is rendered as a PartialView. In it I have a dropDownlist the should change the routing value of the links in the box but I'm having difficulty doing so. My current plan is to call on something similar to a Ajax.ActionLink to reload the partial view into the with a different parameter based on the value of the dropdown selection. However I'm having multiple problems with this, for example as a novice in using dropdownlists I have no idea how to call on the selected value for example. <%= Html.DropDownList("DropDownList1", new SelectList(Model, "ID", "Name"), "--Pick--", new { AutoPostBack = "true", onchange = "maybe something here" })%> I tried putting in the sys.mvc.AsyncHyperlink into the onchange attribute and that worked except I don't know how to put in the route value for it. Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'SmallMenu' } Is there no straight Ajax drop down list that fires events onchange? Any way this is possible? I have later in the Partial view the Ajax actionlinks but they need to have their id's updated by the value in the dropdownlist and if I could do that somehow else I would appreciate a suggestion.

    Read the article

  • How to reuse layouts in WPF

    - by Ingó Vals
    I'm trying to create a application that will be tabbed where each tab will have a button area and a view area. Now each tab will essentially have the same layout just different things in the layout and I wanted to be able to reuse the same layout so that I won't have to change at many places ( it's just not good programming ). Can I accomplish this using resources or perhaps Styles. Please supply a light code example if possible.

    Read the article

  • Proper way to use Linq with WPF

    - by Ingó Vals
    I'm looking for a good guide into the right method of using Linq to Sql together with WPF. Most guides only go into the bare basics like how to show data from a database but noone I found goes into how to save back to the database. Can you answer or point out to me a guide that can answer these questions. I have a separate Data project because the same data will also be used in a web page so I have the repository method. That means I have a seperate class that uses the DataContext and there are methods like GetAllCompanies() and GetCompanyById ( int id ). 1) Where there are collections is it best to return as a IQueryable or should I return a list? Inside the WPF project I have seen reccomendations to wrap the collection in a ObservabgleCollection. 2) Why should I use ObservableCollection and should I use it even with Linq / IQueryable Some properties of the linq entities should be editable in the app so I set them to two-way mode. That would change the object in the observableCollection. 3) Is the object in the ObservableCollection still a instance of the original linq entity and so is the change reflected in the database ( when submitchanges is called ) I should have somekind of save method in the repository. But when should I call it? What happens if someone edits a field but decides not to save it, goes to another object and edits it and then press save. Doesn't the original change also save? When does it not remember the changes to a linq entity object anymore. Should I instance the Datacontext class in each method so it loses scope when done. 4) When and how to call the SubmitChanges method 5) Should I have the DataContext as a member variable of the repository class or a method variable To add a new row I should create a new object in a event ( "new" button push ) and then add it to the database using a repo method. 6) When I add the object to the database there will be no new object in the ObservableCollection. Do I refresh somehow. 7) I wan't to reuse the edit window when creating new but not sure how to dynamically changing from referencing selected item from a listview to this new object. Any examples you can point out.

    Read the article

  • How to have a dynamic theme color in WPF

    - by Ingó Vals
    In WPF I have a few resource dictionaries and in them styles for my panels and controls in my app. I'm reusing the same colors again and again. I actually have 5 colors and they give my app a good color-scheme. However if I wan't to change the theme I have to go into the RD's and change each and every color there. I would like to somewhere have the colors set but don't know how or where. I tried to put a color tag in one RD but as soon as I referenced it in the same RD Visual Studio crashed. Also the best solution would be that I could have the color as a dynamic setting in the app itself so users could even change it themselves.

    Read the article

  • How to call the previous querystring parameter in .aspx

    - by Ingó Vals
    Let's say I have a ActionResult method that has a pageNumber parameter and a category parameter. The user should be able to set the category he's browsing which would be a ActionLink to the first page of that category. However if I have an another ActionLink where I go to the next page the category parameter would go back to default. How can I set the category parameter to be the same as on the previous page.

    Read the article

  • Using MongoDB's map/reduce to "group by" two fields

    - by ibz
    I need something slightly more complex than the examples in the MongoDB docs and I can't seem to be able to wrap my head around it. Say I have a collection of objects of the form {date: "2010-10-10", type: "EVENT_TYPE_1", user_id: 123, ...} Now I want to get something similar to a SQL GROUP BY query, grouping over both date and type. That is, I want the number of events of each type in each day. Also, I'd like to make it unique by user_id, ie. if a user has more events in the same day, count it only once. I'm trying to do this with map/reduce. I do db.logs.mapReduce(function() { emit(this.type, 1); }, function(k, vals) { var total = 0; for (var i = 0; i < vals.length; i++) total += vals[i]; return total; }}) which nicely groups by type, but now, how can I group by date at the same time? Seems the key in emit() can't be an array (I thought about doing emit([this.date, this.type], 1)). Also, how can I ensure the per-user uniqueness? I'm just starting with MongoDB and I'm still having trouble grasping the basic concepts. Also, there is not much documentation available out there. Any help from more experienced users is appreciated. Thanks!

    Read the article

  • C++ Virtual Methods for Class-Specific Attributes or External Structure

    - by acanaday
    I have a set of classes which are all derived from a common base class. I want to use these classes polymorphically. The interface defines a set of getter methods whose return values are constant across a given derived class, but vary from one derived class to another. e.g.: enum AVal { A_VAL_ONE, A_VAL_TWO, A_VAL_THREE }; enum BVal { B_VAL_ONE, B_VAL_TWO, B_VAL_THREE }; class Base { //... virtual AVal getAVal() const = 0; virtual BVal getBVal() const = 0; //... }; class One : public Base { //... AVal getAVal() const { return A_VAL_ONE }; BVal getBVal() const { return B_VAL_ONE }; //... }; class Two : public Base { //... AVal getAVal() const { return A_VAL_TWO }; BVal getBVal() const { return B_VAL_TWO }; //... }; etc. Is this a common way of doing things? If performance is an important consideration, would I be better off pulling the attributes out into an external structure, e.g.: struct Vals { AVal a_val; VBal b_val; }; storing a Vals* in each instance, and rewriting Base as follows? class Base { //... public: AVal getAVal() const { return _vals->a_val; }; BVal getBVal() const { return _vals->b_val; }; //... private: Vals* _vals; }; Is the extra dereference essentially the same as the vtable lookup? What is the established idiom for this type of situation? Are both of these solutions dumb? Any insights are greatly appreciated

    Read the article

  • (type theoretical) How is ([] ==) [] typed in haskell?

    - by Ingo
    It sounds silly, but I can't get it. Why can the expression [] == [] be typed at all? More specifically, which type (in class Eq) is inferred to the type of list elements? In a ghci session, I see the following: Prelude> :t (==[]) (==[]) :: (Eq [a]) => [a] -> Bool But the constraint Eq [a] implies Eq a also, as is shown here: Prelude> (==[]) ([]::[IO ()]) <interactive>:1:1: No instance for (Eq (IO ())) arising from use of `==' at <interactive>:1:1-2 Probable fix: add an instance declaration for (Eq (IO ())) In the definition of `it': it = (== []) ([] :: [IO ()]) Thus, in []==[], the type checker must assume that the list element is some type a that is in class Eq. But which one? The type of [] is just [a], and this is certainly more general than Eq a = [a].

    Read the article

  • send different object value to different funtions

    - by user295189
    I have the code below. I want to send the value of value1 n.value1s = new Array(); n.value1sIDs = new Array(); n.value1sNames = new Array(); n.value1sColors = new Array(); n.descriptions = new Array(); to pg.loadLinkedvalue1s(n); and for value2 to pg.loadLinkedvalue2s(n); Howd I do that in javascript without haveing to rewrite the complete function please see the code below if(n.id == "row"){ n.rs = n.parentElement; if(n.rs.multiSelect == 0){ n.selected = 1; this.selectedRows = [ n ]; if(this.lastClicked && this.lastClicked != n){ selectionChanged = 1; this.lastClicked.selected = 0; this.lastClicked.style.color = "000099"; this.lastClicked.style.backgroundColor = ""; } } else { n.selected = n.selected ? 0 : 1; this.getSelectedRows(); } this.lastClicked = n; n.value1s = new Array(); n.value1sIDs = new Array(); n.value1sNames = new Array(); n.value1sColors = new Array(); n.descriptions = new Array(); n.value2s = new Array(); n.value2IDs = new Array(); n.value2Names = new Array(); n.value2Colors = new Array(); n.value2SortOrders = new Array(); n.value2Descriptions = new Array(); var value1s = myOfficeFunction.DOMArray(n.all.value1s.all.value1); var value2s = myOfficeFunction.DOMArray(n.all.value1s.all.value2); for(var i=0,j=0,k=1;i<vaue1s.length;i++){ n.sortOrders[j] = k++; n.vaue1s[j] = vaue1s[i].v; n.vaue1IDs[j] = vaue1s[i].i; n.vaue1Colors[j] = vaue1s[i].c; alert(n.vaue1Colors[j]); var vals = vaue1s[i].innerText.split(String.fromCharCode(127)); n.cptSortOrders[j] = k++; n.value2s[j] = value2s[i].v; n.value2IDs[j] = value2s[i].i; n.value2Colors[j] = value2s[i].c; var value2Vals = value2s[i].innerText.split(String.fromCharCode(127)); if(vals.length == 2){ alert(n.vaue1Colors[j]); n.vaue1Names[j] = vals[0]; n.descriptions[j++] = vals[1]; } if(value2Vals.length == 2){ n.value2Names[j] = cptVals[0]; alert(n.value2Names[j]); n.cptDescriptions[j++] = cptVals[1]; alert(n.cptDescriptions[j++]); } } //want to run this with value1 only pg.loadLinkedvalue1s(n); // want to run this with value2 only pg.loadLinkedvalue2s(n); }

    Read the article

  • Interpolating 2d data that is piecewise constant on faces

    - by celil
    I have an irregular mesh which is described by two variables - a faces array that stores the indices of the vertices that constitute each face, and a verts array that stores the coordinates of each vertex. I also have a function that is assumed to be piecewise constant over each face, and it is stored in the form of an array of values per face. I am looking for a way to construct a function f from this data. Something along the following lines: faces = [[0,1,2], [1,2,3], [2,3,4] ...] verts = [[0,0], [0,1], [1,0], [1,1],....] vals = [0.0, 1.0, 0.5, 3.0,....] f = interpolate(faces, verts, vals) f(0.2, 0.2) = 0.0 # point inside face [0,1,2] f(0.6, 0.6) = 1.0 # point inside face [1,2,3] The manual way of evaluating f(x,y) would be to find the corresponding face that the point x,y lies in, and return the value that is stored in that face. Is there a function that already implements this in scipy (or in matlab)?

    Read the article

  • How should I rewrite my code to make it amenable to unittesting?

    - by justin
    I've been trying to get started with unit-testing while working on a little cli program. My program basically parses the command line arguments and options, and decides which function to call. Each of the functions performs some operation on a database. So, for instance, I might have a create function: def create(self, opts, args): #I've left out the error handling. strtime = datetime.datetime.now().strftime("%D %H:%M") vals = (strtime, opts.message, opts.keywords, False) self.execute("insert into mytable values (?, ?, ?, ?)", vals) self.commit() Should my test case call this function, then execute the select sql to check that the row was entered? That sounds reasonable, but also makes the tests more difficult to maintain. Would you rewrite the function to return something and check for the return value? Thanks

    Read the article

  • Why isn't my IO executed in order?

    - by HaskellElephant
    Hi, I'm having some fun learning about the haskell IO. However in my recent exploration of it I have encountered some problems with IO not executing in order, even inside a do construct. In the following code I am just keeping track of what cards are left, where the card is a tuple of chars (one for suit and one for value) then the user is continously asked for wich cards have been played. I want the putStr to be executed between each input, and not at the very end like it is now. module Main where main = doLoop cards doLoop xs = do putStr $ show xs s <- getChar n <- getChar doLoop $ remove (s,n) xs suits = "SCDH" vals = "A23456789JQK" cards = [(s,n) | s <- suits, n <- vals] type Card = (Char,Char) remove :: Card -> [Card] -> [Card] remove card xs = filter (/= card) xs

    Read the article

  • iPhone xcode array losing state after load

    - by Frames84
    Right i've had a search around and can't find anything. @synthesize list; // this is an NSArry -(void) viewDidLoad { NSArray *arr = [self getJSONFeed]; self.List = [arr retain]; // if i copy the access code into here it works fine. } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; NSArray *vals = [list objectAtIndex:row] retain]; NSString *id = [vals valueForKey:@"id"]; // ERROR } right i've taken some of the code to try and provide it as simple as possible, ignore typo's and memory leaks this is sorted. Basically when I select a row I can't get data out of my 'list' array object. Please can anyone help me out?

    Read the article

< Previous Page | 1 2 3 4  | Next Page >