Daily Archives

Articles indexed Tuesday May 18 2010

Page 8/121 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • java.util.BitSet -- set() doesn't work as expected

    - by dwhsix
    Am I missing something painfully obvious? Or does just nobody in the world actually use java.util.BitSet? The following test fails: @Test public void testBitSet() throws Exception { BitSet b = new BitSet(); b.set(0, true); b.set(1, false); assertEquals(2, b.length()); } It's really unclear to me why I don't end up with a BitSet of length 2 and the value 10. I peeked at the source for java.util.BitSet, and on casual inspection it seems to fail to make sufficient distinction between a bit that's been set false and a bit that has never been set to any value... (Note that explicitly setting the size of the BitSet in the constructor has no effect, e.g.: BitSet b = new BitSet(2);

    Read the article

  • disable arrow key on flowplayer scrollable

    - by loo
    i need to disable the arrow keys in a flowplayer.org scrollable i have a text input that i cant move between the letters due to the scroller moving when arrow keys pressed, i dont care to disable the scroller keys permanently. thanks link to scrollable link to forum to disable keys

    Read the article

  • Java applet for Tower of Hanoi

    - by Naren
    I am planning to write a Java applet for Tower of Hanoi similar to link( http://www.mazeworks.com/hanoi/index.htm ) Can you suggest how should I start and proceed. And, btw, does it require multi threading? And also, major part of my doubt is to make a disc being clickable and being able to drag and drop the disc on a tower. detect a tower (if a disc is being dragged using mouse)

    Read the article

  • "out of scope" error when iterating an NSMutableArray

    - by wgpubs
    Why am I getting an "out of scope" error whenever I try to access the "url" variable in this loop? for(NSString *url in self.winnerImageURLs) { [mediaItemString appendFormat:@"{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"},", url, url]; } The class of very item in the "self.winnerImageURLs" NSMutableArray comes back as NSCFString so I'm not sure what the dealio is here. Any ideas on what I'm doing wrong??? Thanks

    Read the article

  • horizontally scrollable table column

    - by Alexandru Cucu
    Hello, I would need to build a html table that has a horizontally scrolable column. The scroll should be placed in the column's header. My question first question is: do you know any jquery plug-in that is able to do this? My second question: is this possible using a single table. I've heard that in order to do this you need to use multiple synchronized tables that look like a single one from the user's perspective. Any ideea/advice would be welcomed. Thank you.

    Read the article

  • Problem with "scopes" of variables in try catch blocks in Java

    - by devoured elysium
    Could anyone explain me why in the last lines, br is not recognized as variable? I've even tried putting br in the try clause, setting it as final, etc. Does this have anything to do with Java not support closures? I am 99% confident similar code would work in C#. private void loadCommands(String fileName) { try { final BufferedReader br = new BufferedReader(new FileReader(fileName)); while (br.ready()) { actionList.add(CommandFactory.GetCommandFromText(this, br.readLine())); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) br.close(); //<-- This gives error. It doesn't // know the br variable. } } Thanks

    Read the article

  • Attaching javascript events to form widgets

    - by user334017
    I have a form with a drop down menu and I want to do a javascript action whenever the user changes the selection. I imagine it is possible find the input later, using javascript, and attach an event to to it; but it seems like it would be easier if there was some sort of attribute or option that could be defined in form-configure(): e.g. $this->widgetSchema['menu'] = new sfWidgetFormChoice(array( ... 'onclick' => javascript function )); obviously this doesn't work, and it probably wouldn't be an onclick method either, but my question is how do you attach a javascript event to a input/widget?

    Read the article

  • Discovered: Run A Video In An Image

    - by Moon .
    okay i have found the way to run a video in a image.... the procedure as given below 1 - Run a video in Windows Media Player 2 - While the video running, Press Print Screen 3 - Paste it in MS Paint 4 - Save the image in JPEG or BMP format 5 - Run any video in Windows Media Player again 6 - Now open that image, in Windows Page\Fax Viewer or ACDsee etc. 7 - at this time the win. media player is playing and the image is open 8- Switch to image (focus on image) and you will see the currently running video in the image can anybody with extensive knowledge of windows tell me why does this happen. Well this doesn't work in all versions of windows and media players. i tried this on the follwing setup Windows Media Player 10 Windows XP 2006 SP2

    Read the article

  • Why can I not add a set accessor to an overriden property?

    - by Svish
    In a base class I have this property: public virtual string Text { get { return text; } } I want to override that and return a different text, but I would also like to be able to set the text, so I did this: public override string Text { get { return differentText; } set { differentText = value; } } This however does not work. I get a red squiggly under set saying that I can not override because it does not have a set accessor. Why is this aproblem? What should I do?

    Read the article

  • Partial specialization with reference template parameter fails to compile in VS2005

    - by Blair Holloway
    I have code that boils down to the following: template struct Foo {}; template & I struct FooBar {}; //////// template struct Baz {}; template & I struct Baz< FooBar { static void func(FooBar& value); }; //////// struct MyStruct { static const Foo s_floatFoo; }; // Elsewhere: const Foo MyStruct::s_floatFoo; void callBaz() { typedef FooBar FloatFooBar; FloatFooBar myFloatFooBar; Baz::func(myFloatFooBar); } This compiles successfully under GCC, however, under VS2005, I get: error C2039: 'func' : is not a member of 'Baz' with [ T=FloatFooBar ] error C3861: 'func': identifier not found However, if I change const Foo<T>& I to const Foo<T>* I (passing I by pointer rather than by reference), and defining FloatFooBar as: typedef FooBar FloatFooBar; Both GCC and VS2005 are happy. What's going on? Is this some kind of subtle template substitution failure that VS2005 is handling differently to GCC, or a compiler bug? (The strangest thing: I thought I had the above code working in VS2005 earlier this morning. But that was before my morning coffee. I'm now not entirely certain I wasn't under some sort of caffeine-craving-induced delirium...)

    Read the article

  • Special characters from MySQL database (e.g. curly apostrophes) are mangling my XML

    - by Toph
    I have a MySQL database of newspaper articles. There's a volume table, an issue table, and an article table. I have a PHP file that generates a property list that is then pulled in and read by an iPhone app. The plist holds each article as a dictionary inside each issue, and each issue as a dictionary inside each volume. The plist doesn't actually hold the whole article -- just a title and URL. Some article titles contain special characters, like curly apostrophes. Looking at the generated XML plist, whenever it hits a special character, it unpredictably gobbles up a whole bunch of text, leaving the XML mangled and unreadable. (...in Chrome, anyway, and I'm guessing on the iPhone. Firefox actually handles it pretty well, showing a white ? in a black diamond in place of any special characters and not gobbling anything.) Example well-formed plist snippet: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Rows</key> <array> <dict> <key>Title</key> <string>Vol. 133 (2003-2004)</string> <key>Children</key> <array> <dict> <key>Title</key> <string>No. 18 (Apr 2, 2004)</string> <key>Children</key> <array> <dict> <key>Title</key> <string>Basketball concludes historic season</string> <key>URL</key> <string>http://orient.bowdoin.edu/orient/article_iphone.php?date=2004-04-02&amp;section=1&amp;id=1</string> </dict> <!-- ... --> </array> </dict> </array> </dict> </array> </dict> </plist> Example of what happens when it hits a curly apostrophe: This is from Chrome. This time it ate 5,998 characters, by MS Word's count, skipping down to midway through the opening the title of a pizza story; if I reload it'll behave differently, eating some other amount. The proper title is: Singer-songwriter Farrell ’05 finds success beyond the bubble <dict> <key>Title</key> <string>Singer-songwriter Farrell ing>Students embrace free pizza, College objects to solicitation</string> <key>URL</key> <string>http://orient.bowdoin.edu/orient/article_iphone.php?date=2009-09-18&amp;section=1&amp;id=9</string> </dict> In MySQL that title is stored as (in binary): 53 69 6E 67 |65 72 2D 73 |6F 6E 67 77 |72 69 74 65 72 20 46 61 |72 72 65 6C |6C 20 C2 92 |30 35 20 66 69 6E 64 73 |20 73 75 63 |63 65 73 73 |20 62 65 79 6F 6E 64 20 |74 68 65 20 |62 75 62 62 |6C Any ideas how I can encode/decode things properly? If not, any idea how I can get around the problem some other way? I don't have a clue what I'm talking about, haha; let me know if there's any way I can help you help me. :) And many thanks!

    Read the article

  • iPhone video screen capture for the 3GS

    - by teabot
    With the advent of the iPhone 3GS' video capability - does anyone know if Apple bundled the ability to capture the device screen as a video? Note: I know this question has already been asked regarding previous handset versions but I am specifically asking about the 3GS where this functionality seems more plausible. Update: until I hear otherwise I am going to have to accept that this is not possible.

    Read the article

  • Can you reverse order a string in one line with LINQ or a LAMBDA expression

    - by Student for Life
    Not that I would want to use this practically (for many reasons) but out of strict curiousity I would like to know if there is a way to reverse order a string using LINQ and/or LAMBDA expressions in one line of code, without utilising any framework "Reverse" methods. e.g. string value = "reverse me"; string reversedValue = (....); and reversedValue will result in "em esrever" EDIT Clearly an impractical problem/solution I know this, so don't worry it's strictly a curiosity question around the LINQ/LAMBDA construct.

    Read the article

  • C#: Is it possible to use expressions or functions as keys in a dictionary?

    - by Svish
    Would it work to use Expression<Func<T>> or Func<T> as keys in a dictionary? For example to cache the result of heavy calculations. For example, changing my very basic cache from a different question of mine a bit: public static class Cache<T> { // Alternatively using Expression<Func<T>> instead private static Dictionary<Func<T>, T> cache; static Cache() { cache = new Dictionary<Func<T>, T>(); } public static T GetResult(Func<T> f) { if (cache.ContainsKey(f)) return cache[f]; return cache[f] = f(); } } Would this even work? Edit: After a quick test, it seems like it actually works. But I discovered that it could probably be more generic, since it would now be one cache per return type... not sure how to change it so that wouldn't happen though... hmm Edit 2: Noo, wait... it actually doesn't. Well, for regular methods it does. But not for lambdas. They get various random method names even if they look the same. Oh well c",)

    Read the article

  • C#: What would you name an IEnumerable class?

    - by Svish
    When reading this question I started to wonder a bit. Say you have these two: class ProductCollection : ICollection<Product> class ProductList : IList<Product> What would you call one that were an IEnumerable<Product>? class Product--- : IEnumerable<Product> Before I read that other question I might have called it a ProductCollection actually, but taking the new info into account, that would have been a bit misleading since it does not implement ICollection<Product>. Could you call it Products? var products = new Products(); // products is/are products Almost works but sounds a bit strange... What would you call it?

    Read the article

  • Performance difference in for loop condition?

    - by CSharperWithJava
    Hello all, I have a simple question that I am posing mostly for my curiousity. What are the differences between these two lines of code? (in C++) for(int i = 0; i < N, N > 0; i++) for(int i = 0; i < N && N > 0; i++) The selection of the conditions is completely arbitrary, I'm just interested in the differences between , and &&. I'm not a beginner to coding by any means, but I've never bothered with the comma operator. Are there performance/behavior differences or is it purely aesthetic? One last note, I know there are bigger performance fish to fry than a conditional operator, but I'm just curious. Indulge me. Edit Thanks for your answers. It turns out the code that prompted this question had misused the comma operator in the way I've described. I wondered what the difference was and why it wasn't a && operator, but it was just written incorrectly. I didn't think anything was wrong with it because it worked just fine. Thanks for straightening me out.

    Read the article

  • Problem determining how to order F# types due to circular references

    - by James Black
    I have some types that extend a common type, and these are my models. I then have DAO types for each model type for CRUD operations. I now have a need for a function that will allow me to find an id given any model type, so I created a new type for some miscellaneous functions. The problem is that I don't know how to order these types. Currently I have models before dao, but I somehow need DAOMisc before CityDAO and CityDAO before DAOMisc, which isn't possible. The simple approach would be to put this function in each DAO, referring to just the types that can come before it, so, State comes before City as State has a foreign key relationship with City, so the miscellaneous function would be very short. But, this just strikes me as wrong, so I am not certain how to best approach this. Here is my miscellaneous type, where BaseType is a common type for all my models. type DAOMisc = member internal self.FindIdByType item = match(item:BaseType) with | :? StateType as i -> let a = (StateDAO()).Retrieve i a.Head.Id | :? CityType as i -> let a = (CityDAO()).Retrieve i a.Head.Id | _ -> -1 Here is one dao type. CommonDAO actually has the code for the CRUD operations, but that is not important here. type CityDAO() = inherit CommonDAO<CityType>("city", ["name"; "state_id"], (fun(reader) -> [ while reader.Read() do let s = new CityType() s.Id <- reader.GetInt32 0 s.Name <- reader.GetString 1 s.StateName <- reader.GetString 3 ]), list.Empty ) This is my model type: type CityType() = inherit BaseType() let mutable name = "" let mutable stateName = "" member this.Name with get() = name and set restnameval=name <- restnameval member this.StateName with get() = stateName and set stateidval=stateName <- stateidval override this.ToSqlValuesList = [this.Name;] override this.ToFKValuesList = [StateType(Name=this.StateName);] The purpose for this FindIdByType function is that I want to find the id for a foreign key relationship, so I can set the value in my model and then have the CRUD functions do the operations with all the correct information. So, City needs the id for the state name, so I would get the state name, put it into the state type, then call this function to get the id for that state, so my city insert will also include the id for the foreign key. This seems to be the best approach, in a very generic way to handle inserts, which is the current problem I am trying to solve.

    Read the article

  • Help! Sikuli unit test can not run

    - by Janet
    Hello, I couldn't run any unit tests either in the window xp? The IDE is functional. I write the simple example unit test script in the editor, as follow: def testHelloWorld(self): print("Hello World!") but no test shows up in the unit test window. When clicking the Run button of the Unit test pane, nothing happens, and the IDE window dissappears, there is no way to get back to it other than restarting the IDE. It had stucked me for several days, that would be preciate if anyone can help me solve this problem! Thank you very much. Janet

    Read the article

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