Search Results

Search found 366 results on 15 pages for 'closure cowboy'.

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

  • Singleton by Jon Skeet clarification

    - by amutha
    public sealed class Singleton { Singleton() { } public static Singleton Instance { get { return Nested.instance; } } class Nested { // Explicit static constructor to tell C# compiler // not to mark type as beforefieldinit static Nested() { } internal static readonly Singleton instance = new Singleton(); } } I wish to implement Jon Skeet's Singleton pattern in my current application in C#. I have two doubts on the code 1) How is it possible to access the outer class inside nested class? I mean internal static readonly Singleton instance = new Singleton(); Is something called closure? 2) I did not get this comment // Explicit static constructor to tell C# compiler // not to mark type as beforefieldinit what does this comment suggest us?

    Read the article

  • Interval tree algorithm that supports merging of intervals with no overlap

    - by Dave Griffiths
    I'm looking for an interval tree algorithm similar to the red-black interval tree in CLR but that supports merging of intervals by default so that there are never any overlapping intervals. In other words if you had a tree containing two intervals [2,3] and [5,6] and you added the interval [4,4], the result would be a tree containing just one interval [2,6]. Thanks Update: the use case I'm considering is calculating transitive closure. Interval sets are used to store the successor sets because they have been found to be quite compact. But if you represent interval sets just as a linked list I have found that in some situations they can become quite large and hence so does the time required to find the insertion point. Hence my interest in interval trees. Also there may be quite a lot of merging one tree with another (i.e. a set OR operation) - if both trees are large then it may be better to create a new tree using inorder walks of both trees rather than repeated insertions of each interval.

    Read the article

  • People not respecting good practices at workplace

    - by VexXtreme
    Hi There are some major issues in my company regarding practices, procedures and methodologies. First of all, we're a small firm and there are only 3-4 developers, one of which is our boss who isn't really a programmer, he just chimes in now and then and tries to do code some simple things. The biggest problems are: Major cowboy coding and lack of methodologies. I've tried explaining to everyone the benefits of TDD and unit testing, but I only got weird looks as if I'm talking nonsense. Even the boss gave me the reaction along the lines of "why do we need that? it's just unnecessary overhead and a waste of time". Nobody uses design patterns. I have to tell people not to write business logic in code behind, I have to remind them not to hardcode concrete implementations and dependencies into classes and cetera. I often feel like a nazi because of this and people think I'm enforcing unnecessary policies and use of design patterns. The biggest problem of all is that people don't even respect common sense security policies. I've noticed that college students who work on tech support use our continuous integration and source control server as a dump to store their music, videos, series they download from torrents and so on. You can imagine the horror when I realized that most of the partition reserved for source control backups was used by entire seasons of TV series and movies. Our development server isn't even connected to an UPS and surge protection. It's just plugged straight into the wall outlet. I asked the boss to buy surge protection, but he said it's unnecessary. All in all, I like working here because the atmosphere is very relaxed, money is good and we're all like a family (so don't advise me to quit), but I simply don't know how to explain to people that they need to stick to some standards and good practices in IT industry and that they can't behave so irresponsibly. Thanks for the advice

    Read the article

  • Grails Shiro plugin : confirming my understanding

    - by bsreekanth
    I'm bit vague about how to start using the shiro plugin, after reading few documents. I decided against Nimble, as it comes with few tables and UI plugins. I setup shiro plugin with wildcard realm, with my own tables. I may use permission based (rather tan role based) access control as it scales well. Now, the steps for it. assign the permission string to the subject, and save it in the db check the permission through isPermitted, hasPermission (or relevant tags in GSP). Now, 1. when to use the accesscontrol through filter? 2. is there a closure injected into the controller where I can define the permission for the actions in it? 3. How do I create a typical access control scenario like only the creator of (something, a post etc) can delete it? thanks a lot.. Babu.

    Read the article

  • What is in scala-android.jar?

    - by synic
    I've been trying to experiment with developing Android applications with Scala. I've gotten to the point where I can get the app to compile, but there are no helper functions for things like: button.setOnClickListener( () => { text.setText("test") }) (I'm talking about the closure there) I see lots of references to scala-android.jar, and have this file in my project, but I'm not sure what it does, or how to use it. I get the feeling it has these helper conversion functions, but I'm not sure. Running jar -tvf scala-android.jar on the file gives me this: 401 Sun Jun 06 10:06:02 MDT 2010 scala/Function0$class.class 431 Sun Jun 06 10:06:02 MDT 2010 scala/Function0.class 572 Sun Jun 06 10:06:02 MDT 2010 scala/Function1.class 282 Sun Jun 06 10:06:02 MDT 2010 scala/ScalaObject$class.class 271 Sun Jun 06 10:06:02 MDT 2010 scala/ScalaObject.class 458 Sun Jun 06 10:06:02 MDT 2010 scala/runtime/BoxedUnit.class If this isn't what I'm looking for, is there a simple library that'll do conversions for this kind of stuff?

    Read the article

  • Simulating aspects of static-typing in a duck-typed language

    - by Mike
    In my current job I'm building a suite of Perl scripts that depend heavily on objects. (using Perl's bless() on a Hash to get as close to OO as possible) Now, for lack of a better way of putting this, most programmers at my company aren't very smart. Worse, they don't like reading documentation and seem to have a problem understanding other people's code. Cowboy coding is the game here. Whenever they encounter a problem and try to fix it, they come up with a horrendous solution that actually solves nothing and usually makes it worse. This results in me, frankly, not trusting them with code written in duck typed language. As an example, I see too many problems with them not getting an explicit error for misusing objects. For instance, if type A has member foo, and they do something like, instance->goo, they aren't going to see the problem immediately. It will return a null/undefined value, and they will probably waste an hour finding the cause. Then end up changing something else because they didn't properly identify the original problem. So I'm brainstorming for a way to keep my scripting language (its rapid development is an advantage) but give an explicit error message when an an object isn't used properly. I realize that since there isn't a compile stage or static typing, the error will have to be at run time. I'm fine with this, so long as the user gets a very explicit notice saying "this object doesn't have X" As part of my solution, I don't want it to be required that they check if a method/variable exists before trying to use it. Even though my work is in Perl, I think this can be language agnostic.

    Read the article

  • Is there an easy way to get a list of all successful captures from a regex pre-5.10?

    - by Chas. Owens
    I know the right way to do this if I have Perl 5.10 is to use named captures and values %+, but in Perl 5.8.9 and how can I get a list of successful captures? I have come up with two methods that are both just terrible: #you need to list each possible match my @captures = grep { defined } ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16); and #ew, I turned on symbolic references { no strict 'refs'; my @captures = map { defined $+[$_] ? $$_ : () } 1 .. $#+; } There is a third option I have found involving (?{}), but it requires global variables (because the closure happens at compile time) and takes the regex from reasonably clear to ungodly mess. The only alternative I have found is to capture the whole match and then use another set of regexes to get the values I want (actually I build the first regex out of the other regexes because there is no good reason to duplicate the logic).

    Read the article

  • Iterator blocks in Clojure?

    - by Checkers
    I am using clojure.contrib.sql to fetch some records from an SQLite database. (defn read-all-foo [] (with-connection *db* (with-query-results res ["select * from foo"] (into [] res)))) Now, I don't really want to realize the whole sequence before returning from the function (i.e. I want to keep it lazy), but if I return res directly or wrap it some kind of lazy wrapper (for example I want to make a certain map transformation on result sequence), SQL-related bindings will be reset and connection will be closed after I return, so realizing the sequence will throw an exception. How can I enclose the whole function in a closure and return a kind of iterator block (like yield in C# or Python)? Or is there another way to return a lazy sequence from this function?

    Read the article

  • Shortest way of attaching multiple DOM elements to one event handler using Jquery?

    - by Camsoft
    I need to attach a single event handler to multiple DOM elements using jQuery. I'm currently achieving this using jQuery's each() method. See below: $([elm1, elm2, elm3]).each(function() { this.click(eventHandler); }); I was wondering if there is a way to do this without using the each method and closure. I thought I would be able to do something like: $(elm1, elm2, elm3).click(eventHandler); This kind of statement works using Prototype.js but not in jQuery.The reason I ask the question is because after using both Prototype.js and jQuery I have found that jQuery requires simpler statements to achieve the same tasks in almost every area so I assume there must be a better way of doing this?

    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 define enum in as3?

    - by Nava Carmon
    Is there a way to define an enum in AS3 in a way we do it in other languages? I can define constants with defined values like that: private const CONST_1:int = 0; private const CONST_2:int = 1; private const CONST_3:int = 2; and so on. If I want to insert some other constant between 3 these I need to move all values like that: private const CONST_1:int = 0; private const CONST_2:int = 1; private const CONST_2A:int = 2; private const CONST_3:int = 3; while in other language I would end up with only adding a new member to enum closure like that: enum { CONST_1 = 0, CONST_2, CONST_2A, CONST_3 } MyConstEnum; Does AS3 has something similar? Thanks

    Read the article

  • Java - JTable multiple instances

    - by Brian
    I have a JTable that gets data added to it from another JTable. Now I want to switch between JTables according to the day selected in a JComboBox. For example, if I choose Monday I add programs added to it then I select Tuesday from the JComboBox and a fresh JTable appears. If I go to Monday again the programs should still be there (until the program is closed). How do I create multiple JTables (the JTable remains the same) for the days and let the info remain there until program closure? Here is an example to show you what I mean:

    Read the article

  • Is it possible to replace groovy method for existing object?

    - by Jean Barmash
    The following code tried to replace an existing method in a Groovy class: class A { void abc() { println "original" } } x= new A() x.abc() A.metaClass.abc={-> println "new" } x.abc() A.metaClass.methods.findAll{it.name=="abc"}.each { println "Method $it"} new A().abc() And it results in the following output: original original Method org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod@103074e[name: abc params: [] returns: class java.lang.Object owner: class A] Method public void A.abc() new Does this mean that when modify the metaclass by setting it to closure, it doesn't really replace it but just adds another method it can call, thus resulting in metaclass having two methods? Is it possible to truly replace the method so the second line of output prints "new"? When trying to figure it out, I found that DelegatingMetaClass might help - is that the most Groovy way to do this?

    Read the article

  • Mock Assertions on objects inside Parallel ForEach's???

    - by jacko
    Any idea how we can assert a mock object was called when it is being accessed inside Parallel.ForEach via a closure? I assume that because each invocation is on a different thread that Rhino Mocks loses track of the object? Pseudocode: var someStub = MockRepository.GenerateStub() Parallel.Foreach(collectionOfInts, anInt => someStub.DoSomething(anInt)) someStub.AssertWasCalled(s => s.DoSomething, Repeat.Five.Times) This test will return an expectation violation, expecting the stub to be called 5 times but being actually called 0 times. Any ideas how we can tell the lambdas to keep track of the thread-local stub object?

    Read the article

  • Server returned HTTP response code: 500 for URL

    - by user617162
    java.io.IOException: Server returned HTTP response code: 500 for URL: http://ww .huadt.com.cn/zh-cn/i/l/@357671030745308@V500@0000@AUTOLOW@1@11d590f7$GPRMC,065 48.000,A,3959.8587,N,11617.2447,E,0.00,55.32,210311,,,A*56@@ at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown S urce) at hdt.SendCmdToP.Sendplatform(SendCmdToP.java:67) at hdt.SendCmdToP.process(SendCmdToP.java:198) at hdt.SendCmdToP.run(SendCmdToP.java:131) java.lang.NullPointerException at hdt.SendCmdToP.Sendplatform(SendCmdToP.java:91) at hdt.SendCmdToP.process(SendCmdToP.java:198) at hdt.SendCmdToP.run(SendCmdToP.java:131) Appeared pointer, and 500 wrong with the closure of the abnormal, a firewall relationship? If not is it code problems? Please help everybody see how to solve the problem. thanks?

    Read the article

  • Do Any Client-Side JavaScript Frameworks Integrate Well With Node.js+Express.js+socket.io.js?

    - by Tom D
    I'm building an webapp using Node.js+Express.js+socket.io.js on the backend. Do any of the popular front-end frameworks (Agility, Angular, Backbone, Closure, Dojo, Ember, GWT, jQuery, Knockback, Knockout, Spine, YUI, etc) integrate well with this backend for "real-time" applications? I want my application to have a very "real-time" feel. Specifically, when a user submits a form I want the information to be sent using web sockets to the backend for validation and (if validation passes) to be updated in the database. Then, the server-side will use web sockets to send a confirmation that the data was saved or some list of errors. I will use the server's response to update the page using JavaScript. I know all this can be done with any of the listed frameworks. I'm interested in features of particular frameworks that will help the framework integrate better with the Node-based backend than the other frameworks.

    Read the article

  • Where to learn about VS debugger 'magic names'

    - by Gael Fraiteur
    If you've ever used Reflector, you probably noticed that the C# compiler generates types, methods, fields, and local variables, that deserve 'special' display by the debugger. For instance, local variables beginning with 'CS$' are not displayed to the user. There are other special naming conventions for closure types of anonymous methods, backing fields of automatic properties, and so on. My question: where to learn about these naming conventions? Does anyone know about some documentation? My objective is to make PostSharp 2.0 use the same conventions. Thank you!

    Read the article

  • Why calling ISet<dynamic>.Contains() compiles, but throws an exception at runtime?

    - by Andrey Breslav
    Please, help me to explain the following behavior: dynamic d = 1; ISet<dynamic> s = new HashSet<dynamic>(); s.Contains(d); The code compiles with no errors/warnings, but at the last line I get the following exception: Unhandled Exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Collections.Generic.ISet<object>' does not contain a definition for 'Contains' at CallSite.Target(Closure , CallSite , ISet`1 , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1) at FormulaToSimulation.Program.Main(String[] args) in As far as I can tell, this is related to dynamic overload resolution, but the strange things are (1) If the type of s is HashSet<dynamic>, no exception occurs. (2) If I use a non-generic interface with a method accepting a dynamic argument, no exception occurs. Thus, it looks like this problem is related particularly with generic interfaces, but I could not find out what exactly causes the problem. Is it a bug in the compiler/typesystem, or legitimate behavior?

    Read the article

  • Lifetime of javacript variables.

    - by The Machine
    What is the lifetime of a variable in javascript, declared with "var". I am sure, it is definitely not according to expectation. <script> function(){ var a; var fun=function(){ // a is accessed and modified } }(); </script> Here how and when does javascript garbage collect the variable a? Since 'a' is a part of the closure of the inner function, it ideally should never get garbage collected, since the inner function 'fun', may be passed as a reference to an external context.So 'fun' should still be able to access 'a', from the external context. If my understanding is correct, how does garbage collection happen then, and how does it ensure to have enough memory space, since keeping all variables in memory until the execution of the program might not be tenable ?

    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

  • Create LINQ to entities OrderBy expression on the fly

    - by AyKarsi
    I'm trying to add the orderby expression on the fly. But when the query below is executed I get the following exception: System.NotSupportedException: Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context. The strange thing is, I am query exactly those primitive types only. string sortBy = HttpContext.Current.Request.QueryString["sidx"]; ParameterExpression prm = Expression.Parameter(typeof(buskerPosting), "posting"); Expression orderByProperty = Expression.Property(prm, sortBy); // get the paged records IQueryable<PostingListItemDto> query = (from posting in be.buskerPosting where posting.buskerAccount.cmsMember.nodeId == m.Id orderby orderByProperty //orderby posting.Created select new PostingListItemDto { Set = posting }).Skip<PostingListItemDto>((page - 1) * pageSize).Take<PostingListItemDto>(pageSize); Hope somebody can shed some light on this!

    Read the article

  • Usage of closures with multiple arguments in swift

    - by Nilzone-
    This question is largely based on this one: Link The main difference being that I want to pass in arguments to the closure as well. Say I have something like this: func someFunctionThatTakesAClosure(completionClosure: (venues: Dictionary<String, AnyObject>, error: NSError) -> ()) { // function body goes here var error: NSError? let responseDictionary: Dictionary<String, AnyObject> = ["test" : "test2"] completionClosure(venues: responseDictionary, error: error!) } No error here. But when I call this function in my main view controller I have tried several ways but all of the result in different errors: venueService.someFunctionThatTakesAClosure(completionClosure(venues: Dictionary<String, AnyObject>, error: NSError){ }) or like this: venueService.someFunctionThatTakesAClosure((venues: Dictionary<String, AnyObject>, error: NSError){ }) or even like this: venueService.someFunctionThatTakesAClosure(completionClosure: (venues: Dictionary<String, AnyObject>, error: NSError) -> (){ }); I'm probably just way tired, but any help would be greatly appreciated!

    Read the article

  • Why are closures broken within exec?

    - by Devin Jeanpierre
    In Python 2.6, >>> exec "print (lambda: a)()" in dict(a=2), {} 2 >>> exec "print (lambda: a)()" in globals(), {'a': 2} Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1, in <module> File "<string>", line 1, in <lambda> NameError: global name 'a' is not defined >>> exec "print (lambda: a).__closure__" in globals(), {'a': 2} None I expected it to print 2 twice, and then print a tuple with a single cell. It is the same situation in 3.1. What's going on?

    Read the article

  • VS 2010 / Resharper 5 Mouse Behavior

    - by Berryl
    After upgrading to the above configuration I notice that 1) CTRL-Click on a type highlights the type but doesn't take me to the declaration, 2) Clicking on some closure (ie, like a method) toggles whether it's expanded or collapsed. Since these are both mouse related tasks I figure there is some setting in either VS or R# that I need to change, but I sure can't figure out what it is. Anybody know? Cheers, Berryl PS - there is an option in R# to ctrl-click to the type but I have that checked and it still does not work.

    Read the article

  • What are the benefits and risks of moving to a Model Driven Architecture approach?

    - by Tone
    I work for a company with about 350 employees and we are in the process of growing. Our current codebase is not structured very well and we are looking both at how to improve it immediately (by organizing objects into namespaces, separating concerns, etc.) and moving to a model driven architecture approach, where we model and design everything first with uml, then generate code from that model. We have been looking heavily at Sparx Systems Enterprise Architect (EA) (which is UML 2.0 capable) and we are also considering the tools in VS 2010. I know there are other tools out there (Rational XDE being one) but I really do not think we can spend $1500+ per license at this point. I'm not looking for answers on which tool is better than another but more for experiences moving from a cowboy coding environment (that is, little planning and design, just jump in and start coding) to a model driven architecture. Looking back was it helpful to your organization? What are the pain points? What are the risks? What are the benefits?

    Read the article

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