Search Results

Search found 6357 results on 255 pages for 'generic relations'.

Page 165/255 | < Previous Page | 161 162 163 164 165 166 167 168 169 170 171 172  | Next Page >

  • Please help me translate C# code to Ruby

    - by Valentin Vasilyev
    Here is the code: using System; using System.Collections.Generic; using System.Linq; namespace cs2 { class Program { static void Main(string[] args) { var i=Fibs.TakeWhile(x=>x < 1000).Where(x=>x % 2==0).Sum(); } static IEnumerable<long> Fibs() { long a = 0, b = 1; while (true) { yield return b; b += a; a = b - a; } } } }

    Read the article

  • Why is Decimal('0') > 9999.0 True in Python?

    - by parxier
    This is somehow related to my question Why is ''0 True in Python? In Python 2.6.4: >> Decimal('0') > 9999.0 True From the answer to my original question I understand that when comparing objects of different types in Python 2.x the types are ordered by their name. But in this case: >> type(Decimal('0')).__name__ > type(9999.0).__name__ False Why is Decimal('0') > 9999.0 == True then? UPDATE: I usually work on Ubuntu (Linux 2.6.31-20-generic #57-Ubuntu SMP Mon Feb 8 09:05:19 UTC 2010 i686 GNU/Linux, Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2). On Windows (WinXP Professional SP3, Python 2.6.4 (r264:75706, Nov 3 2009, 13:23:17) [MSC v.1500 32 bit (Intel)] on win32) my original statement works differently: >> Decimal('0') > 9999.0 False I even more puzzled now. %-(

    Read the article

  • Can I have two different Styles in a CustomControl

    - by Subhen
    Hi, Can we have two different styles in generic.xaml setter template Property Something like: <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:customLocalFolderButton"> **<----Style 1---->** </ControlTemplate TargetType="local:customLocalFolderButton"> </Setter.Value> <Setter.Value> <ControlTemplate TargetType="local:customLocalFolderButton"> **<----Style 2---->** </ControlTemplate TargetType="local:customLocalFolderButton"> </Setter.Value> </Setter> Now I want to load the styles , as per the requirement. The 1st Style Can have a Red Folder and the Second Style Can have Blue Folder . The user can choose any of the theme and the choosen style(Either RedFolder or Blue) should be applied in the customControl it self. Thanks, Subhen

    Read the article

  • javascript memory leak

    - by hhj
    I have a some javascript (used with google maps api) that I am testing on IE and Chrome and noticed memory leak symptoms in IE only: when I refresh the page continuously, the amount of memory used in IE keeps growing (fast), but in Chrome it stays constant. Without posting all of the code (as it is rather long), can I get some suggestions as to what to look out for? What could cause the memory to keep growing like this in IE on page refreshes? Like I said I know its hard without code, but I'd like to see if any generic advice works first. Thanks.

    Read the article

  • Instantiate ItemsPanelTemplate

    - by Stephan
    I'm trying to create a ItemsControl that has a separator between items, for example a control to create a navigation bread crumb. I want the control to be completely generic. My original method was to create extend ItemsControl, add a SeparatorTemplate property, and then have the class add separators to the ItemsHost of the ItemsControl. The problem with this approach is that if you add extra items to the container panel, the ItemGenerator gets confused and the items are out of order and don't get removed correctly. So my second plan was to create a completely new control that would emulate an ItemsControl, but the problem I'm running into is that I can't find a way to instantiate an ItemsPanelTemplate. I would like to provide an ItemsPanel property just like ItemsControl, but I can't then create a panel from that template. Can anyone think of a way to either instantiate an ItemsPanelTemplate or way to add controls to an ItemsControl's panel without breaking the ItemGenerator?

    Read the article

  • Any ideas for developing a Risc Processor friendly string allocator?

    - by Richard Fabian
    I'm working on some tools to enable high throughput data-oriented development, and one thing that I've not got an immediate answer for is how you go about allocating strings quickly. On risc processors you've got another problem of implementation that the CPU doesn't like branching, which is what I'm trying to minimise or avoid. Also, cache coherence is important on most CPUs, so that's gotta be influential in the design too. So, how would you go about reducing the overhead for a generic string allocator? Sometimes it's easier to solve a more explicit problem, so any ideas for string sizes of 5-30?

    Read the article

  • Multiple classes in body tag, multi-dimensional css structure or blueprint for insanity?

    - by mwiik
    This question is about an approach to css structuring, and so is more discussion oriented. I'm working with some outsourced css where the body tags have multiple classes assigned, up to half a dozen. (To make things a little worse, none of the css selectors include an html tag which is making it confusing to analyze the css.) These body classes are then used to modify classed or id'd widgets within. It seems like this approach is like adding an additional dimension to the css, perhaps in some attempt to create a structured css approach. Documentation might have helped, had we been provided any. This differs from my approach where widgets are styled primarily via id'd divs, perhaps extracting the more generic elements into a class, i.e. div#MyWidget.widgets. Any ideas on whether such an approach is maintainable, especially considering I am dealing with websites with thousands of pages including tons of legacy stuff, all done by different people with different skill levels? Thanks...

    Read the article

  • First try StructureMap and MVC3 via NuGet

    - by Angel Escobedo
    Hello Guys, I'm trying to figure how to config StructureMap for ASP.NET MVC3 I've already using NuGet and I notice that it creates App_Start Folder with a cs file named as StructuremapMVC, so I check it and notice that is the same code but simplified that will be written manually on App_Start section placed on Global.asax... My Question is when I inject some IoC on my Controllers as the follow (I use this pattern : Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable) : private readonly IAsambleaRepository _aRep; private readonly IUnitOfWork _uOw; public AsambleaController(IAsambleaRepository aRep, IUnitOfWork uOw) { _aRep = aRep; this._uOw = uOw; } public ActionResult List(string period) { var rs = _aRep.ByPeriodo(period).ToList<Asamblea>(); return View(); } I got an Exception Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

    Read the article

  • Need some suggestions on my softwares architecture. [Code review]

    - by Sergio Tapia
    I'm making an open source C# library for other developers to use. My key concern is ease of use. This means using intuitive names, intuitive method usage and such. This is the first time I've done something with other people in mind, so I'm really concerned about the quality of the architecture. Plus, I wouldn't mind learning a thing or two. :) I have three classes: Downloader, Parser and Movie I was thinking that it would be best to only expose the Movie class of my library and have Downloader and Parser remain hidden from invocation. Ultimately, I see my library being used like this. using FreeIMDB; public void Test() { var MyMovie = Movie.FindMovie("The Matrix"); //Now MyMovie would have all it's fields set and ready for the big show. } Can you review how I'm planning this, and point out any wrong judgement calls I've made and where I could improve. Remember, my main concern is ease of use. Movie.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace FreeIMDB { public class Movie { public Image Poster { get; set; } public string Title { get; set; } public DateTime ReleaseDate { get; set; } public string Rating { get; set; } public string Director { get; set; } public List<string> Writers { get; set; } public List<string> Genres { get; set; } public string Tagline { get; set; } public string Plot { get; set; } public List<string> Cast { get; set; } public string Runtime { get; set; } public string Country { get; set; } public string Language { get; set; } public Movie FindMovie(string Title) { Movie film = new Movie(); Parser parser = Parser.FromMovieTitle(Title); film.Poster = parser.Poster(); film.Title = parser.Title(); film.ReleaseDate = parser.ReleaseDate(); //And so an so forth. } public Movie FindKnownMovie(string ID) { Movie film = new Movie(); Parser parser = Parser.FromMovieID(ID); film.Poster = parser.Poster(); film.Title = parser.Title(); film.ReleaseDate = parser.ReleaseDate(); //And so an so forth. } } } Parser.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using HtmlAgilityPack; namespace FreeIMDB { /// <summary> /// Provides a simple, and intuitive way for searching for movies and actors on IMDB. /// </summary> class Parser { private Downloader downloader = new Downloader(); private HtmlDocument Page; #region "Page Loader Events" private Parser() { } public static Parser FromMovieTitle(string MovieTitle) { var newParser = new Parser(); newParser.Page = newParser.downloader.FindMovie(MovieTitle); return newParser; } public static Parser FromActorName(string ActorName) { var newParser = new Parser(); newParser.Page = newParser.downloader.FindActor(ActorName); return newParser; } public static Parser FromMovieID(string MovieID) { var newParser = new Parser(); newParser.Page = newParser.downloader.FindKnownMovie(MovieID); return newParser; } public static Parser FromActorID(string ActorID) { var newParser = new Parser(); newParser.Page = newParser.downloader.FindKnownActor(ActorID); return newParser; } #endregion #region "Page Parsing Methods" public string Poster() { //Logic to scrape the Poster URL from the Page element of this. return null; } public string Title() { return null; } public DateTime ReleaseDate() { return null; } #endregion } } ----------------------------------------------- Do you guys think I'm heading towards a good path, or am I setting myself up for a world of hurt later on? My original thought was to separate the downloading, the parsing and the actual populating to easily have an extensible library. Imagine if one day the website changed its HTML, I would then only have to modifiy the parsing class without touching the Downloader.cs or Movie.cs class. Thanks for reading and for helping!

    Read the article

  • To return the list in JSON format

    - by Reshma
    Below is my code, List<string> modified_listofstrings = new List<string>(); string sJSON = ""; System.Web.Script.Serialization.JavaScriptSerializer jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer(); resulted_value = final_resulted_series_name + ":" + period_name + ":" + period_final_value; modified_listofstrings.Add(resulted_value); json_resultedvalue = JsonConvert.SerializeObject(resulted_value); modified_listofstrings.Add(json_resultedvalue); sJSON = jSearializer.Serialize(modified_listofstrings); return sJSON; But on following line , sJSON = jSearializer.Serialize(modified_listofstrings); I am getting an error as Cannot implicitly convert type string to system.collection.generic.list

    Read the article

  • Error Downloading Metadata from ASMX Service

    - by michael.lukatchik
    It should be possible (and it looks like it is), but assume I have the following functions in my ASMX web service: [WebMethod(MessageName = "CreateExternalRpt1")] public bool CreateExternalRpt(int iProductId, int iOrderProductId, DateTime dtReportTime, string strReportTitle, string strReportCategory, string strReportPrintType, out string strSnapshot, string strApplicantFirst, string strApplicantLast, string strApplicantMiddle, string strOwnerLast, string strOwnerMiddle, string strOwnerFirst, bool blnCurrentReport, int iOrderId, bool blnFlag, string strCustomerId, string strUserId) { … } [WebMethod(MessageName = "CreateExternalRpt2")] public bool CreateExternalRpt(int iProductId, int iOrderProductId, DateTime dtReportTime, string strReportTitle, string strReportCategory, string strReportPrintType, string strReportSnapshot, string strApplicantFirst, string strApplicantLast, string strApplicantMiddle, string strOwnerLast, string strOwnerMiddle, string strOwnerFirst, bool blnCurrentReport, int iOrderId, bool blnFlag) { … } With both of these functions defined in my web service, my .NET client app can’t download the metadata and instead throws a generic error message “There was an error downloading…”. With one of the above methods removed, the .NET client app can successfully download the metadata. I’ve read that by decorating the WebMethod with a unique name, both functions should be exposed in the service metadata. This isn’t working. What am I missing?

    Read the article

  • Flex 4: Defining a XML data model in an Actionscript Class

    - by Steve
    I'm really having a hard time accessing a data model I've defined in an Actionscript class in my Flex app. The following is my AS Class (Model.as): package { import mx.rpc.http.HTTPService; public class Model { private static var _instance:Model; public static function getInstance():Model { if (!_instance) _instance = new Model(); return _instance; } [Bindable] public var xml:mx.rpc.http.HTTPService = new mx.rpc.http.HTTPService(); Model.getInstance().xml.url = "http://127.0.01/RAF/DATAPOINTS.xml"; Model.getInstance().xml.resultFormat = "e4x"; } } I'm then trying to access this in my main application with the following code: Model.getInstance().xml.send(); var sectorList:XMLList = Model.getInstance().xml.lastResult; And it just keeps throwing errors. The errors are generic so I can't determine the source in debugging. Hope this is enough info...

    Read the article

  • Fade animation UITableViewCell

    - by Tomas
    Hi everyone, I have a UITableViewController that populates a UITableView with some data that I pull off the net. The data for each cell consists also of an image used as background, which I'm downloading in a separated NSOperation added to a NSOperationQueue with a MaxConcurrentOperationCount set to 4. As long as the image is not downloaded I'm showing a generic placeholder which I would like to replace (fading out/fading in) with the downloaded image once it's being successfully downloaded. I'm using the following code placed inside the cellForRowAtIndexPath of the UITableViewController. [UIView beginAnimations:@"fade" context:nil]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:3.0]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; cell.placeholderUIImage.alpha = 0.0; cell.backgroundUIImage.alpha = 1.0; [UIView commitAnimations]; This is unfortunately just working randomly for a couple of rows, since for the most the background image is set instantly, as if the animation started on one cell would have been "overwritten" by the next call of beginAnimations.

    Read the article

  • Programatically WPF Fade In (via extension methods)

    - by Dinis Cruz
    I'm trying to write a simple (stand alone) C# extension method to do a Fade-In of a generic WPF UIElement, but the solutions (and code samples) that I found all contain a large number of moving parts (like setting up a story, etc...) For reference here is an example of the type of API method I would like to create. This code will rotate an UIElement according to the values provided (fromValue, toValue, duration and loop) public static T rotate<T>(this T uiElement, double fromValue, double toValue, int durationInSeconds, bool loopAnimation) where T : UIElement { return (T)uiElement.wpfInvoke( ()=>{ DoubleAnimation doubleAnimation = new DoubleAnimation(fromValue, toValue, new Duration(TimeSpan.FromSeconds(durationInSeconds))); RotateTransform rotateTransform = new RotateTransform(); uiElement.RenderTransform = rotateTransform; uiElement.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5); if (loopAnimation) doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; rotateTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation); return uiElement; }); }

    Read the article

  • Unknown error when creating packages with pkgbuild

    - by Aeyoun
    I followed several tutorials-which all appeared to say the same thing-on how to create deployable flat-packages (.pkg) using the OS X system provided pkgbuild tool. The packages was always generated just fine. They did, however, not want to be installed. Running the graphical Apple Installer or the command line interface installer aborted the installation early on giving an generic “Unknown error” after prompting for higher permissions. Hours later after closer investigation I discovered that I could not install other packages either. Not even updates and new installations from the OS X App Store. Why could I not install my own nor any other packages? What was going on?

    Read the article

  • Testing for security vulnerabilities on web applications

    - by Moak
    A lot of companies use CMS software that updates on the regular, often they are security fixes, implying that the previous version have security vulnerabilities. But most clients never upgrade this, or even the CMS has been modified so that an update would break the site. Are there sites that document these exploits, and instruct how to test for them? Or does this information not even get published? (in order not to have people try to exploit them) Also is there a generic php/js based check list to prevent hack attempts? I know about SQL injections and XSS, but I'm sure that there are more threats out there. Peace

    Read the article

  • deploying flex on tomcat

    - by ron
    Hello, I am using Flash builder 4 (SDK3.5) to create my flex program. I want to deploy this program and load it to a tomcat server. I configure my "flex server" root folder and other parameters in the project properties. The problem is, that i don't know how to make it generic. e.g. my friend's tomcat is installed in other directory on the computer. I know that in eclipse i can run the server and tomcat from the IDE. I can't see how i do it in Flash builder plugin for eclipse 4. There is a server configuration, but there isn't adapter for tomcat. Any ideas? thanks.

    Read the article

  • LLBLGen and the repository pattern

    - by user137348
    I was wondering if building a repository on the top LLBLGen (adapter) is a good idea. I don't want to overengineer and reinvent the wheel again. The DataAccessAdapter class could be some kind of a generic repository.It has all the CRUD methods you need. But on the other side for a larger project it could be good to have a layer between your ORM and service layer. I'd like to hear your opinions, if your using the repository pattern with LLBLGen,if yes why if no why not. If you have some implementation, post it please.

    Read the article

  • prevent hover set by the CSS

    - by meo
    I try to prevent the Browser from using the :hover effect of the CSS. $("ul#mainFilter a").hover( function(o){ o.preventDefault(); ...do my stuff... }, function(o){ o.preventDefault(); ...do my stuff... }); I tired it with return false; to but it does not work. Does anyone know how to do this? due the answers i give you some more nfo: I have set the a and a:hover styles, in my CSS already. Now if JS is available on the clients machine, i want to overwrite the effect with a smoother one. (using jQuery color plugin) As mentioned by fudgey, a work around would be to set the style (using .css()) but i would have to overwrite every single effect specified in the CSS (see here: http://jsfiddle.net/raPeX/1/ ). I am looking for a generic solution.

    Read the article

  • Java URL("file://") doesn't work on Windows XP

    - by Soumya Simanta
    For some reason the following code doesn't work on Windows XP. new URL("file://" + tempfile.getAbsolutePath()); I'm using Java 1.6. Java(TM) SE Runtime Environment (build 1.6.0_31-b05) Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing) However, the same code just works fine in OS X (Lion) and Java 1.6 java version "1.6.0_29" Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527) Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode) Linux (Linux 2.6.32-38-generic #83-Ubuntu x86_64 GNU/Linux) with Java 1.6 java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode) Based on this the above code should work.

    Read the article

  • Learning about version control systems, Git, SVN

    - by anijhaw
    I am a basic SVN user now trying to learn GIT for a new position. I am trying the usual reading docs and watching videos. However after doing all that I still feel that there is a lot that I do not know. I was wondering if there is a place like project Euler for programming languages, that provides a series of exercises that you can do just to increase your confidence and test your knowledge about a version control system. Something thats generic enough and gets you up to speed with how to do basic things. This could also serve as a comparison point of sorts between multiple VCSs, that would show what things are easy in which VCS. If there is nothing I was planning to document my journey in learning GIT and the create an exercise of this sort.

    Read the article

  • Can folks that edit tags make sure they preserve the information that they would be editing away?

    - by vkraemer
    I have notice that some folks edit the tags associated with questions to make the tag more generic, like converting netbeans6.8-netbeans. I think this is a good thing. BUT, most users/askers do not include version info in the text of their question and some of them do pick the 'versioned' tag. That additional info is valuable at that point. Please read the question before you edit version info out of tags. If the version info is not in the question's text.... take another moment to edit the text of the question, so the info is immediately available to folks that are trying to answer questions.

    Read the article

  • Access to an inner type

    - by sohum
    A colleague of mine posted a question on an internal forum which got me thinking about whether this was possible through C#. Basically, he's got an interface as follows: public interface IProvider<T> { T GetT(); } Is it possible to use something that implements that interface as a type parameter to another generic class and have access to the type T without re-specifying it? For example: public class Foo<P> where P : IProvider<T> { P p; T GetInnerT() { return p.GetT(); } } This does not compile, because the type T is not defined and hence can't be used as a parameter for IProvider. Is something like this even possible? Just curious!

    Read the article

  • Are these libraries okay to distribute with my C# application?

    - by HoNgOuRu
    I included these libraries or namespaces in my C# application and published the solution as freeware. I used Visual C# Express 2008. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Media; using System.Management; using System.Diagnostics; using System.Runtime.InteropServices; using System.Drawing.Text; Is it okay to give the application as freeware or am I violating any license here???

    Read the article

  • Best cross-platform solution for network server?

    - by Anonymous
    Hi, im starting a new project and for the first time i want to be cross-platform. But the tricky is my project would involve listen server, cryptos etc., etc. So i was wondering what is the best solution for cross-platform development (OpenSSL, instead of MSCrypto etc.) that would be easy to write with VS2010 (yeah the RC). The language is still not specified (depends on witch we would be easier) but im leaning to Visual C++. In Cross-Platform i mean windows/generic unix compilation.

    Read the article

< Previous Page | 161 162 163 164 165 166 167 168 169 170 171 172  | Next Page >