Search Results

Search found 3177 results on 128 pages for 'david murrant'.

Page 86/128 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • Logic for family tree program

    - by david robers
    Hi All, I am creating a family tree program in Java, or at least trying to. I have developed several classes: Person - getters and setter for name gender age etc FamilyMember - extends Person getters and setters for setting arents and children Family - which consists of multiple family members and methods for adding removing members FamilyTree which is the main class for setting relationships. I have two main problems: 1) I need to set the relationships between people. Currently I am doing: FamilyMember A, FamilyMember B B.setMother(A); A.setChild(B); The example above is for setting a mother child relationship. This seems very clunky. Its getting very long winded to implement all relationships. Any ideas on how to implement multiple relationships in a less prodcedural way? 2) I have to be able to display the family tree. How can I do this? Are there any custom classes out there to make life easier? Thanks for your time...

    Read the article

  • Serialization of non-required fields in protobuf-net

    - by David Hedlund
    I have a working java client that is communicating with Google, through ProtoBuf serialized messages. I am currently trying to translate that client into C#. I have a .proto file where the parameter appId is an optional string. Its default value in the C# representation as generated by the protobuf-net library is an empty string, just as it is in the java representation of the same file. message AppsRequest { optional AppType appType = 1; optional string query = 2; optional string categoryId = 3; optional string appId = 4; optional bool withExtendedInfo = 6; } I find that when I explicitly set appId to "" in the java client, the client stops working (403 Bad Request from Google). When I explicitly set appId to null in the java client, everything works, but only because hasAppId is being set to false (I'm uncertain as to how that affects the serialization). In the C# client, I always get 403 responses. I don't see any logic behind the distinction between not setting a value, and setting the default value, that seems to make all the difference in the java client. Since the output is always a binary stream, I am not sure if the successful java messages are being serialized with an empty string, or not serialized at all. In the C# client, I've tried setting IsRequired to true on the ProtoMember attribute, to force them to serialize, and I've tried setting the default value to null, and explicitly set "", so I'm quite sure I've tried some configuration where the value is being serialized. I've also played around with ProtoBuf.ProtoIgnore and at some point, removing the appId parameter altogether, but I haven't been able to avoid the 403 errors in C#. I've tried manually copying the serialized string from java, and that resolved my issues, so I'm certain that the rest of the HTTP Request is working, and the error can be traced to the serialized object. My serialization is simply this: var clone = ProtoBuf.Serializer.DeepClone(request); MemoryStream ms = new MemoryStream(2000); ProtoBuf.Serializer.Serialize(ms, clone); var bytearr = ms.ToArray(); string encodedData = Convert.ToBase64String(bytearr); I'll admit to not being quite sure about what DeepClone does. I've tried both with and without it...

    Read the article

  • Silverlight 4 business application themes

    - by David Brunelle
    Hi, We are starting a new SilverLight 4 Business Application project and are looking for theme. All we can find on the web are Navigation Application themes, which when applied to business application project, don't work. Most even have compilation errors. Is there a place on the web to get theme specifically for that project or is there a way to translate navigation application theme into business application theme? Thank you

    Read the article

  • Good tools for keeping the content in test/staging/live environments synchronized

    - by David Stratton
    I'm looking for recommendations on automated folder synchronization tools to keep the content in our three environments synchronized automatically. Specifically, we have several applications where a user can upload content (via a File Upload page or a similar mechanism), such as images, pdf files, word documents, etc. In the past, we had the user doing this to our live server, and as a result, our test and staging servers had to be manually synchronized. Going forward, we will have them upload content to the staging server, and we would like some software to automatically copy the files off to the test and live servers EITHER on a scheduled basis OR as the files get uploaded. I was planning on writing my own component, and either set it up as a scheduled task, or use a FileSystemWatcher, but it occurred to me that this has probably already been done, and I might be better off with some sort of synchronization tool that already exists. On our web site, there are a limited number of folders that we want to keep synchronized. In these folders, it is an all or nothing - we want to make sure the folders are EXACT duplicates. This should make it fairly straightforward, and I would think that any software that can synchronize folders would be OK, except that we also would like the software to log changes. (This rules out simple BATCH files.) So I'm curious, if you have a similar environment, how did you solve the challenge of keeping everything synchronized. Are you aware of a tool that is reliable, and will meet our needs? If not, do you have a recommendation for something that will come close, or better yet, an open source solution where we can get the code and modify it as needed? (preferably .NET). Added Also, I DID google this first, but there are so many options, I am interested mostly in knowing what actually works well vs what they SAY works, which is why I'm asking here.

    Read the article

  • Updating the launcher icon at run-time

    - by david
    Is it possible to update the launcher icon dynamically? Currently it seems that it can only be set statically at build time using the android:icon attribute in the AndroidManifest.xml file. For example, to display a unique icon based on the device's location? Is this something that can be achieved using aliases? If so, can an alias's launcher icon be enabled/disabled dynamically?

    Read the article

  • In .NET, how do I prevent, or handle, tampering with form data of disabled fields before submission?

    - by David
    Hi, If a disabled drop-down list is dynamically rendered to the page, it is still possible to use Firebug, or another tool, to tamper with the submitted value, and to remove the "disabled" HTML attribute. This code: protected override void OnLoad(EventArgs e) { var ddlTest = new DropDownList() {ID="ddlTest", Enabled = false}; ddlTest.Items.AddRange(new [] { new ListItem("Please select", ""), new ListItem("test 1", "1"), new ListItem("test 2", "2") }); Controls.Add(ddlTest); } results in this HTML being rendered: <select disabled="disabled" id="Properties_ddlTest" name="Properties$ddlTest"> <option value="" selected="selected">Please select</option> <option value="1">test 1</option> <option value="2">test 2</option> </select> The problem occurs when I use Firebug to remove the "disabled" attribute, and to change the selected option. On submission of the form, and re-creation of the field, the newly generated control has the correct value by the end of OnLoad, but by OnPreRender, it has assumed the identity of the submitted control and has been given the submitted form value. .NET seems to have no way of detecting the fact that the field was originally created in a disabled state and that the submitted value was faked. This is understandable, as there could be legitimate, client-side functionality that would allow the disabled attribute to be removed. Is there some way, other than a brute force approach, of detecting that this field's value should not have been changed? I see the brute force approach as being something crap, like saving the correct value somewhere while still in OnLoad, and restoring the value in the OnPreRender. As some fields have dependencies on others, that would be unacceptable to me.

    Read the article

  • Moving a Point along a Path in SQL Server 2008

    - by David Pfeffer
    I have a geography field stored in my database, holding a linestring path. I want to move a point n meters along this linestring, and return the destination. For example, I want the destination point 500 meters along the linestring starting from its beginning. Here's an example -- what is the YourFunctionHere? Or, is there another way? DECLARE @g geography; SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656, -122.310 47.690)', 4326); SELECT @g.YourFunctionHere(100).ToString();

    Read the article

  • Ruby: Why is Array.sort slow for large objects?

    - by David Waller
    A colleague needed to sort an array of ActiveRecord objects in a Rails app. He tried the obvious Array.sort! but it seemed surprisingly slow, taking 32s for an array of 3700 objects. So just in case it was these big fat objects slowing things down, he reimplemented the sort by sorting an array of small objects, then reordering the original array of ActiveRecord objects to match - as shown in the code below. Tada! The sort now takes 700ms. That really surprised me. Does Ruby's sort method end up copying objects about the place rather than just references? He's using Ruby 1.8.6/7. def self.sort_events(events) event_sorters = Array.new(events.length) {|i| EventSorter.new(i, events[i])} event_sorters.sort! event_sorters.collect {|es| events[es.index]} end private # Class used by sort_events class EventSorter attr_reader :sqn attr_reader :time attr_reader :index def initialize(index, event) @index = index @sqn = event.sqn @time = event.time end def <=>(b) @time != b.time ? @time <=> b.time : @sqn <=> b.sqn end end

    Read the article

  • Null-free "maps": Is a callback solution slower than tryGet()?

    - by David Moles
    In comments to "How to implement List, Set, and Map in null free design?", Steven Sudit and I got into a discussion about using a callback, with handlers for "found" and "not found" situations, vs. a tryGet() method, taking an out parameter and returning a boolean indicating whether the out parameter had been populated. Steven maintained that the callback approach was more complex and almost certain to be slower; I maintained that the complexity was no greater and the performance at worst the same. But code speaks louder than words, so I thought I'd implement both and see what I got. The original question was fairly theoretical with regard to language ("And for argument sake, let's say this language don't even have null") -- I've used Java here because that's what I've got handy. Java doesn't have out parameters, but it doesn't have first-class functions either, so style-wise, it should suck equally for both approaches. (Digression: As far as complexity goes: I like the callback design because it inherently forces the user of the API to handle both cases, whereas the tryGet() design requires callers to perform their own boilerplate conditional check, which they could forget or get wrong. But having now implemented both, I can see why the tryGet() design looks simpler, at least in the short term.) First, the callback example: class CallbackMap<K, V> { private final Map<K, V> backingMap; public CallbackMap(Map<K, V> backingMap) { this.backingMap = backingMap; } void lookup(K key, Callback<K, V> handler) { V val = backingMap.get(key); if (val == null) { handler.handleMissing(key); } else { handler.handleFound(key, val); } } } interface Callback<K, V> { void handleFound(K key, V value); void handleMissing(K key); } class CallbackExample { private final Map<String, String> map; private final List<String> found; private final List<String> missing; private Callback<String, String> handler; public CallbackExample(Map<String, String> map) { this.map = map; found = new ArrayList<String>(map.size()); missing = new ArrayList<String>(map.size()); handler = new Callback<String, String>() { public void handleFound(String key, String value) { found.add(key + ": " + value); } public void handleMissing(String key) { missing.add(key); } }; } void test() { CallbackMap<String, String> cbMap = new CallbackMap<String, String>(map); for (int i = 0, count = map.size(); i < count; i++) { String key = "key" + i; cbMap.lookup(key, handler); } System.out.println(found.size() + " found"); System.out.println(missing.size() + " missing"); } } Now, the tryGet() example -- as best I understand the pattern (and I might well be wrong): class TryGetMap<K, V> { private final Map<K, V> backingMap; public TryGetMap(Map<K, V> backingMap) { this.backingMap = backingMap; } boolean tryGet(K key, OutParameter<V> valueParam) { V val = backingMap.get(key); if (val == null) { return false; } valueParam.value = val; return true; } } class OutParameter<V> { V value; } class TryGetExample { private final Map<String, String> map; private final List<String> found; private final List<String> missing; public TryGetExample(Map<String, String> map) { this.map = map; found = new ArrayList<String>(map.size()); missing = new ArrayList<String>(map.size()); } void test() { TryGetMap<String, String> tgMap = new TryGetMap<String, String>(map); for (int i = 0, count = map.size(); i < count; i++) { String key = "key" + i; OutParameter<String> out = new OutParameter<String>(); if (tgMap.tryGet(key, out)) { found.add(key + ": " + out.value); } else { missing.add(key); } } System.out.println(found.size() + " found"); System.out.println(missing.size() + " missing"); } } And finally, the performance test code: public static void main(String[] args) { int size = 200000; Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < size; i++) { String val = (i % 5 == 0) ? null : "value" + i; map.put("key" + i, val); } long totalCallback = 0; long totalTryGet = 0; int iterations = 20; for (int i = 0; i < iterations; i++) { { TryGetExample tryGet = new TryGetExample(map); long tryGetStart = System.currentTimeMillis(); tryGet.test(); totalTryGet += (System.currentTimeMillis() - tryGetStart); } System.gc(); { CallbackExample callback = new CallbackExample(map); long callbackStart = System.currentTimeMillis(); callback.test(); totalCallback += (System.currentTimeMillis() - callbackStart); } System.gc(); } System.out.println("Avg. callback: " + (totalCallback / iterations)); System.out.println("Avg. tryGet(): " + (totalTryGet / iterations)); } On my first attempt, I got 50% worse performance for callback than for tryGet(), which really surprised me. But, on a hunch, I added some garbage collection, and the performance penalty vanished. This fits with my instinct, which is that we're basically talking about taking the same number of method calls, conditional checks, etc. and rearranging them. But then, I wrote the code, so I might well have written a suboptimal or subconsicously penalized tryGet() implementation. Thoughts?

    Read the article

  • [iText] Inserting Image onCloseDocument

    - by David
    I'm trying to insert an image in the footer of my document using iText's onCloseDocument event. I have the following code: public void onCloseDocument(PdfWriter writer, Document document) { PdfContentByte pdfByte = writer.getDirectContent(); try { // logo is a non-null global variable Image theImage = new Jpeg(logo); pdfByte.addImage(theImage, 400.0f, 0.0f, 0.0f, 400.0f, 0.0f, 0.0f); } catch (Exception e) { e.printStackTrace(); } } The code throws no exceptions, but it also fails to insert the image. This identical code is used onOpenDocument to insert the same logo. The only difference between the two methods are the coordinates in pdfByte.addImage. However, I've tried quite a few different coordinations in onCloseDocument and none of them appear anywhere in my document. Is there any troubleshooting technique for detecting content which is displayed off-page in a PDF? If not, can anyone see the problem with my onCloseDocument method? Edit: As a followup, it seems that onDocumentClose puts its content on page document.length() + 1 (according to its API). However, I don't know how to change the page number back to document.length() and place my logo on the last page.

    Read the article

  • Parsing Complex Text File with C#

    - by David
    Hello, I need to parse a text file that has a lot of levels and characters. I've been trying different ways to parse it but I haven't been able to get anything to work. I've included a sample of the text file I'm dealing with. Any suggestions on how I can parse this file? I have denoted the parts of the file I need with TEXTINEED. (bean name: 'TEXTINEED context: (list '/text '/content/home/left-nav/text '/content/home/landing-page) type: '/text/types/text module: '/modules/TEXTINEED source: '|moretext| ((contents (list (list (bean type: '/directory/TEXTINEED ((directives (bean ((chartSize (list 600 400)) (showCorners (list #f)) (showColHeader (list #f)) (showRowHeader (list #f))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "MTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "QTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400)))))))) Thanks!

    Read the article

  • Detecting GWT RichTextArea 'dirty' state

    - by David
    I want to detect when the contents of my GWT RichTextArea become 'dirty' (have been changed by the user) in order to enable a 'save' button accordingly. I suppose I could listen for key presses that are likely to have changed the contents; but browser support for key presses is notoriously quirky. I suppose I could, before editing begins, save the original contents in a variable, and upon key press, compare the current contents against that variable, but doing that on each key press is going to be really slow. Is there some neat way to achieve RichTextArea dirty-detection?

    Read the article

  • Clickonce redirect

    - by David Hagan
    Is it possible to deploy an application (using an existing clickonce deployment URL, such that users update to that version) which changes the deployment URL of the deployed application? The scenario is that I have a deployed client (A), which is stable and has been in use for over a year, and a new client (B), which is in development and will be used. However, B and A have different UIDs so that they can both be deployed on the same system together. At some point in the future, I'd like to automatically migrate users who have been using A to B, but I'd hope that Clickonce is well-designed enough to not upgrade A to B if I place B's install files in A's install directory (because it should be checking those UIDs). I know that a C# application that's been deployed through clickonce has some access to its own deployment method, and I'm wondering whether I'm able to change the upgrade-location. I'm hoping to do this quietly without much involvement of the user (and I understand that quiet redirects are heavily frowned upon, for good reasons) and am wondering whether anyone has any experience of trying to modify an installed clickonce's deployment/upgrade information with an update.

    Read the article

  • C inline assembly of x96 fbstp instruction

    - by David HUnter
    Was wondering how to inline a usage of fbstp on a 32 bit I86 architecture. I tried something like int main( ) { double foo = 100.0; long bar = 0; asm( "pushl %1; fbstp %0" : "=m"(bar) : "r"(foo) ); ... But bar is unchanged. I have tried reading everything I can find on this but most example simply do things like add two integers together. I can’t find any that talk about pushing operands onto the stack and what I should be doing when an instruction like fbstp writes 80 bits of data back to memory ( i.e. what C type to use ) and how to specify it in the asm syntax. Also on x86-64 there seems to be a pushq and no pushl but fbstp still exists whereas fbstq does not. Is there some other magic for 64 bit.

    Read the article

  • Python: How do I pass a variable by reference?

    - by David Sykes
    The Python documentation seems unclear about whether parameters are passed by reference or value, and the following code produces the unchanged value 'Original' class PassByReference: def __init__(self): self.variable = 'Original' self.Change(self.variable) print self.variable def Change(self, var): var = 'Changed' Is there something I can do to pass the variable by actual reference? Update: I am coming to the conclusion that while Andrea answered my actual question (Can you... No but you can...), on the subject of pass by reference Blair Conrad is more technically correct. As I understand it the crux is that a copy of a reference is being passed. If you assign that copy, as in my example, then you lose the reference to the original and it remains unchanged. If, however, you 'use' that reference, for example append on a passed list, then the original is changed. I will see how the comments and votes go before choosing the answer people think is the best

    Read the article

  • A follow up on type coercion in C++, as it may be construed by type conversion

    - by David
    This is a follow up to my previous question. Consider that I write a function with the following prototype: int a_function(Foo val); Where foo is believed to be a type defined unsigned int. This is unfortunately not verifiable for lack of documentation. So, someone comes along and uses a_function, but calls it with an unsigned int as an argument. Here the story takes a turn. Foo turns out to actually be a class, which can take an unsigned int as a single argument of unsigned int in an explicit constructor. Is it a standard and reliable behavior for the compiler to render the function call by doing a type conversion on the argument. I.e. is the compiler supposed to recognize the mismatch and insert the constructor? Or should I get a compile time error reporting the type mismatch.

    Read the article

  • Is there a good argument for software patents?

    - by David Nehme
    Now that it looks like software patents are going to be severely limited, does anyone have a good argument for keeping them. It seems like copyright law serves software fine and patents just add overhead to what should be an almost frictionless process. Are there any examples of software that wouldn't have been written if not for patents?

    Read the article

  • F# - core benefits

    - by David Neale
    Since the release of VS 2010 I've seen F# more strongly advertised by Microsoft. What are the core benefits of using this language? What problems does it most naturally lend itself to? What is the learning curve like?

    Read the article

  • var in C# - Why can't it be used as a member variable?

    - by David Neale
    Why is it not possible to have implicitly-typed variables at a class level within C# for when these variables are immediately assigned? ie: public class TheClass { private var aList = new List<string>(); } Is it just something that hasn't been implemented or is there a conceptual/technical reason for why it hasn't been done?

    Read the article

  • Are all public read/write members serialized with XmlSerializer?

    - by David
    I have a handful of public read/write members that are not being serialized and I can't figure out why. Reviewing some code, and my root class is marked serializable: [Serializable] public class MyClass I have a default constructor that initializes 10-15 string members. There are about 50 public read/write string members in MyClass with get and set--no explicit serialization attributes are set on any of these. Serialization looks like this: XmlSerializer x = new XmlSerializer(typeof(MyClass)); TextWriter twWriter = new StreamWriter(sFileName); x.Serialize(twWriter, this); twWriter.Close(); only a handful (20-30) of these members are actually seralized to my xml file. what am i missing or misunderstanding about the XmlSerializer class?

    Read the article

  • Need this VB code changed into Python.

    - by David
    I wrote this code in VB to label columns in a table but now im writting a python script to automate the process and i can't make it work. Any thoughts?? Static v1 as variant Static v2 as variant Dim Output as double Dim Start as double Start = 1 If v2 = [XMIN] Then Output = v1 Else Output = v1 + 1 End If v1 = Output v2 = [XMIN]

    Read the article

  • Getting specific values with regex [JAVA, ANDROID]

    - by David
    I need to knowingly isolate each row of the vcard and get its value. For instance, I want to get "5555" from X-CUSTOMFIELD. So far, my thoughts are: "X-CUSTOMFIELD;\d+" I have been looking at some tutorials and I am a little confused with what function to use? What would my regex above return? Would it give me the whole line or just the numerical part (5555)? I was thinking I i get the whole row, I can use substring to get the digits? BEGIN:VCARD VERSION:2.1 N:Last;First; FN:First Last TEL;HOME;VOICE:111111 TEL;MOBILE;VOICE:222222 X-CUSTOMFIELD;5555 END:VCARD

    Read the article

  • How to bind to localStorage change event using jQuery for all browsers?

    - by David Glenn
    How do I bind a function to the HTML5 localStorage change event using jQuery? $(function () { $(window).bind('storage', function (e) { alert('storage changed'); }); localStorage.setItem('a', 'test'); }); I've tried the above but the alert is not showing. Update: It works in Firefox 3.6 but it doesn't work in Chrome 8 or IE 8 so the question should be more 'How to bind to localStorage change event using jQuery for all browsers?'

    Read the article

  • Reply to specific socket client.

    - by David
    hi, I am using C#. I have one socket server in PC A and three socket clients in PC B,PC C,and PC D.When PC A receives data, I want to send this data to either PC B or PC C or PC D. I mean i don't want to send this data to all PC.I just want to send the PC i need to send. Now, when server receives data from one client PC, it sends back to all clients PC. Thank you.

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >