Daily Archives

Articles indexed Wednesday April 14 2010

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

  • How to implement a category hierarchy using collections

    - by Luke101
    Hello, I have about 200 categories that are nested. I am currently reading the documention on the C5 generics library. I am not sure if the C5 library is overkill or not. I am looking at converting all my custom algorithms to the C5 implemention. This is what I need. If a certain category is chosen i need to find its parents, siblings, direct children, and all children. This is the way I have it set up. To find the: Parents: I start from the current location then loop through the list and find the current parent. When I find the parent I loop through the whole list again to find the next parent and so on. Siblings: I loop through the whole list and find all the nodes that have the same parent as the choosen node. direct children: I loop through the whole list and find all nodes that is a parent of the choosen node. All Children: This one took me a while to figure out. But I used recursion to find all children of the choosen node. Is there a better way to implement something like this?

    Read the article

  • Why does my token return NULL and how can I fix it?(c++)

    - by Van
    I've created a program to get a string input from a user and parse it into tokens and move a robot according to the input. The program is supposed to recognize these inputs(where x is an integer): "forward x" "back x" "turn left x" "turn right x" and "stop". The program does what it's supposed to for all commands except for "stop". When I type "stop" the program prints out "whats happening?" because I've written a line which states: if(token == NULL) { cout << "whats happening?" << endl; } Why does token get NULL, and how can I fix this so it will read "stop" properly? here is the code: bool stopper = 0; void Navigator::manualDrive() { VideoStream video(&myRobot, 0);//allows user to see what robot sees video.startStream(); const int bufSize = 42; char uinput[bufSize]; char delim[] = " "; char *token; while(stopper == 0) { cout << "Enter your directions below: " << endl; cin.getline(uinput,bufSize); Navigator::parseInstruction(uinput); } } /* parseInstruction(char *c) -- parses cstring instructions received * and moves robot accordingly */ void Navigator::parseInstruction(char * uinput) { char delim[] = " "; char *token; // cout << "Enter your directions below: " << endl; // cin.getline (uinput, bufSize); token=strtok(uinput, delim); if(token == NULL) { cout << "whats happening?" << endl; } if(strcmp("forward", token) == 0) { int inches; token = strtok(NULL, delim); inches = atoi (token); double value = fabs(0.0735 * fabs(inches) - 0.0550); myRobot.forward(1, value); } else if(strcmp("back",token) == 0) { int inches; token = strtok(NULL, delim); inches = atoi (token); double value = fabs(0.0735 * fabs(inches) - 0.0550); myRobot.backward(1/*speed*/, value/*time*/); } else if(strcmp("turn",token) == 0) { int degrees; token = strtok(NULL, delim); if(strcmp("left",token) == 0) { token = strtok(uinput, delim); degrees = atoi (token); double value = fabs(0.00467 * degrees - 0.04); myRobot.turnLeft(1/*speed*/, value/*time*/); } else if(strcmp("right",token) == 0) { token = strtok(uinput, delim); degrees = atoi (token); double value = fabs(0.00467 * degrees - 0.04); myRobot.turnRight(1/*speed*/, value/*time*/); } } else if(strcmp("stop",token) == 0) { stopper = 1; } else { std::cerr << "Unknown command '" << token << "'\n"; } } /* autoDrive() -- reads in file from ifstream, parses * and moves robot according to instructions in file */ void Navigator::autoDrive(string filename) { const int bufSize = 42; char fLine[bufSize]; ifstream infile; infile.open("autodrive.txt", fstream::in); while (!infile.eof()) { infile.getline(fLine, bufSize); Navigator::parseInstruction(fLine); } infile.close(); } I need this to break out of the while loop and end manualDrive because in my driver program the next function called is autoDrive.

    Read the article

  • Reduce lines of code

    - by coffeeaddict
    I'm not a JavaScript guru (yet). I am trying to figure out a way to cut down the number of lines below...are there any shortcuts for lets say the if statements? function showDialog(divID) { var dialogDiv = $("#" + divID); var height = 500; var width = 400; var resizable = false; if (dialogDiv.attr("height") != "") { height = parseInt(dialogDiv.attr("height")); } if (dialogDiv.attr("width") != "") { width = parseInt(dialogDiv.attr("width")); } if (dialogDiv.attr("resizable") != "") { resizable = dialogDiv.attr("resizable"); } dialogDiv.dialog ( { resizable: resizable, width: width, height: height, bgiframe: true, modal: true, autoOpen: false, show: 'blind' } ) dialogDiv.dialog("open"); }

    Read the article

  • WPF RichTextBox with no width set

    - by Mick
    I have the following XAML code: <Window x:Class="RichText_Wrapping.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1"> <Grid> <RichTextBox Height="100" Margin="2" Name="richTextBox1"> <FlowDocument> <Paragraph> This is a RichTextBox - if you don't specify a width, the text appears in a single column </Paragraph> </FlowDocument> </RichTextBox> </Grid> ... If you create this window in XAML, you can see that when you don't specify a width for the window, it wraps the text in a single column, one letter at a time. Is there something I'm missing? If it's a known deficiency in the control, is there any workaround? Thanks, Michael

    Read the article

  • Ant trouble with environment variables on Ubuntu

    - by Inaimathi
    Having some trouble with with ant reading environment variables in Ubuntu 9.10. Specifically, the build tasks my company uses has a token like ${env.CATALINA_HOME] in the main build.xml. I set CATALINA_HOME to the correct value in /etc/environment, ~/.pam_environment and (just to be safe) my .bashrc. I can see the correct value when I run printenv from bash, or when I eval (getenv "CATALINA_HOME") in emacs. Ant refuses to build to the correct directory though; instead I get a folder named ${env.CATALINA_HOME} in the same directory as my build.xml. Any idea what's happening there, and/or how to fix it?

    Read the article

  • android spinning image

    - by user270811
    hi, i am trying to create two spinning wheels, as in pulleys, so everytime the attached rope moves, the two pulleys will rotate. i have tried two approaches: 1) use Matrix.postRotate within the onDraw() method of the View class, which calls the following: private void drawSpinningWheel(Canvas canvas) { try { canvas.save(); Bitmap bitmapOrg = null; int iDrawable = R.drawable.spinning_button; bitmapOrg = BitmapFactory.decodeResource(getResources(), iDrawable); if(bitmapOrg != null) { int width = bitmapOrg.getWidth(); int height = bitmapOrg.getHeight(); int newWidth = 24; int newHeight = 24; // calculate the scale - in this case = 0.4f float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // createa matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); matrix.postRotate((float) mDegrees++); Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true); canvas.drawBitmap(resizedBitmap, matrix, null); } canvas.restore(); } catch(Exception e) { Log.e(TAG + "drawSpinningWheel", e.getMessage()); } } but it seems like the image not only spins but rotates around another axis 2) use SurfaceView and a separate thread, in the run() call this: private void doDraw(Canvas canvas) { // Draw the background image. Operations on the Canvas accumulate // so this is like clearing the screen. canvas.drawBitmap(mBackgroundImage, 0, 0, null); int yTop = mCanvasHeight - ((int) mY + mSpinningWheelImageHeight / 2); int xLeft = (int) mX - mSpinningWheelImageWidth / 2; ... // Draw the ship with its current rotation canvas.save(); canvas.rotate((float) mHeading++, (float) mX, mCanvasHeight - (float) mY); mSpinningWheelImage.setBounds(xLeft, yTop, xLeft + mSpinningWheelImageWidth, yTop + mSpinningWheelImageHeight); mSpinningWheelImage.draw(canvas); canvas.restore(); } i get the spinning to work but i can't add another spinning wheel. i even tried to create another thread for the second spinning wheel, only one shows up. can someone point me in the right direction? thanks.

    Read the article

  • stored procedure vs UDF

    - by TheObserver
    I have a select statement and in a couple of the fields, I want to check if an entry for the record exists in another table and if it does, output 1 value and if it doesn't, provide another value. What would be the best way to do it? When would you use a stored procedure and when would you use a UDF?

    Read the article

  • My Favorite New Features in Visual Studio 2010

    On Tuesday, April 13th, Microsoft released Visual Studio 2010 and the .NET Framework 4.0 (which includes ASP.NET 4.0). To get started with Visual Studio 2010 you can either download a trial version of one of the commercial editions or you can go grab the free Visual Web Developer 2010 Express Edition. The Visual Studio 2010 user experience is noticeably different than with previous versions. Some of the changes are cosmetic - gone is the decades-old red and orange color scheme, having been replaced with blues and purples - while others are more substantial. For instance, the Visual Studio 2010 shell was rewritten from the ground up to use Microsoft's Windows Presentation Foundation (WPF). In addition to an updated user experience, Visual Studio introduces an array of new features designed to improve developer productivity. There are new tools for searching for files, types, and class members; it's now easier than ever to use IntelliSense; the Toolbox can be searched using the keyboard; and you can use a single editor - Visual Studio 2010 - to work on . This article explores some of the new features in Visual Studio 2010. It is not meant to be an exhaustive list, but rather highlights those features that I, as an ASP.NET developer, find most useful in my line of work. Read on to learn more! Read More >Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Microsoft Updates Service Pack Support Policy

    Microsoft announced a slight revision on Tuesday to its end-of-support policy for software service packs....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • It's Here! Visual Studio 2010 and ASP.NET 4.0 Ship

    Today Microsoft released Visual Studio 2010 and ASP.NET 4.0. I've been using the RC version of Visual Studio 2010 quite a bit for the past couple of months and have really grown to like it. It has a host of features and enhancements that improve developer productivity, from improved IntelliSense to better multiple monitor support. Plus there's something about the user experience that, to me, makes it feel better than Visual Studio 2008. I don't know if it's the new blue color motif or what, but the IDE seems more modern looking and more responsive to my mouse movements and other input. Anyway, if you've not yet downloaded Visual Studio 2010 and ASP.NET 4.0, why not? As with previous versions of Visual Studio there's a free Express Edition and VS2010 and ASP.NET 4.0 runs side-by-side with earlier versions of Visual Studio and ASP.NET. And with Visual Studio 2010's multi-targeting you can even use VS2010 as your development editor for ASP.NET 2.0 and ASP.NET 3.5 web applications. (Although be forewarned if you have multiple developers working on the application that the project files in VS2010 and earlier versions of Visual Studio differ.) This week's article on 4Guys explores my favorite new features of Visual Studio 2010. Here's an excerpt: The Visual Studio 2010 user experience is noticeably different than with previous versions. Some of the changes are cosmetic - gone is the decades-old red and orange color scheme, having been replaced with blues and purples - while others are more substantial. For instance, the Visual Studio 2010 shell was rewritten from the ground up to use Microsoft's Windows Presentation Foundation (WPF). In addition to an updated user experience, Visual Studio introduces an array of new features designed to improve developer productivity. There are new tools for searching for files, types, and class members; it's now easier than ever to use IntelliSense; the Toolbox can be searched using the keyboard; and you can use a single editor - Visual Studio 2010 - to work on. This article explores some of the new features in Visual Studio 2010. It is not meant to be an exhaustive list, but rather highlights those features that I, as an ASP.NET developer, find most useful in my line of work. Read on to learn more! And, in closing, here are some helpful VS2010 and ASP.NET 4.0 links: One click installation for ASP.NET 4.0, Visual Web Developer 2010, .NET Framework 4.0, and ASP.NET MVC 2 Eight Quick Hit videos showing some of the cool new VS2010 features VS2010 and ASP.NET 4.0 Release Announcement with some great info/links from none other than Scott Guthrie Happy Programming!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Buying used windows license. How can I tell if they are still active?

    - by muhan
    I want to buy used copies of Windows Full Retail Version, (XP, Vista, 7) so we can install our PC application on customers Macs using something like Vmware fusion. If we do buy these licenses, how can we tell they are legit and not being used anymore? Will it tell us when we try to activate them? Are we liable if they are being used at the same time as the original owner? Any other pitfalls to this strategy? Thanks in advance.

    Read the article

  • How to rip dvd and arrange files

    - by user23950
    I'm ripping a dvd with dvd shrink. There are lots of anime episodes on it. And when I open those .vob files it seems that the episodes are not arranged in one .vob file. Because 1 .vob file has multiple episodes but they are not arranged as ep 1, ep 2, ep 3, etc. Is it possible to edit those files so that the episodes would be arranged

    Read the article

  • OS X home, end, page up, page down movement keys and cursor focus

    - by Gerald Kaszuba
    When using the home, end, page up and page down movement keys in a text editor, the cursor stays in the same spot, even though the window has moved elsewhere. I know that you can use the option modifier to move the cursor along, but is there a way to move the cursor where your window has moved to (without using the mouse)? Another alternative would be to make these movement keys always behave as if the option modifier key is already pressed. Is this possible?

    Read the article

  • Sorting By Multiple Conditions in Ruby

    - by viatropos
    I have a collection of Post objects and I want to be able to sort them based on these conditions: First, by category (news, events, labs, portfolio, etc.) Then by date, if date, or by position, if a specific index was set for it Some posts will have dates (news and events), others will have explicit positions (labs, and portfolio). I want to be able to call posts.sort!, so I've overridden <=>, but am looking for the most effective way of sorting by these conditions. Below is a pseudo method: def <=>(other) # first, everything is sorted into # smaller chunks by category self.category <=> other.category # then, per category, by date or position if self.date and other.date self.date <=> other.date else self.position <=> other.position end end It seems like I'd have to actually sort two separate times, rather than cramming everything into that one method. Something like sort_by_category, then sort!. What is the most ruby way to do this?

    Read the article

  • Parsing unicode XML with Python SAX on App Engine

    - by Derek Dahmer
    I'm using xml.sax with unicode strings of XML as input, originally entered in from a web form. On my local machine (python 2.5, using the default xmlreader expat, running through app engine), it works fine. However, the exact same code and input strings on production app engine servers fail with "not well-formed". For example, it happens with the code below: from xml import sax class MyHandler(sax.ContentHandler): pass handler = MyHandler() # Both of these unicode strings return 'not well-formed' # on app engine, but work locally xml.parseString(u"<a>b</a>",handler) xml.parseString(u"<!DOCTYPE a[<!ELEMENT a (#PCDATA)> ]><a>b</a>",handler) # Both of these work, but output unicode xml.parseString("<a>b</a>",handler) xml.parseString("<!DOCTYPE a[<!ELEMENT a (#PCDATA)> ]><a>b</a>",handler) resulting in the error: File "<string>", line 1, in <module> File "/base/python_dist/lib/python2.5/xml/sax/__init__.py", line 49, in parseString parser.parse(inpsrc) File "/base/python_dist/lib/python2.5/xml/sax/expatreader.py", line 107, in parse xmlreader.IncrementalParser.parse(self, source) File "/base/python_dist/lib/python2.5/xml/sax/xmlreader.py", line 123, in parse self.feed(buffer) File "/base/python_dist/lib/python2.5/xml/sax/expatreader.py", line 211, in feed self._err_handler.fatalError(exc) File "/base/python_dist/lib/python2.5/xml/sax/handler.py", line 38, in fatalError raise exception SAXParseException: <unknown>:1:1: not well-formed (invalid token) Any reason why app engine's parser, which also uses python2.5 and expat, would fail when inputting unicode?

    Read the article

  • What does the question mark at then end of a css include url do?

    - by Bob Dylan
    I've noticed that on some websites (including SO) the link to the CSS will look like: <link rel="stylesheet" href="http://sstatic.net/so/all.css?v=6638"> I would say its safe to assume that ?v=6638 tells the browser to load version 6638 of the css file. But can I do this on my websites and can I include different versions of my CSS file just by changing the numbers?

    Read the article

  • Clear cache with greasemonkey

    - by Paul
    I have a web application running in a kiosk, which is set up with greasemonkey so that we can customize little things about the application and ensure the customizations only occur at the kiosk. I have been digging through the GM api hoping that it would have some functionality to affect browser settings, but alas it looks like it only affects pages running in the browser. Is there a way for me to tell the browser to clear it's cache when a certain event happens in the application?

    Read the article

  • How to use LIKE query in sqlite & iPhone

    - by 4thSpace
    I'm using the following for a LIKE query. Is this technique for LIKE correct? selectstmtSearch = nil; if(selectstmtSearch == nil){ const char *sql = "SELECT col1, col2 FROM table1 t1 JOIN table2 t2 ON t1.cityid = t2.cityid where t1.cityname like ?001 order by t1.cityname"; if(sqlite3_prepare_v2(databaseSearch, sql, -1, &selectstmtSearch, NULL) == SQLITE_OK) { sqlite3_bind_text(selectstmtSearch, 1, [[NSString stringWithFormat:@"%%%@%%", searchText] UTF8String], -1, SQLITE_TRANSIENT); } } The problem I'm having is after a few uses of this, I get an error 14 on sqlite3_open(), which is unable to open database. If I replace the LIKE with something such as: SELECT col1, col2 FROM table1 t1 JOIN table2 t2 ON t1.cityid = t2.cityid where t1.cityname = ? order by t1.cityname It works fine. I do open/close the DB before after the above code. Is there a way to troubleshoot exactly why the database can't be opened and what its relationship to my LIKE syntax is?

    Read the article

  • Base class for windows service

    - by user187020
    My new project has a design in which there are number windows services for performing different tasks. I have been given a task to create base class from which all of the windows service will inherit. This base class will perform common functions like creating instances of other windows services by iterating through the config file (may be like Activator.CreateInstance), do event logging on onStart, onStop etc. and may contain some more functionality. Before I start developing stuff, wondering if there is any pattern already in place or someone has good understanding of how to implement this kind of functionality. Any help appreciated.

    Read the article

  • Zend framework on shared hosting

    - by Stefano
    I have a problem. I'm trying to deploy my zend framework app on a shared hosting. In local, with xampp was everything ok, but on shared hosting I received the following message: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /application/public/index.php on line 40. The line 40 is: $application-bootstrap()-run();. Any idea?

    Read the article

  • Enter Password in C

    - by Mohit Deshpande
    I am aware that it is not possible to echo the * while you type in standard ANSI C. But is there a way to display nothing while someone is typing their password in the console. What I mean is like the sudo prompts in a Unix/Linux terminal. Like if you type in the command: sudo cp /etc/somefile ~/somedir. You are usually prompted for the root password. And while you type it in, the terminal displays nothing. Is this effect possible in C? If it is, how?

    Read the article

  • How to change url field of Web Proxy portlet dynamically

    - by hura
    Hello, I'm using Liferay 5.2 portal. I have 2 Web Proxy portlet in my portal. Web Proxy portlet 1 contains navigation items & Web Proxy portlet 2 contains content. When user click an item in portlet 1 then the content in portlet 2 will change, it also mean that the url for portlet 2 changes. How can I do that? Or is there any other way to do the action as I describe? Thx all!

    Read the article

  • "Wrapping" a BindingList<T> propertry with a List<T> property for serialization.

    - by Eric
    I'm writing an app that allows users search and browse catalogs of widgets. My WidgetCatalog class is serialized and deserialized to and from XML files using DataContractSerializer. My app is working now but I think I can make the code a lot more efficient if I started taking advantage of data binding rather then doing everything manually. Here's a stripped down version of my current WidgetCatalog class. [DataContract(Name = "WidgetCatalog")] class WidgetCatalog { [DataContract(Name = "Name")] public string Name { get; set; } [DataContract(Name = "Widgets")] public List<Widget> Widgets { get; set; } } I had to write a lot of extra code to keep my UI in sync when widgets are added or removed from a catalog, or their internal properties change. I'm pretty inexperienced with data-binding, but I think I want a BindingList<Widget> rather than a plain old List<Widget>. Is this right? In the past when I had similar needs I found that BindingList<T> does not serialize very well. Or at least the Event Handers between the items and the list are not serialized. I was using XmlSerializer though, and DataContractSerializer may work better. So I'm thinking of doing something like the code below. [DataContract(Name = "WidgetCatalog")] class WidgetCatalog { [DataMember(Name = "Name")] public string Name { get; set; } [DataMember(Name = "Widgets")] private List<Widget> WidgetSerializationList { get { return this._widgetBindingList.ToList<Widget>(); } set { this._widgetBindingList = new BindingList<Widget>(value); } } //these do not get serialized private BindingList<Widget> _widgetBindingList; public BindingList<Widget> WidgetBindingList { get { return this._widgetBindingList; } } public WidgetCatalog() { this.WidgetSerializationList = new List<Widget>(); } } So I'm serializing a private List<Widget> property, but the GET and SET accessors of the property are reading from, and writing to theBindingList<Widget> property. Will this even work? It seems like there should be a better way to do this.

    Read the article

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