Search Results

Search found 3227 results on 130 pages for 'anonymous guy'.

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

  • How do I write recursive anonymous functions?

    - by James T Kirk
    In my continued effort to learn scala, I'm working through 'Scala by example' by Odersky and on the chapter on first class functions, the section on anonymous function avoids a situation of recursive anonymous function. I have a solution that seems to work. I'm curious if there is a better answer out there. From the pdf: Code to showcase higher order functions def sum(f: Int => Int, a: Int, b: Int): Int = if (a > b) 0 else f(a) + sum(f, a + 1, b) def id(x: Int): Int = x def square(x: Int): Int = x * x def powerOfTwo(x: Int): Int = if (x == 0) 1 else 2 * powerOfTwo(x-1) def sumInts(a: Int, b: Int): Int = sum(id, a, b) def sumSquares(a: Int, b: Int): Int = sum(square, a, b) def sumPowersOfTwo(a: Int, b: Int): Int = sum(powerOfTwo, a, b) scala> sumPowersOfTwo(2,3) res0: Int = 12 from the pdf: Code to showcase anonymous functions def sum(f: Int => Int, a: Int, b: Int): Int = if (a > b) 0 else f(a) + sum(f, a + 1, b) def sumInts(a: Int, b: Int): Int = sum((x: Int) => x, a, b) def sumSquares(a: Int, b: Int): Int = sum((x: Int) => x * x, a, b) // no sumPowersOfTwo My code: def sumPowersOfTwo(a: Int, b: Int): Int = sum((x: Int) => { def f(y:Int):Int = if (y==0) 1 else 2 * f(y-1); f(x) }, a, b) scala> sumPowersOfTwo(2,3) res0: Int = 12

    Read the article

  • Staying anonymous while hosting your site?

    - by jamesCroft
    I don't mean anonymous surfing. I mean hosting and having your own domain and such. The reason is that my blog is about religious/political topics which may cause me trouble in the future. This is the domain I am working on: www.james-croft.com I know that using Whois search my name can come up: http://www.networksolutions.com/whois-search/james-croft.com The solution to that, as far as I understood, is to buy a privacy package from the domain registrar. in my case it is lucky register: http://i.stack.imgur.com/uvOdc.png Also hosting is a concern. I use the same hosting service for multiple websites. My question is this: Can my hosting be tracked and be used to identify me? Also: Are there other methods of finding out my identity from either Google Adsense or Amazon affiliate programs? I couldn't find any relevant articles online. If there is anything else that is relevant, please let me know. I appreciate any response.

    Read the article

  • “NT AUTHORITY\ANONYMOUS LOGON” error in Windows 7 (ASP.NET & Web Service)

    - by Tony_Henrich
    I have an asp.net web app which works fine in Windows XP machine in a domain. I am porting it to a Windows 7 stand alone machine. The app uses a web service which makes a call to sql server. The web server (IIS 7.5) and SQL Server are on the same stand alone machine. I enabled Windows authentication for the website and web service. The web service uses a trusted connection connection string. The web service credentials uses System.Net.CredentialCache.DefaultCredentials. I noticed username, password and domainname are blank after the call! The webservice and web site use the 'Classic .NET AppPool' with NetworkServices identity. I am getting an exception "NT AUTHORITY\ANONYMOUS LOGON" in the database call in the web service. I am assuming it's related to the blank credentials. I am expecting ASPNET user to be the security token to the database. Why is this not happening? Did I miss a setting? (Usually this happens when sql server and web server are on two different machines in a domain, delegation & double hopping, but in my case everything is on a dev box)

    Read the article

  • Ugly thing and advantage of anonymos method -C#

    - by nettguy
    I was asked to explain the ugly thing and advantages of anonymous method. I explained possibly Ugly thing anonymous methods turning quickly into spaghetti code. Advantages We can produce thread safe code using anonymous method :Example static List<string> Names = new List<string>( new string[] { "Jon Skeet", "Marc Gravell", "David", "Bill Gates" }); static List<string> FindNamesStartingWith(string startingText) { return Names.FindAll( delegate(string name) { return name.StartsWith(startingText); }); } But really i did not know whether it is thread safe or not.I was asked to justify it. Can any one help me to understand (1) advantages of anonymous methods (2) Is the above code thread safe or not?

    Read the article

  • Simple way to return anonymous types (to make MVC using LINQ possible)

    - by BlueRaja The Green Unicorn
    I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would do this is have the Controller generate (or call something which generates) the result-set using LINQ, then return that to the View to display the data. The problem is, if I do: return (from o in myTable select o); All the columns are read from the database, even the ones (potentially dozens) I don't want. And - more importantly - I can't do something like this: return (from o in myTable select new { o.column }); because there is no way to make anonymous types type-safe! I know for sure there is no nice, clean way of doing this in 3.5 (this is not clean...), but what about 4.0? Is there anything planned, or even proposed? Without something like duck-typing-for-LINQ, or type-safe anonymous return values (it seems to me the compiler should certainly be capable of that), it appears to be nearly impossible to cleanly separate the Controller from the View.

    Read the article

  • MVC using LINQ? - Can't return anonymous types

    - by BlueRaja
    I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would do this is have the Controller generate (or call something which generates) the result-set using LINQ, then return that to the View to display the data. The problem is, if I do: return (from o in myTable select o); All the columns are read from the database, even the ones (potentially dozens) I don't want. And - more importantly - I can't do something like this: return (from o in myTable select new { o.column }); because there is no way to make anonymous types type-safe! I know for sure there is no nice, clean way of doing this in 3.5 (this is not clean...), but what about 4.0? Is there anything planned, or even proposed? Without something like duck-typing-for-LINQ, or type-safe anonymous return values (it seems to me the compiler should certainly be capable of that), it appears to be nearly impossible to cleanly separate the Controller from the View.

    Read the article

  • Anonymous Methods / Lambda's (Coding Standards)

    - by Mystagogue
    In Jeffrey Richter's "CLR via C#" (the .net 2.0 edtion page, 353) he says that as a self-discipline, he never makes anonymous functions longer than 3 lines of code in length. He cites mostly readability / understandability as his reasons. This suites me fine, because I already had a self-discipline of using no more than 5 lines for an anonymous method. But how does that "coding standard" advice stack against lambda's? At face value, I'd treat them the same - keeping a lambda equally as short. But how do others feel about this? In particular, when lambda's are being used where (arguably) they shine brightest - when used in LINQ statements - is there genuine cause to abandon that self-discipline / coding standard?

    Read the article

  • C# -Interview Question Anonymous Type

    - by Amutha
    Recently i was asked to prove the power of C# 3.0 in a single line( might be tricky) i wrote new int[] { 1, 2, 3 }.Union(new int[]{10,23,45}). ToList().ForEach(x => Console.WriteLine(x)); and explained you can have (i) anonymous array (ii) extension method (iii)lambda and closure all in a single line.I got spot offer. But..... The interviewer asked me how will you convert an anonymous type into know type :( I am 100% sure ,we can not do that.The interviewer replied there is 200% chance to do that if you have a small work around.I was clueless. As usual,I am waiting for your valuable reply(Is it possible?).

    Read the article

  • How to get/create anonymous method from TRttiMethod?

    - by Heinrich Ulbricht
    I want to handle a TRttiMethod as anonymous method. How could I do this? Here is a simplified example of how I wish things to work: Interface: TMyClass = class public // this method will be acquired via Rtti procedure Foo; // this method shall return above Foo as anonymous method function GetMethodAsAnonymous: TProc; end; Implementation: function TMyClass.GetMethodAsAnonymous: TProc; var Ctx: TRttiContext; RttiType: TRttiType; RttiMethod: TRttiMethod; begin Ctx := TRttiContext.Create; try RttiType := Ctx.GetType(Self.ClassType); RttiMethod := RttiType.GetMethod('Foo'); Result := ??????; // <-- I want to put RttiMethod here - but how? finally Ctx.Free; end; end;

    Read the article

  • How do you document anonymous functions ?

    - by clutch
    I'm specifically referring to JavaScript anonymous function but this could be relevant to other languages. I like to use JSDoc notations in my scripts because I know other people will be hacking at it sooner or later. When i have pretty complex anonymous function how do people document it so that it gets picked up by Eclipse and other IDE's that understand JSDoc or JavaDoc notations? /** * Blah Blah blah * * @param Object Blah blah blah * @return Blah Blah Blah * @type Object */ function foo(this) { ...... this.bar = function () { ... complex code .....}; ...... return obj; } Thanks

    Read the article

  • anonymous access disabled but...

    - by Melody Friedenthal
    My web app (asp VB 2005) uses Windows authentication. If the user isn't part of a specific AD security group they don't get to edit the data; instead I redirect the user to a read-only page. The program works fine in the IDE. I published the web app to my laptop and Disabled anonymous access. When I ran the program I got redirected to the read-only page. I added a write event to the application event log to see what was going on, and found that the WindowsPrincipal.Identity.Name contained my laptop's ID, not my user name. I reassert: anonymous access is disabled in IIS and the web.config file has Windows Authentication. Can anyone suggest what else to check? Or can you explain what's going on?

    Read the article

  • How to reference an anonymous JavaScript function?

    - by ProfK
    I'm trying to call a Page Method using a jQuery 'attached' event function, in which I like to use the closure to keep the event target local, as below, but page method calls declare several 'error' functions, and I would like to use one function for all of them. If, in the below code, I was handling an error and not success, how could I use my single, anonymous handler for all 3 error functions? $(":button").click(function () { var button = this; PageMethods.DoIt( function (a, b, c) { alert(button); }); }); This example passes an anonymous function for the success callback. There is only one of these. If I was passing an error callback, how could I use 'function (e, c, t)' for all 3 error callbacks?

    Read the article

  • User controls in masterpage and anonymous user

    - by Senad Uka
    I am developing a master page which includes the user control that generates a menu from the list with a specific logic. Before including the control into master page I successfully configured anonymous access to the site. After including the control and deploying - site prompts for user name and password. I allowed the anonymous access to the list. Oh yes ... It worked on SHarepoint 2010 beta, but the problem happens when deploying to the Sharepoint 2010 final release. Additional data: I am using Sharepoint Server 2010 with Standard features, standalone instalation on Windows Server 2008 R2 for deployment, and Visual Studio 2010 Ultimate for development of masterpage and user control.

    Read the article

  • Anonymous types based in Interface

    - by Bhaskar
    Can I create anonymous implementations of an interface , in a way similar to the way delegate() { // type impl here , but not implementing any interface} Something on the lines of new IInterface() { // interface methods impl here } The situations where I see them to be useful are for specifying method parameters which are interface types, and where creating a class type is too much code. For example , consider like this : public void RunTest() { Cleanup(delegate() { return "hello from anonymous type"; }); } private void Cleanup(GetString obj) { Console.WriteLine("str from delegate " + obj()); } delegate string GetString(); how would this be achieved if in the above code , the method Cleanup had an interface as a parameter , without writing a class definition ? ( I think Java allows expressions like new Interface() ... )

    Read the article

  • Anonymous users support vs Google bot

    - by Andy
    I have a User class in my web app that represents a user currently logged in. Every time a user vists a page, a User instance is populated based on authentication data supplied in cookies. A User instance is created even if an anonymous user logs in - and a corresponding new record is created in the User table in the database. This approach allows me to save some state info for the current user regardless of its type. The problem however with this approach is the Google bot, and other non-human web organisms crawling my pages. Every time a bot starts to walk around the site, thousands of useless records will be created in the database, each of them only to be used for a single page. Question: what is the best trade off? How to support anonymous users, save their state, and don't get too much overhead because of cookieless bots?

    Read the article

  • Reusing an anonymous parameter in a prepared statement

    - by Chris Lieb
    I am customizing the insert SQL generated by hibernate and have hit an issue. When Hibernate generates the query by itself, it inserts data into the first two columns of the table, but this causes a database error since all four columns of the table are non-nullable. For the insert to be performed properly, it must insert the same data into two columns of the new record. This means that I need Hibernate to bind the same data to two different parameters in the query (prepared statement) that I am writing. Is there some SQL syntax that allows me to refer to anonymous parameters bound to a prepared statement in an order different from which they are bound? Details REF_USER_PAGE_XREF ---------------------------------------- PK FK1 | NETWORK_ID | VARCHAR2(100) PK FK1 | PAGE_PATH | VARCHAR2(1000) | USER_LAST_UPDT | VARCHAR2(100) | TMSP_LAST_UPDT | DATE insert into REF_USER_ROLE_XREF( NETWORK_ID, PAGE_PATH, TMSP_LAST_UPDT, USER_LAST_UPDT) values ( ?, /* want to insert the same data here */ ?, ?, /* and here */ (select to_char(sysdate, 'DD-MON-YY') from dual) I want to insert the same data into the first and third anonymous parameters.

    Read the article

  • Sending an anonymous email to my own address

    - by N3HL
    I want to send an anonymous email to my own gmail/hotmail/yahoo/any other mail service address (Im not trying to spam or something like that). Why? I have a .NET application and I want to add a "Send log to the developer" feature (attaching the log) using SmtpClient. The fact is I've read like 30+ pages, and found out, i.e. gmail's smtp client doesn't allow anonymous connections, and many other things. The idea is to receive a mail message like this: From: [email protected] (non-existent email really) To: [email protected] (this would be my real address which will recieve the logs attachments) Subject: Issue report nºX (auto-generated) Body: From a textbox Attachments: logs attached Is this possible? If so, how do I achieve it?

    Read the article

  • Silverlight async calls and anonymous methods....

    - by JLewis
    I know there are a couple of debates on this kind of thing.... At any rate, I have several cases where I need to populate combobox items based on enumerations returned from the WCF service. In an effort to keep code clean, I started this approach. After looking into it more, I don't think the this works as well is initially thought... I am throwing this out to get recommendations/advice/code snippets on how you would do this or how you currently do this. I may be forced to have a seperate, non anonymous method, procedure. I hate doing this for something like this but at the moment, don't see it working another way... EventHandler<GetEnumerationsForTypeCompletedEventArgs> ev = null; ev = delegate(object eventSender, GetEnumerationsForTypeCompletedEventArgs eventArgs) { if (eventArgs.Error == null) { //comboBox.ItemsSource = eventArgs.Result; // populate combox for display purposes (for now) foreach (Enumeration e in eventArgs.Result) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Content = e.EnumerationValueDisplayed; comboBox.Items.Add(cbi); } // remove event so we don't keep adding new events each time we need an enumeration proxy.GetEnumerationsForTypeCompleted -= ev; } }; proxy.GetEnumerationsForTypeCompleted += ev; proxy.GetEnumerationsForTypeAsync(sEnumerationType); Basically in this example we use ev to hold the anonymous method so we can then use ev from within the method to remove it from the events once called. This prevents this method from getting called more than one time. I suspect that the comboBox local var declared before this call, but within the same method, is not always the combobox originally intended but can't really verify that yet. I may add a tag to it to do some tests and populating to verify. Sorry if this is not clear. I can elaborate more if needed. Thanks Jeff

    Read the article

  • Sorting Anonymous Types

    - by strobaek
    I have a question of how to sort an anonymous type. Using Linq2SQL I have the following query, which returns a list of submissions: var submissions = EventSubmissions .Where(s => s.EventId.Equals(eventId)); Consider the following interface (somewhat simplyfied): public interface IQuerySorter { IOrderedQueryable Sort(IQueryable query); IOrderedQueryable<T> Sort<T, U>(IQueryable<T> query, Expression<Func<T,U>> selector); ... } Using this interface allows me to implement a number of 'sorters', e.g. on Date, Rating or whether or not a submission has been nominated (for voting). sortedQuery = sorter.Sort(submissions) So far so good. A submission can be made "votable". I get the number of votes a nominated submission may have using the following query: var withVoteCount = submissions .Select(s => new {NumberOfVotes = s.Votes.Count(), Submission = s}); I would like to sort this new query by NumberOfVotes using my "general" sorter class, but run into the problem that the anonymous type/member does not seem to live outside the repository-method, hence I am unable to sort on it. Any input would be greatly appreciated.

    Read the article

  • Perl - How to get the number of elements in an anonymous array, for concisely trimming pathnames

    - by NXT
    Hi Everyone, I'm trying to get a block of code down to one line. I need a way to get the number of items in a list. My code currently looks like this: # Include the lib directory several levels up from this directory my @ary = split('/', $Bin); my @ary = @ary[0 .. $#ary-4]; my $res = join '/',@ary; lib->import($res.'/lib'); That's great but I'd like to make that one line, something like this: lib->import( join('/', ((split('/', $Bin)) [0 .. $#ary-4])) ); But of course the syntax $#ary is meaningless in the above line. Is there equivalent way to get the number of elements in an anonymous list? Thanks! PS: The reason for consolidating this is that it will be in the header of a bunch of perl scripts that are ancillary to the main application, and I want this little incantation to be more cut & paste proof. Thanks everyone There doesn't seem to be a shorthand for the number of elements in an anonymous list. That seems like an oversight. However the suggested alternatives were all good. I'm going with: lib->import(join('/', splice( @{[split('/', $Bin)]}, 0, -4)).'/lib'); But Ether suggested the following, which is much more correct and portable: my $lib = File::Spec->catfile( realpath(File::Spec->catfile($FindBin::Bin, ('..') x 4)), 'lib'); lib->import($lib);

    Read the article

  • iPhone OS: Get a list of methods and variables from anonymous object

    - by ChrisOPeterson
    I am building my first iPhone/Obj-c app and I have a large amount of data-holding subclasses that I am passing into a cite function. To the cite function these objects are anonymous and I need to find a way to access all the variables of each passed object. I have been using a pre-built NSArray and Selectors to do this but with more than 30 entries (and growing) it is kind of silly to do manually. There has to be a way to dynamically look up all the variables of an anonymous object. The obj-c runtime run-time docs mention this problem but from what I can tell this is not available in iPhone OS. If it is then I don't understand the implementation and need some guidance. A similar question was asked before but again I think they were talking about OSX and not iPhone. Any thoughts? -(NSString*)cite:(id)source { NSString *sourceClass = NSStringFromClass([source class]); // Runs through all the variables in the manually built methodList for(id method in methodList) { SEL x = NSSelectorFromString(method); // further implementation // Should be something like NSArray *methodList = [[NSArray alloc] initWithObjects:[source getVariableList]] for(id method in methodList) { SEL x = NSSelectorFromString(method); // Further implementation }

    Read the article

  • Why LINQ to Entities won't let me initialize just some properties of an Entity?

    - by emzero
    So I've started to add Entity Framework 4 into a legacy web application (ASP.NET WebForms). As a start I have auto-generated some entities from the database. Also I want to apply Repository Pattern. There is an entity called Visitor and its repository VisitorRepository In VisitorRepository I have the following method: public IEnumerable<Visitor> GetActiveVisitors() { var visitors = from v in _context.Visitors where v.IsActive select new Visitor { VisitorID = v.VisitorID, EmailAddress = v.EmailAddress, RegisterDate = v.RegisterDate, Company = v.Company, Position = v.Position, FirstName = v.FirstName, LastName = v.LastName }; return visitors.ToList(); } That List is then bound to a repeater and when trying to do <%# Eval('EmailAddress') #%> it throws the following exception. The entity or complex type 'Model.Visitor' cannot be constructed in a LINQ to Entities query. A) Why is this happening? How I can workaround this? Do I need to select an anonymous type and then use that to initialize my entities??? B) Why every example I've seen makes use of 'select new' (anonymous object) instead of initializing a known type? Anonymous types are useless unless you are retrieving the data and showing it in the same layer. As far as I know anonymous types cannot be returned from methods? So what's the real point of them??? Thank you all

    Read the article

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