Daily Archives

Articles indexed Friday April 9 2010

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

  • Combining lists but getting unique members

    - by MC
    I have a bit of a special requirement when combining lists. I will try to illustrate with an example. Lets say I'm working with 2 lists of GamePlayer objects. GamePlayer has a property called LastGamePlayed. A unique GamePlayer is identified through the GamePlayer.ID property. Now I'd like to combine listA and listB into one list, and if a given player is present in both lists I'd like to keep the value from listA. I can't just combine the lists and use a comparer because my uniqueness is based on ID, and if my comparer checks ID I will not have control over whether it picks the element of listA or listB. I need something like: for each player in listB { if not listA.Contains(player) { listFinal.Add(player) } } However, is there a more optimal way to do this instead of searching listA for each element in listB?

    Read the article

  • MVVM and Ribbon Command

    - by user312372
    I am trying to change the source property of the frame in Page1.xaml when the SampleCommand is excecuted. How do I acheive this in the View Model? Page1.xaml: <r:RibbonTab.Groups> <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}"> <r:RibbonGroup.Command> <r:RibbonCommand LabelTitle="RibbonButton"/> </r:RibbonGroup.Command> <r:RibbonButton x:Name="RibbonButton1" Command="{Binding Path=SampleCommand}"/> </r:RibbonGroup> </r:RibbonTab.Groups> </r:RibbonTab> </r:Ribbon> <Border Name="PageBorder" Grid.Row="0" Grid.Column="1"> <Frame Name="pageFrame" Source="FirstPage.xaml" /> </Border> </DockPanel> c# Page1ViewModel.cs: RelayCommand _sampleCommand; public ICommand SampleCommand { get { // create command ?? return _sampleCommand } page1.xaml.cs : Page1ViewModel pageViewModel; this.DataContext = pageViewModel; // when pageloads

    Read the article

  • Reimplementing data structures in the real world

    - by Jason
    The topic of algorithms class today was reimplementing data structures, specifically ArrayList in Java. The fact that you can customize a structure for in various ways definitely got me interested, particularly with variations of add() & iterator.remove() methods. But is reimplementing and customizing a data structure something that is of more interest to the academics vs the real-world programmers? Has anyone reimplemented their own version of a data structure in a commercial application/program, and why did you pick that route over your particular language's implementation?

    Read the article

  • A very weired problem with texbox control in C# .net

    - by Kazoom
    Well i know textbox is a very simple user control, perhaps the first input control ever made. I have been facing a very frustrating problem with this simple control. I programatically add a textbox in my user control. From ui i am able to edit it like a normal textbox. however, i am not able to read the user inputed value in the program. my program all the time sees the old value with which my text box was initialized. i textchange event getting triggered but the value never gets updated. This seemingly looks to be some innocuous bug in the code, but the program is very simple and it does not seem to be having any bug. Any guidelines on this issue?

    Read the article

  • NSUserDefaults in monotouch

    - by Ali Shafai
    I'm very impressed with MonoTouch.Dialog by Miguel. inspired by his simple approach I thought it would be very nice to have a reflection based NSUserDefaults class that works seamlessly by marking certain properties as "persistable in user defaults" and forget about the rest. something like this: public class SomeController { [PersistInUserSettings] public string LastPostUserRead { get; set; } } I don't like the LastPostUserRead to be of type "UserSetting", I like it to be a normal property so that later I can assign to it like: LastPostUserRead = "Post 1"; and not like: LastPostUserRead.SetValue("Post 1"); Any idea on how to implement it (without Reflection.Emit) in monotouch?

    Read the article

  • LINQ: Enhancing Distinct With The SelectorEqualityComparer

    - by Paulo Morgado
    On my last post, I introduced the PredicateEqualityComparer and a Distinct extension method that receives a predicate to internally create a PredicateEqualityComparer to filter elements. Using the predicate, greatly improves readability, conciseness and expressiveness of the queries, but it can be even better. Most of the times, we don’t want to provide a comparison method but just to extract the comaprison key for the elements. So, I developed a SelectorEqualityComparer that takes a method that extracts the key value for each element. Something like this: public class SelectorEqualityComparer<TSource, Tkey> : EqualityComparer<TSource> where Tkey : IEquatable<Tkey> { private Func<TSource, Tkey> selector; public SelectorEqualityComparer(Func<TSource, Tkey> selector) : base() { this.selector = selector; } public override bool Equals(TSource x, TSource y) { Tkey xKey = this.GetKey(x); Tkey yKey = this.GetKey(y); if (xKey != null) { return ((yKey != null) && xKey.Equals(yKey)); } return (yKey == null); } public override int GetHashCode(TSource obj) { Tkey key = this.GetKey(obj); return (key == null) ? 0 : key.GetHashCode(); } public override bool Equals(object obj) { SelectorEqualityComparer<TSource, Tkey> comparer = obj as SelectorEqualityComparer<TSource, Tkey>; return (comparer != null); } public override int GetHashCode() { return base.GetType().Name.GetHashCode(); } private Tkey GetKey(TSource obj) { return (obj == null) ? (Tkey)(object)null : this.selector(obj); } } Now I can write code like this: .Distinct(new SelectorEqualityComparer<Source, Key>(x => x.Field)) And, for improved readability, conciseness and expressiveness and support for anonymous types the corresponding Distinct extension method: public static IEnumerable<TSource> Distinct<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector) where TKey : IEquatable<TKey> { return source.Distinct(new SelectorEqualityComparer<TSource, TKey>(selector)); } And the query is now written like this: .Distinct(x => x.Field) For most usages, it’s simpler than using a predicate.

    Read the article

  • route view problem

    - by Clear.Cache
    Trying to check IP status to show a customer root@server [~]# telnet route-views.routeviews.org Trying 128.223.51.103... Nothing happens, but telnet is enabled Any idea why it may hang for minutes? Using CSf firewall, Centos 4.4 box

    Read the article

  • how to disable local logins to a mac snow leopard machine?

    - by Wang
    I have a maintenance script that needs to run uninterrupted, so I'd like some way to disable local user logins. Right now, the solution is to send SIGSTP to the loginwindow process, which is suboptimal for several reasons. The most important of them is that the observed behavior is a login prompt that appears to accept the user's credentials but then hangs on a blank desktop before the menu bar or dock or desktop icons appear. This has led to users "fixing" the problem by rebooting the machine. Is there a better way to disable local logins? We currently use iHook, so if there's any way to abort a login from within the login hook, that would integrate nicely with our current setup. Unfortunately, Apple doesn't seem to have documented exactly what would cause Mac OS to abort the login.

    Read the article

  • A very weird problem with texbox control in C# .net

    - by Kazoom
    Well i know textbox is a very simple user control, perhaps the first input control ever made. I have been facing a very frustrating problem with this simple control. I programatically add a textbox in my user control. From ui i am able to edit it like a normal textbox. however, i am not able to read the user inputed value in the program. my program all the time sees the old value with which my text box was initialized. i textchange event getting triggered but the value never gets updated. This seemingly looks to be some innocuous bug in the code, but the program is very simple and it does not seem to be having any bug. Any guidelines on this issue?

    Read the article

  • Changing document.domain to completely other domain

    - by Sergej Andrejev
    I'm trying to prove that changing document.domain can be used only for cross scripting on the same upper level domain. For example if i will try to change document.domain to "google.com" on page which is located on www.test.com I will get a security exception in FF. Does anybody know where to locate an official proof of that?

    Read the article

  • How to differentiate document requests from variable requests? and how to allow for urls that are no

    - by Lucas
    Hello. My last post was met by smarmy, unhelpful "answers" (comments), so i'll get right to it: if I have an htaccess file like so: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ - [L] RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1&subject=$2 RewriteRule ^([^/]+)$ /index.php?page=$1 [L] how can I allow for other url variable names and values to be handled... say for instance I want to add extra unexpected url vars to this scenario /page/subject?urlvar1=value1&urlvar2=value2 and get the page I want without creating unexpected results? Any real help is greatly appreciated. Thanks!

    Read the article

  • flv to mp3 converter

    - by alex
    hey im writing a c# flv2mp3 converter and i could need some help. flv is a container type, wich means that when i get all audio tags together, i just have have to reassemble them, or do i habe to save them in a special way? is it possible at all? and i do not want any flvextractors i wanna do it by myself

    Read the article

  • JQuery/JS Markdown plugin?

    - by Rosarch
    I'm writing a chat app, and I'd like to add some simple functionality where users use markup to affect text formatting, like bold or italics. I'm envisioning this would be like how it is done on Google Talk or StackOverflow. Does JQuery have any plugins to do this?

    Read the article

  • Processing incoming emails on Heroku

    - by Jerry Cheung
    For my side project kwiqi, I use ActionMailer's 'receive' method to process incoming email messages for tracking my expenses. Heroku doesn't have a local mail server running that same code will not work. One solution I've thought of is to periodically hit a controller action that will pull messages from Gmail. Are there other solutions that are reasonable? Is anyone processing incoming emails in Heroku?

    Read the article

  • Trouble configuring firewall for FTP on Windows Server 2008 R2

    - by x3ro
    Ok, I'm having the exact same problem as in this question http://serverfault.com/questions/59635/outbound-ftp-on-server-2008-r2-stalls but the accepted answer didn't help me much... I followed the third step of this http://learn.iis.net/page.aspx/309/configuring-ftp-firewall-settings/ guide in order to configure my firewall for FTP, and I am able to authenticate, however, the data channel doesn't seem to be passing through the firewall. If I disable the firewall, everything works fine. Hope someone can help me, as this is really starting to annoy me. Best regards, x3ro

    Read the article

  • Distinction between Cloud Servers and VPS

    - by Frank V
    What is the distinction between a Cloud based host and a VPS? I talked to a Rackspace Cloud sales person for around 45 minutes and never came to a real conclusion on this. So, to elaborate on my question a bit -- what benefits might a "cloud" server provide me versus a VPS provider such as Linode and vice versa -- what benefits would a VPS provide over a cloud provider? From what I've been able to ascertain, when you host on a cloud (with Rackspace Cloud) you get a instance of Linux in which you install software and such (a LAMP, for instance). From what I can figure, if the instance is running, I am charged and the pricing on Rackspace (according to what I understood from the sales rep) comes out to about $20 a month.... I was thinking a cloud customer pays per processing hours -- so if your app just sits there, no charges are incurred. Does one not pay of the cloud instance is shut down, perhaps? A similar questions to what I'm asking but not exactly it: Understanding: cloud-server, cloud-hosting, cloud-computing, the cloud What is the difference between vps and cloud hosting

    Read the article

  • Page numbers in Word 2007

    - by ldigas
    I'm gonna skip the usual rant which normally follows upon mention of the words "Word 2007" I have a numbered section. Which has page numbers. Then, I insert a new section break at the end of the current section ... go to page numbers, format ..., and "start at ...", and the new section then has a new page numbering (starting with some other number). But, how do I after inserting a new section break, remove the page numbering in the new section ? If I go to remove page numbers option, Word removes the numbers from the new, but also from the old section (i.e. all of them). Help ... time is short ...

    Read the article

  • Understanding top output in Linux

    - by Rayne
    Hi, I'm trying to determine the CPU usage of a program by looking at the output from Top in Linux. I understand that %us means userspace and %sy means system/kernel etc. But say I see 100%us. Does this mean that the CPU is really only doing useful work? What if a CPU is tied up waiting for resources that are not avaliable, or cache misses, would it also show up in the %us column, or any other column? Thank you.

    Read the article

  • jQuery Treeview – Expand and Collapse All Without the TreeControl

    - by Ben Griswold
    The jQuery Treeview Plugin provides collapse all, expand all and toggle all support with very little effort on your part. Simply add a treecontrol with three links, and the treeview, to your page…   <div id="treecontrol">     <a title="Collapse the entire tree below" href="#"><img src="../images/minus.gif" /> Collapse All</a>     <a title="Expand the entire tree below" href="#"><img src="../images/plus.gif" /> Expand All</a>     <a title="Toggle the tree below, opening closed branches, closing open branches" href="#">Toggle All</a> </div> <ul id="treeview" class="treeview-black">     <li>Item 1</li>     <li>         <span>Item 2</span>         <ul>             <li>                 <span>Item 2.1</span>                   <ul>                     <li>Item 2.1.1</li>                     <li>Item 2.1.2</li>                 </ul>             </li>             <li>Item 2.2</li>             <li class="closed">                   <span>Item 2.3 (closed at start)</span>                 <ul>                     <li>Item 2.3.1</li>                     <li>Item 2.3.2</li>                 </ul>             </li>         </ul>     </li> </ul> …and then associate the control to the treeview when defining the treeview settings. $("#treeview").treeview({     control: "#treecontrol",     persist: "cookie",     cookieId: "treeview-black" }); It really couldn’t be easier and it works great! But the plugin doesn’t offer a lot of flexibility when it comes to layout.  For example, the plugin assumes your treecontrol will include links.  If you want buttons or images or whatever, you are out of luck.  The plugin also assumes a set number of links and the collapse all handler is associated with the first link inside of the treecontrol, a:eq(0), the expand all handler is associated with the second link and so on.  So you really can’t incorporate the toggle all link by itself unless you manually hide the other options. Which brings me to the point of this post – making the collapse/expand/toggle layout more flexible without modifying the plugin’s source code. We will continue to use the treecontrol actions but we’re not going to use them directly. In fact, our custom collapse, expand and toggle links will trigger the actions for us.  So, hide the treecontrol links and associate the treecontrol click events with the click events of other controls.  Finally, render the treeview with the same setting definitions as usual. $(document).ready(function() {     // The plugin shows the treecontrol after the     // collapse, expand and toggle events are hooked up     // Just hide the links.     $('#treecontrol a').hide();       // On click of your custom links, button, etc     // Trigger the appropriate treecontrol click     $('#expandAll').click(function() {                 $('#treecontrol a:eq(1)').click();         });          $('#collapseAll').click(function() {         $('#treecontrol a:eq(0)').click();             });       // Render the treeview per usual.         $("#treeview").treeview({         control: "#treecontrol",         persist: "cookie",         cookieId: "treeview-black"     }); }); Since I’m not using the treecontrol directly, I move it to the bottom of the page but it doesn’t really matter where the treecontrol goes. <div>     <a id="collapseAll" href="#">Collapse All Outside of TreeControl</a> </div>   <ul id="treeview" class="treeview-black">     <li>Item 1</li>     <li>         <span>Item 2</span>         <ul>             <li>                 <span>Item 2.1</span>                 <ul>                     <li>Item 2.1.1</li>                     <li>Item 2.1.2</li>                 </ul>             </li>             <li>Item 2.2</li>             <li class="closed">                 <span>Item 2.3 (closed at start)</span>                 <ul>                     <li>Item 2.3.1</li>                     <li>Item 2.3.2</li>                 </ul>             </li>         </ul>     </li> </ul>   <div>     <input type="button" id="expandAll" value="Expand All Outside of TreeControl"/> </div>   <div id="treecontrol">     <a href="#"></a><a href="#"></a><a href="#"></a> </div> The above jQuery and Html snippets generate the following ugly output which shows the separated collapse/expand elements. If you want the toggle all option, I bet you can figure out how to put it in place.  I’ve made the source available below if you’re interested. Download jQuery Treeview Expand and Collapse Super Code

    Read the article

  • Why did i get this error?

    - by David
    here's the code: class Acount { int sum ; String owner ; //these seem to make sense //a constructor or two public Acount () { this.sum = 0 ; this.owner = "John Doe" ; } public Acount (String name) {this.sum = 0 ; this.owner = name ; } public Acount (String name, int sum) {this.sum = sum ; this.owner = name ; } //prints an acount in the format "owner" "sum" public static void printAcount (Acount Acount) {System.out.print (Acount.owner) ; System.out.print (" ") ; System.out.println (Acount.sum) ; } public static void main (String[]arg) { Acount Acount1 = new Acount ("david", 100) ; System.out.println ("heres the first acount as it was created:") ; printAcount (Acount1) ; System.out.println ("now i changed one of its instance varaibles with a static method") ; upOne (Acount1) ; printAcount (Acount1) ; } public static Acount upOne (Acount Acount) { Acount.sum = Acount.sum + 1 ; return Acount ; } } here's the error: Exception in thread "main" java.lang.NoClassDefFoundError: Acount/java What went wrong?

    Read the article

  • javascript setTimeout() first argument: expression error

    - by Jonah
    function Timer() { this.initialTime = 0; this.timeStart = null; this.getTotalTime = function() { timeEnd = new Date(); diff = timeEnd.getTime() - this.timeStart.getTime(); return diff+this.initialTime; }; this.formatTime = function() { interval = new Date(this.getTotalTime()); return interval.getHours() + ":" + interval.getMinutes() + ":" + interval.getSeconds(); }; this.start = function() { this.timeStart = new Date(); setTimeout("this.updateTime()", 1000); }; this.updateTime = function() { alert(this.formatTime()); setTimeout("this.updateTime()", 1000); }; } timer = new Timer(); timer.start(); I am getting an error: this.updateTime is not a function Any ideas? Thanks

    Read the article

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