Daily Archives

Articles indexed Tuesday May 11 2010

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

  • RelayCommand sender from ItemsControl item

    - by Padu Merloti
    I've been using MVVM's RelayCommand with success to bind actions to XAML, but I'm having a small problem with my ItemsControl. <ItemsControl ItemsSource="{Binding Devices}" > <ItemsControl.ItemTemplate> <DataTemplate> <Grid Width="100" Margin="4" > <Button Command="{Binding Path=SelectDeviceCommand}" > <Grid> <Image Source="img_small.png"></Image> <Image Source="{Binding Path=Logo}" /> </Grid> </Button> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> In my view model: public RelayCommand SelectDeviceCommand { get; set; } private ObservableCollection<Device> Devices; Devices = CreateListOfDevices(); private void InitializeCommands() { SelectDeviceCommand = new RelayCommand((s) => MessageBox.Show(s.ToString())); } How do I define my SelectDeviceCommand in my view model in order to receive object that is bound to that item? My SelectDeviceCommand is not even being called... (but that I guess is because I need to make my Device a mini-viewmodel and implement the SelectDeviceCommand in it, is that correct?)

    Read the article

  • How to perform undirected graph processing from SQL data

    - by recipriversexclusion
    I ran into the following problem in dynamically creating topics for our ActiveMQ system: I have a number of processes (M_1, ..., M_n), where n is not large, typically 5-10. Some of the processes will listen to the output of others, through a message queue; these edges are specified in an XML file, e.g. <link from="M1" to="M3"</link> <link from="M2" to="M4"</link> <link from="M3" to="M4"</link> etc. The edges are sparse, so there won't be many of them. I will parse this XML and store this information in an SQL DB, one table for nodes and another for edges. Now, I need to dynamically create strings of the form M1.exe --output_topic=T1 M2.exe --output_topic=T2 M3.exe --input_topic=T1 --output_topic=T3 M4.exe --input_topic=T2 --input_topic=T3 where the tags are sequentially generated. What is the best way to go about querying SQL to obtain these relationships? Are there any tools or other tutorials you can point me to? I've never done graps with SQL. Using SQL is imperative, because we use it for other stuff, too. Thanks!

    Read the article

  • what does driver program mean?

    - by Tom
    there is a quote from Algorithms for Java (sedgwick 2003) p. 135: "we commonly use driver programs when developing or debugging adt iplementations" what is meant by driver program? google just gives me loads of info about programming drivers, clearly not related

    Read the article

  • What are Class methods in Python for?

    - by Dave Webb
    I'm teaching myself Python and my most recent lesson was that Python is not Java, and so I've just spent a while turning all my Class methods into functions. I now realise that I don't need to use Class methods for what I would done with static methods in Java, but now I'm not sure when I would use them. All the advice I can find about Python Class methods is along the lines of newbies like me should steer clear of them, and the standard documentation is at its most opaque when discussing them. Does anyone have a good example of using a Class method in Python or at least can someone tell me when Class methods can be sensibly used?

    Read the article

  • While loop: Output something different on every second result

    - by Wade D Ouellet
    Hi, I am running a plugin called Category Posts Widget for WordPress: http://wordpress.org/extend/plugins/category-posts/ It uses a while loop to display the names of all posts in a certain category. I want to get it so that there is a different class attached to the li tag on every second output. Here is the block of code for the plugin: // Post list echo "<ul>\n"; while ( $cat_posts->have_posts() ) { $cat_posts->the_post(); ?> <li class="cat-post-item"> <a class="post-title" href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && $instance["thumb"] && has_post_thumbnail() ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail( 'cat_post_thumb_size'.$this->id ); ?> </a> <?php endif; ?> <?php if ( $instance['date'] ) : ?> <p class="post-date"><?php the_time("j M Y"); ?></p> <?php endif; ?> <?php if ( $instance['excerpt'] ) : ?> <?php the_excerpt(); ?> <?php endif; ?> <?php if ( $instance['comment_num'] ) : ?> <p class="comment-num">(<?php comments_number(); ?>)</p> <?php endif; ?> </li> <?php } echo "</ul>\n"; I am just trying to get it so on each second one in the output list, the li has a different class, so cat-post-item-alt for example. Thanks, Wade

    Read the article

  • Auto mapping a IDictionary<string, myclass> with fluent nhibernate

    - by Marcus
    I have a simple class that looks like this: public class Item { // some properties public virtual IDictionary<string, Detail> Details { get; private set; } } and then I have a map that looks like this: map.HasMany(x => x.Details).AsMap<string>("Name").AsIndexedCollection<string>("Name", c => c.GetIndexMapping()).Cascade.All().KeyColumn("Item_Id")) with this map I get the following error and I don't know how to solve it? The type or method has 2 generic parameter(s), but 1 generic argument(s) were provided. A generic argument must be provided for each generic parameter.

    Read the article

  • Problem when get pageContent of URL in java ?

    - by tiendv
    Hi all ! i have a code for get pagecontent from a URL here is code ! import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class GetPageFromURLAction extends Thread { public String stringPageContent; public String targerURL; public String getPageContent(String targetURL) throws IOException { String returnString=""; URL urlString = new URL(targetURL); URLConnection openConnection = urlString.openConnection(); String temp; BufferedReader in = new BufferedReader(new InputStreamReader(openConnection.getInputStream())); while ((temp = in.readLine()) != null) { returnString += temp + "\n"; } in.close(); // String nohtml = sb.toString().replaceAll("\\<.*?>",""); return returnString; } public String getStringPageContent() { return stringPageContent; } public void setStringPageContent(String stringPageContent) { this.stringPageContent = stringPageContent; } public String getTargerURL() { return targerURL; } public void setTargerURL(String targerURL) { this.targerURL = targerURL; } @Override public void run() { try { this.stringPageContent=this.getPageContent(targerURL); } catch (IOException e) { e.printStackTrace(); } } } The problem is : 1 Some time i receive a error lik 405 ,or 403 HTTP error ... and result string is null . To repair i check permission to connect URL but it usualy return null URLConnection openConnection = urlString.openConnection(); openConnection.getPermission( ) is mean that i don't have permission to acess link ? To get resultString without HTML Tag ? i do like that String nohtml = sb.toString().replaceAll("\<.*?",""); Para sb is Stringbulder , but it can't remove all HTML Tab in string return ? I use thread here because i must get page alot of url , so how can i cread a multi thread to impro speed of program ! Thanks

    Read the article

  • Vague MVC and Castle Windsor question. Sorry...

    - by Matt W
    I have inheritted some code in which the MVC Controller classes all get their constructors called by Castle....DefaultProxyFactory.Create() somewhere along the line (the call stack drops out to the , which isn't helping.) So, basically, how would I go about finding out where Castle is being told how to call the constructors of my Controllers? I am very new to Castle, Windsor and MicroKernel, etc, and not a master of ASP's MVC. Many thanks for any pointers - sorry about the vagueness, Matt.

    Read the article

  • SQL Server Backup modes, and a huge log file

    - by Matt Dawdy
    Okay, I'm not a server administrator, a network guy, or a DBA. I'm merely a programmer helping out a small company. They have IT guy who isn't MS centric (most stuff is on Mac) and he and I are trying to figure out a solution here. We've got 1 main database. We run nightly full backups. I know they are full backups because I can take the latest file, or any of the daily backups, and go to a completely new machine and "restore" the backup to an empty database and our app runs perfectly fine off of this backup. The backups have grown from 60 MB to 250MB over 4 months. When running, then log file is 1.7 GB, and the data file is only 200-300 MB. Yes, recovery model is set to full. So, my question, after all of that, if we are keeping daily backups, and we don't have the need / aren't smart enough to roll the DB back to a certain time, if I change the recovery mode to simple, am I really losing anything? And, if I do change it to simple, will it completely dump the log file or at least reduce it way the hell down? And, will that make our database run faster? I know that it'll make my life easier when I copy a relatively recent backup to my local machine to do development and testing...

    Read the article

  • Problem when getting pageContent of an unavailable URL in Java

    - by tiendv
    I have a code for get pagecontent from a URL: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class GetPageFromURLAction extends Thread { public String stringPageContent; public String targerURL; public String getPageContent(String targetURL) throws IOException { String returnString=""; URL urlString = new URL(targetURL); URLConnection openConnection = urlString.openConnection(); String temp; BufferedReader in = new BufferedReader( newInputStreamReader(openConnection.getInputStream())); while ((temp = in.readLine()) != null) { returnString += temp + "\n"; } in.close(); // String nohtml = sb.toString().replaceAll("\\<.*?>",""); return returnString; } public String getStringPageContent() { return stringPageContent; } public void setStringPageContent(String stringPageContent) { this.stringPageContent = stringPageContent; } public String getTargerURL() { return targerURL; } public void setTargerURL(String targerURL) { this.targerURL = targerURL; } @Override public void run() { try { this.stringPageContent=this.getPageContent(targerURL); } catch (IOException e) { e.printStackTrace(); } } } Sometimes I receive an HTTP error of 405 or 403 and result string is null. I have tried checking permission to connect to the URL with: URLConnection openConnection = urlString.openConnection(); openConnection.getPermission() but it usualy returns null. Does mean that i don't have permission to access the link? I have tried stripping off the query portion of the URL with: String nohtml = sb.toString().replaceAll("\\<.*?>",""); where sb is a Stringbulder, but it doesn't seem to strip off the whole query substring. In an unrelated question, I'd like to use threads here because I must retrieve many URLs; how can I create a multi-thread client to improve the speed?

    Read the article

  • ActionScript 3 class over several files - how?

    - by Poni
    So, how do we write a class over several files in action script 3? In C# there's the "partial" keyword. In C++ it's natural (you just "#include ..." all files). In Flex 3, in a component, you add this tag: <mx:Script source="myfile.as"/>. How do I split the following class into several files; package package_path { public class cSplitMeClass { public function cSplitMeClass() { } public function doX():void { // .... } public function doY():void { // .... } } } For example I want to have the doX() and doY() functions implemented in another ".as" file. Can I do this? And please, don't tell me something like "a good practice is to have them in one file" :)

    Read the article

  • Marshaling and Unmarshaling of kml codes for Google Earth

    - by Kayson
    May i inquire more knowledge on marshaling and unmarshaling of kml codes? Regarding those used in Google earth. I need to do a project on flight airlines, linking them with an arc which is a polygon to connect placemarks with placemarks. I've tried to compile sample codes of HelloKML but still unable to marshal and produce the kml codes itself. Please someone explain marshaling and unmarshaling of codes and producing of kml codes. Thanks in advance.

    Read the article

  • How do you parse with SAX using Attributes & Values to a URL path using iPhone SDK?

    - by Jim
    I'm trying to get my head around parsing with SAX and thought a good place to start was the TopSongs example found at the iPhone Dev Center. I get most of it but when it comes to reaching Attributes and Values within a node I can't find a good example anywhere. The XML has a path to a URL for the coverArt. And the XML node looks like this. <itms:coverArt height="60" width="60">http://a1.phobos.apple.com/us/r1000/026/Music/aa/aa/27/mzi.pbxnbfvw.60x60-50.jpg</itms:coverArt> What I've tried is this for the startElement… ((prefix != NULL && !strncmp((const char *)prefix, kName_Itms, kLength_Itms)) && (!strncmp((const char *)localname, kName_CoverArt, kLength_Item) && !strncmp((const char *)attributes, kAttributeName_CoverArt, kAttributeLength_CoverArt) && !strncmp((const char *)attributes, kValueName_CoverArt, kValueLength_CoverArt) || !strncmp((const char *)localname, kName_Artist, kLength_Artist) || and picking it up again with just the localname at the end like this. if (!strncmp((const char *)localname, kName_CoverArt, kLength_CoverArt)) { importer.currentSong.coverArt = [NSURL URLWithString:importer.currentString]; The trace is -[Song setCoverArt:]: unrecognized selector sent to instance.

    Read the article

  • postmessage for directinput

    - by kevin
    can someone PLEASE point me in the right direction all i want to do is simulate a mouse click in a video game that is minimized the video game i am doing this for allows macroing like this, so its all good however, the game uses directinput so using postmessage and sendmessage is not working

    Read the article

  • jQuery - Change background of input field if text getting replaced

    - by ywickham
    I'm currently using jQuery to restrict a text box to number only input as follows: $('input.numbersOnly').keyup(function () { this.value = this.value.replace(/[^0-9\.]/g,''); }); I'd like to let the user know that what they are typing is being rejected by changing the background color of the field. I know that I can change the background of a field using something like this: $('input.numbersOnly').addClass('alertClass'); My question is, how do I combine the two code examples above so that the color of the field changes as the character is getting replaced? My goal is to alert the user that something is wrong with their input as they type it in the field. Thanks!

    Read the article

  • Controling virtualbox internet access?

    - by HandyGandy
    I am finally going through the process of moving my XP into a vbox (host linux). The thing is that I am migrating a virtually clean install. So aside from the occasional antivirus scan, I want to make sure that my XP is not sending malware data (keystoke.logs, spam etc. ) out silently ( and thus having picked up some virus ). To that end I want to limit XP to contacting my LAN and a few internet sites. ( mainly sites that require proprietary windows only software to access, AV sites and Windows update ). I want XP to only access preapproved addresses. If it is trying to contact a nonapproved address, I want it somehow logged and access restricted until I allow access. I also don't want to have to decide whether to allow access to a site at my leisure. To keeps things clear let me give an example: I start my vbox/XP ( which I call MYXP) running on my linux box ( called MYLINUX connecting to the net through a linksys wrt54g ) and connects via samba to my LAN ( since my LAN seems to be possessed of every evil thing, it's address is 192.168.666. ). At the moment my configuration is set so that I allow MYXP to access 192.168.666 and www.MYANTIVIRUS_UPDATES.com and www.MS_UPDATES.com. Then on the VM I start a program which tries to make a connection to www.playmygame.com . www.playmygame.com is on my preapproved list so the connection goes through. Later I check attempted accesses and discover that it also tried to connect to www.mygame_high_scores.com I figure this is OK so I add www.mygame_high_scores.com to my approved list. Later, I again check address and discover that my VM/XP tried to access www.mygame_steals_your_identity.com. I do some checking and discover the address is registered to someone in Kiev, Nigeria. Since this doesn't sound kosher to me, I replace the MYXP VM with one that was backed up before I installed mygame. I remove www.playmygame.com and www.mygame_high_scores.com from my access list for MYXP. It should acomplish this with little overheard. When I am not running the VM ideally it should not have any overhead. Suggestions?

    Read the article

  • 256 color terminal library for Ruby?

    - by brianegge
    Is there a gem like 'Term::ANSIColor' which works with 256 color terminals? The perl script 256colors2.pl works great in my terminal, and I'd like to use some of these colors in my ruby scripts without manually inserting the ANSI codes.

    Read the article

  • ANTLR: using stringTemplate

    - by Kevin Won
    (I'm a Noob with Antlr)... I'm having difficulties getting my grammar with StringTemplates. Basically I'm trying to write a little DSL. I can get my grammar the way I want (it parses correctly), but I can't get the generation of the target code to work with templates. So here's a snippet of my grammar: grammar Pfig; options { output=template; language=CSharp2; } conf : globalName ; globalName : 'GlobalName:' ID -> localConf(name ={$ID.text}) ; I simplified it quite a bit just to get the essence across. Basically, when the lex/parse comes across `GlobalName: Foo' I want it to spit out text based on the StringTemplate called 'localConf'. Super straightforward. So now, let's fire up the parser in a test app and have it process an input file. // C# processing a file with the lex/parser. // the 'app.pfig' file just has one line that reads 'GlobalName: Bla' using (FileStream fs = File.OpenRead("c:\\app.pfig")) { PfigParser parser = new PfigParser(new CommonTokenStream( new PfigLexer(new ANTLRInputStream(fs)))); using (TextReader tr = File.OpenText("./Pfig.stg")) { parser.TemplateLib = new StringTemplateGroup(tr); } var parseResult = parser.conf(); string code = parseResult.Template.ToString(); // Fail: template is null } I can step through the parser code and see that it correctly identifies my text and applies the stringTemplate correctly. The problem is that since this 'globalName' rule is a subrule of 'conf' it doesn't get executed directly--the method just finds it and returns. But the calling 'Conf' method does not keep the return value from the subrule--it goes to thin air. This means that my resultant template on the last line is null. If I get rid of the 'conf' rule in my grammar and call 'globalName' directly, it will work (since it's the only rule on the stack). But I obviously want more than one rule. I've generated the parser in Java and it does the same thing: // antlr generated parser code public PfigParser.conf_return conf() // throws RecognitionException [1] { PfigParser.conf_return retval = new PfigParser.conf_return(); try { { PushFollow(FOLLOW_globalName_in_conf30); globalName(); // <- it calls globalName() but doesn't keep the return. state.followingStackPointer--; } retval.Stop = input.LT(-1); } // snip It's simple to see I don't get some basic concept with how the Template approach is supposed to work with Antlr. I'm quite sure this is my problem but I'm a loggerheads to know what I'm doing wrong... the examples I've seen don't really show real-world template emission of code.

    Read the article

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