Search Results

Search found 987 results on 40 pages for 'andy gregory'.

Page 10/40 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Exporting to XML, including embedded classes

    - by Andy
    I have an object config which has some properties. I can export this ok, however, it also has an ArrayList which relates to embedded classes which I can't get to appear when I export to XML. Any pointers would be helpful. Export Method public String exportXML(config conf, String path) { String success = ""; try { FileOutputStream fstream = new FileOutputStream(path); try { XMLEncoder ostream = new XMLEncoder(fstream); try { ostream.writeObject(conf); ostream.flush(); } finally { ostream.close(); } } finally { fstream.close(); } } catch (Exception ex) { success = ex.getLocalizedMessage(); } return success; } Config Class (some detail stripped to keep size down) public class config { protected String author = ""; protected String website = ""; private ArrayList questions = new ArrayList(); public config(){ } public void addQuestion(String name) { questions.add(new question(questions.size(), name)); } public void removeQuestion(int id) { questions.remove(id); for (int c = 0; c <= questions.size(); c++) { question q = (question) (questions.get(id)); q.setId(c); } questions.trimToSize(); } public config.question getQuestion(int id){ return (question)questions.get(id); } /** * There can be multiple questions per config. * Questions store all the information regarding what questions are * asked of the user, including images, descriptions, and answers. */ public class question { protected int id; protected String title; protected ArrayList answers; public question(int id, String title) { this.id = id; this.title = title; } public int getId() { return id; } public void setId(int id) { this.id = id; } public void addAnswer(String name) { answers.add(new answer(answers.size(), name)); } public void removeAnswer(int id) { answers.remove(id); for (int c = 0; c <= answers.size(); c++) { answer a = (answer) (answers.get(id)); a.setId(c); } answers.trimToSize(); } public config.question.answer getAnswer(int id){ return (answer)answers.get(id); } public class answer { protected int id; protected String title; public answer(int id, String title) { this.id = id; this.title = title; } public int getId() { return id; } public void setId(int id) { this.id = id; } } } } Resultant XML File <?xml version="1.0" encoding="UTF-8"?> <java version="1.6.0_18" class="java.beans.XMLDecoder"> <object class="libConfig.config"> <void property="appName"> <string>xxx</string> </void> <void property="author"> <string>Andy</string> </void> <void property="website"> <string>www.example.com/dsx.xml</string> </void> </object> </java>

    Read the article

  • opening a fancybox from a drop down box and passing the selected value to it directly

    - by andy
    <select name="mySelectboxsituation_found" id="mySelectboxsituation_found"> <option value="100">Firecall</option> <option value="200">FireAlarm</option> <option value="300">FireAlarm2</option> <option value="400">FireAlarm4</option> </select> < a href="#" class="incidenttype" name="all" onClick="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;"/>CLICK HERE < / a> function cleanUp(){ var subsituation_found1 = $("#fancybox- frame").contents().find('input:radio[name=incident_subcate]:checked').val(); } $(".incidenttype").fancybox({ 'width' : 900, 'height' : 600, 'autoScale': false, 'transitionIn': 'none', 'transitionOut': 'none', 'type': 'iframe', 'onCleanup': cleanUp ); }); clicking on "CLICK HERE" opens the fancybox and transfers the value selected in the drop down box. What I would like to do is open the fancy box when i change the value in the dropdown box...without having to click on the click here link.....i know it is posisble using something like _this....but i am not sure and am looking for some direction... ideally some thing like this ... <select name="mySelectboxsituation_found" id="mySelectboxsituation_found" onChange="JavaScript:var dropdown=document.getElementById('mySelectboxsituation_found');this.href='main_situation_found.php?incident_maincateid='+dropdown.options[dropdown.selectedIndex].value;return true;"> <option value="100">Firecall</option> <option value="200">FireAlarm</option> <option value="300">FireAlarm2</option> <option value="400">FireAlarm4</option> </select> does any have an idea how to do it.... I have also tried... function test_fan() { alert(document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value); var dropval =document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value; return dropval; } $(document).ready(function(){ $("#autostart").fancybox({ 'onStart':test_fan, 'width': 800, 'height': 700, 'type': 'iframe', href:'main_situation_found.php?incident_maincateid='+document.getElementById('mySelectboxsituation_found').options[document.getElementById('mySelectboxsituation_found').selectedIndex].value }); <a href="#" id="autostart" style="display:none"></a> <form><select id="mySelectboxsituation_found" onchange="$('#autostart').trigger('click');"> <option value="">select</option> <option value="100">option 1</option> <option value="200">trigger</option> <option value="300">option 3</option> <option value="400">option 4</option> </select> </form> the really funny that happens there is that .... on the alert id do get the value i selected so if i selected alert fancybox window 100 100 nothing shows up empty 200 200 100 300 300 200 400 400 300 the fancybox seems to me the the previously selected values and i am not sure why that is happening... thanks andy

    Read the article

  • Jquery cycle plugin image resizing issue opera

    - by Sam Gregory
    I am using the cycle plugin within Joomla and it works fine on IE6,FF,SAFARI,CHROME however when you view it in OPERA breaking happens. It loads fine but when it brings in the next slide and every consequent slide after that it re-sizes them to what i can only assume to be the browswe window's width and height. here's my javascript <script type="text/javascript"> $('.fullScreen').cycle({ speed: 1000, timeout: 100 }); </script> css <script type="text/css"> .fullScreen { margin-left: 0px; height: 355px; clear: both; width: 475px; z-index: -1; overflow: hidden; } </script> and finally HTML <div class="fullscreen"> <img width="475px" src="images/someimage1.jpg" /> <img width="475px" src="images/someimage2.jpg" /> <img width="475px" src="images/someimage3.jpg" /> </div> hope I'm not the only one having this problem.

    Read the article

  • How do I use Loki's small object allocator?

    - by Gregory
    I need to use Loki's small object allocator but I am very confused as to how it works. I've read the documentation and lots of forums but it doesnt make sense: some of them say to use the stl, others use custom allocators. I just need to be able to test its performance with allocating and deallocating objects of different sizes. Could someone please provide a small example of how to use it?

    Read the article

  • UIImagePickerController does not deliver geo tag data

    - by Gregory Mace
    When I use UIImagePickerController to select a photo, either from the Camera Roll or the Photo Library, the image that gets returned to me in the method 'didFinishPickingImage' does not contain the exif data for latitude and longitude. I know that the headers are there, because they show up when imported into iPhoto, also if I upload images from the Camera Roll, they also contain the exif headers for location. Is there a way to get UIImagePickerController to deliver that information as well?

    Read the article

  • Bubble Breaker Game Solver better than greedy?

    - by Gregory
    For a mental exercise I decided to try and solve the bubble breaker game found on many cell phones as well as an example here:Bubble Break Game The random (N,M,C) board consists N rows x M columns with C colors The goal is to get the highest score by picking the sequence of bubble groups that ultimately leads to the highest score A bubble group is 2 or more bubbles of the same color that are adjacent to each other in either x or y direction. Diagonals do not count When a group is picked, the bubbles disappear, any holes are filled with bubbles from above first, ie shift down, then any holes are filled by shifting right A bubble group score = n * (n - 1) where n is the number of bubbles in the bubble group The first algorithm is a simple exhaustive recursive algorithm which explores going through the board row by row and column by column picking bubble groups. Once the bubble group is picked, we create a new board and try to solve that board, recursively descending down Some of the ideas I am using include normalized memoization. Once a board is solved we store the board and the best score in a memoization table. I create a prototype in python which shows a (2,15,5) board takes 8859 boards to solve in about 3 seconds. A (3,15,5) board takes 12,384,726 boards in 50 minutes on a server. The solver rate is ~3k-4k boards/sec and gradually decreases as the memoization search takes longer. Memoization table grows to 5,692,482 boards, and hits 6,713,566 times. What other approaches could yield high scores besides the exhaustive search? I don't seen any obvious way to divide and conquer. But trending towards larger and larger bubbles groups seems to be one approach Thanks to David Locke for posting the paper link which talks above a window solver which uses a constant-depth lookahead heuristic.

    Read the article

  • Help me with a solution for what could be solutioned by virtual static fields... in FPC

    - by Gregory Smith
    Hi I'm doing an event manager in Freepascal Each event is an object type TEvent (=object), each kind of event must derive from this class. Events are differentiated by an integer identificator, assigned dynamically. The problem is that i want to retrieve the event id of an instance, and i can't do it well. All instances of a class(object) have a unique id = so it should be static field. All classes have a diferent id = so it should be virtual. Event ids are assignated in run time, and can change = so it can't be a simple method In sum, I can't put all this together. I'm looking for an elegant solution, i don't want to write a hardcoded table, actualizing it in every constructor... etc, i'd prefer something taking advantage of the polymorphism Can anyone help me with another technical or design solution? I remark I don't want to use class instead of object construct.(property doesn't work on objects? :(

    Read the article

  • MooTools events not firing in IE8

    - by gregory
    I have a Mootools asset created like so: // Create a new asset var asset = new Asset.image(path, { title: this.language.download, events: {click: this.download.bind(this, link)}, }); I have a method of a MooTools object defined as such: download: function(e) { // The path to download console.log('download: ' + e); }, In Firefox the console.log print shows up. In IE8, however, I have no luck. Am I missing something? Any tips or advice would be greatly appreciated. TIA!

    Read the article

  • Why is WPO(whole-program optimization) not doing any improvements in my program size? (FPC 2.4.0)

    - by Gregory Smith
    I use FPC 2.4.0 for WinXP(binary from the official page), also tryed with same version but compiled from source on my comp. I put something like this: I:\pascal\fpc-2.4.0.source\fpc-2.4.0\compiler\ppc386 -FWserver-1.wpo -OWsymbolliveness -CX -XX -Xs- -al -Os -oServer1.o Server I:\pascal\fpc-2.4.0.source\fpc-2.4.0\compiler\ppc386 -FWserver-2.wpo -OWsymbolliveness -Fwserver-1.wpo -Owsymbolliveness -CX -XX -Xs- -al -Os -oServer2.o Server ..(up to 100 times) but always same .wpo files, and same .o sizes(.s, assembly files change intermittently) I also not(through compiler messages), that not used variables are still alive. Also tryed -OWall -owall What am i doing wrong?

    Read the article

  • How can I get at the raw bytes of the request in WCF?

    - by Gregory Higley
    For logging purposes, I want to get at the raw request sent to my RESTful web service implemented in WCF. I have already implemented IDispatchMessageInspector. In my implementation of AfterReceiveRequest, I want to spit out the raw bytes of the message even (and especially) if the content of the message is invalid. This is for debugging purposes. My service works perfectly already, but it is often helpful when working through problems with clients who are trying to call the service to know what it was they sent, i.e., the raw bytes. For example, let's say that instead of sending a well-formed XML document, they post the string "your mama" to my service endpoint. I want to see that that's what they did. Unfortunately using MessageBuffer::CreateBufferedCopy() won't work unless the contents of the message are already well-formed XML. Here's (roughly) what I already have in my implementation of AfterReceiveRequest: // The immediately following line raises an exception if the message // does not contain valid XML. This is uncool because I want // the raw bytes regardless of whether they are valid or not. using (MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue)) { using (MemoryStream stream = new MemoryStream()) using (StreamReader reader = new StreamReader(stream)) { buffer.WriteMessage(stream); stream.Position = 0; Trace.TraceInformation(reader.ReadToEnd()); } request = buffer.CreateMessage(); } My guess here is that I need to get at the raw request before it becomes a Message. This will most likely have to be done at a lower level in the WCF stack than an IDispatchMessageInspector. Anyone know how to do this?

    Read the article

  • How can I list the properties of an object programmatically in VB6?

    - by Gregory Higley
    A friend of mine is working on a legacy VB6 project. I haven't touched that language in ten years, so I'm pretty rusty. Anyway, is there any kind of reflection API for VB6? Specifically, he needs a way to iterate the properties (and types) of a user-created Class. (In other words, not an external COM object, but an internal "Class Module" as it's called.) How can this be done?

    Read the article

  • Why do I not get the correct answer for Euler 56 in J?

    - by Gregory Higley
    I've solved 84 of the Project Euler problems, mostly in Haskell. I am now going back and trying to solve in J some of those I already solved in Haskell, as an exercise in learning J. Currently, I am trying to solve Problem 56. Let me stress that I already know what the right answer is, since I've already solved it in Haskell. It's a very easy, trivial problem. I will not give the answer here. Here is my solution in J: digits =: ("."0)":"0 eachDigit =: adverb : 'u@:digits"0' NB. I use this so often I made it an adverb. cartesian =: adverb : '((#~ #) u ($~ ([:*~#)))' >./ +/ eachDigit x: ^ cartesian : i. 99 This produces a number less than the desired result. In other words, it's wrong somehow. Any J-ers out there know why? I'm baffled, since it's pretty straightforward and totally brute force.

    Read the article

  • How can I generate the Rowland prime sequence idiomatically in J?

    - by Gregory Higley
    If you're not familiar with the Rowland prime sequence, you can find out about it here. I've created an ugly, procedural monadic verb in J to generate the first n terms in this sequence, as follows: rowland =: monad define result =. 0 $ 0 t =. 1 $ 7 while. (# result) < y do. a =. {: t n =. 1 + # t t =. t , a + n +. a d =. | -/ _2 {. t if. d > 1 do. result =. ~. result , d end. end. result ) This works perfectly, and it indeed generates the first n terms in the sequence. (By n terms, I mean the first n distinct primes.) Here is the output of rowland 20: 5 3 11 23 47 101 7 13 233 467 941 1889 3779 7559 15131 53 30323 60647 121403 242807 My question is, how can I write this in more idiomatic J? I don't have a clue, although I did write the following function to find the differences between each successive number in a list of numbers, which is one of the required steps. Here it is, although it too could probably be refactored by a more experienced J programmer than I: diffs =: monad : '}: (|@({.-2&{.) , $:@}.) ^: (1 < #) y'

    Read the article

  • Calculate the digital root of a number

    - by Gregory Higley
    A digital root, according to Wikipedia, is "the number obtained by adding all the digits, then adding the digits of that number, and then continuing until a single-digit number is reached." For instance, the digital root of 99 is 9, because 9 + 9 = 18 and 1 + 8 = 9. My Haskell solution -- and I'm no expert -- is as follows. digitalRoot n | n < 10 = n | otherwise = digitalRoot . sum . map (\c -> read [c]) . show $ n As a language junky, I'm interested in seeing solutions in as many languages as possible, both to learn about those languages and possibly to learn new ways of using languages I already know. (And I know at least a bit of quite a few.) I'm particularly interested in the tightest, most elegant solutions in Haskell and REBOL, my two principal "hobby" languages, but any ol' language will do. (I pay the bills with unrelated projects in Objective C and C#.) Here's my (verbose) REBOL solution: digital-root: func [n [integer!] /local added expanded] [ either n < 10 [ n ][ expanded: copy [] foreach c to-string n [ append expanded to-integer to-string c ] added: 0 foreach e expanded [ added: added + e ] digital-root added ] ] EDIT: As some have pointed out either directly or indirectly, there's a quick one-line expression that can calculate this. You can find it in several of the answers below and in the linked Wikipedia page. (I've awarded Varun the answer, as the first to point it out.) Wish I'd known about that before, but we can still bend our brains with this question by avoiding solutions that involve that expression, if you're so inclined. If not, Crackoverflow has no shortage of questions to answer. :)

    Read the article

  • Building 'flat' rather than 'tree' LINQ expressions

    - by Ian Gregory
    I'm using some code (available here on MSDN) to dynamically build LINQ expressions containing multiple OR 'clauses'. The relevant code is var equals = values.Select(value => (Expression)Expression.Equal(valueSelector.Body, Expression.Constant(value, typeof(TValue)))); var body = equals.Aggregate<Expression>((accumulate, equal) => Expression.Or(accumulate, equal)); This generates a LINQ expression that looks something like this: (((((ID = 5) OR (ID = 4)) OR (ID = 3)) OR (ID = 2)) OR (ID = 1)) I'm hitting the recursion limit (100) when using this expression, so I'd like to generate an expression that looks like this: (ID = 5) OR (ID = 4) OR (ID = 3) OR (ID = 2) OR (ID = 1) How would I modify the expression building code to do this?

    Read the article

  • Use a stylesheet when NOT IE

    - by Sam Gregory
    When i use this code <!--[if IE 6]> <link rel="stylesheet" href="ie6.css" type="text/css" /> <![endif]--> <!--[if !IE]> <link rel="stylesheet" href="not_ie.css" type="text/css" /> <![endif]--> IE 6 does correctly use the specified stylesheet but all other browsers ignore both when they should be using the one that basically states, use this stylesheet if you are not IE. Any ideas?

    Read the article

  • How can I define a verb in J that applies a different verb alternately to each atom in a list?

    - by Gregory Higley
    Imagine I've defined the following name in J: m =: >: i. 2 4 5 This looks like the following: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 I want to create a monadic verb of rank 1 that applies to each list in this list of lists. It will double (+:) or add 1 (>:) to each alternate item in the list. If we were to apply this verb to the first row, we'd get 2 3 6 5 10. It's fairly easy to get a list of booleans which alternate with each item, e.g., 0 1 $~{:$ m gives us 0 1 0 1 0. I thought, aha! I'll use something like +:`>: @. followed by some expression, but I could never quite get it to work. Any suggestions? UPDATE The following appears to work, but perhaps it can be refactored into something more elegant by a J pro. poop =: monad define (($ y) $ 0 1 $~{:$ y) ((]+:)`(]:) @. [)"0 y )

    Read the article

  • Use a styleshhet when NOT IE

    - by Sam Gregory
    When i use this code <!--[if IE 6]> <link rel="stylesheet" href="ie6.css" type="text/css" /> <![endif]--> <!--[if !IE]> <link rel="stylesheet" href="not_ie.css" type="text/css" /> <![endif]--> IE 6 does correctly use the specified stylesheet but all other browsers ignore both when they should be using the one that basically states, use this stylesheet if you are not IE. Any ideas?

    Read the article

  • How to filter a list in J?

    - by Gregory Higley
    I'm currently learning the fascinating J programming language, but one thing I have not been able to figure out is how to filter a list. Suppose I have the arbitrary list 3 2 2 7 7 2 9 and I want to remove the 2s but leave everything else unchanged, i.e., my result would be 3 7 7 9. How on earth do I do this?

    Read the article

  • How can I maximally partition a set?

    - by Gregory Higley
    I'm trying to solve one of the Project Euler problems. As a consequence, I need an algorithm that will help me find all possible partitions of a set, in any order. For instance, given the set 2 3 3 5: 2 | 3 3 5 2 | 3 | 3 5 2 | 3 3 | 5 2 | 3 | 3 | 5 2 5 | 3 3 and so on. Pretty much every possible combination of the members of the set. I've searched the net of course, but haven't found much that's directly useful to me, since I speak programmer-ese not advanced-math-ese. Can anyone help me out with this? I can read pretty much any programming language, from BASIC to Haskell, so post in whatever language you wish.

    Read the article

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