w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Removing smart quotes from an SQL server text column
If the data type is in fact of TEXT, first cast the column to VARCHAR(MAX) like this: SELECT [COLUMN] FROM [TABLE] where CAST([COLUMN] AS VARCHAR(MAX)) like '%['+char(226)+']%' SELECT [COLUMN] FROM [TABLE] where CAST([COLUMN] AS VARCHAR(MAX)) like '%['+char(8364)+']%' SELECT [COLUMN] FROM [TABLE] where CAST([COLUMN] AS VARCHAR(MAX)) like '%['+char(381)+']%' SELECT [COLUMN] FROM [TABLE] where CAST([COLUMN] AS VARCHAR(MAX)) like '%['+char(8206)+']%'

Categories : Sql Server

Issue in understanding the Spring Bean Scopes Vs Spring web flow Session Scopes
You are confusing yourself with objects and beans. For each request, will it create a new Student Object or Spring container will create only once? The functioning of Spring is purely using beans. When you declare a something like a @Component, it's just an annotation that tells Spring that the part you've declared as a component is either Model or View or Controller i.e. a component of MVC. When you say something like @Scope=singleton, it tells Spring that only a single object instance can access the bean. Let me make it more clear. Say you and I are objects and a strawberry candy is a bean. So if you have the candy. I cannot take it from you. Meaning only one of us can have that candy. It's the same thing with singleton scope. Hope I made things simpler.. :)

Categories : Spring

Scopes in asp.net?
ASP.NET has the same: Application, Session and Request. Read more here: Page and Application Context in ASP.NET Web Applications. What do you mean by different? I think they are quite similar.

Categories : Java

jsp scopes of PagesContext
This parameter is not an enumeration, but a a plain int. PageContext.APPLICATION_SCOPE and so on are constants (public static final int) variables inside PageContext. The full set of values can be found in these links: J2EE 1.4: http://docs.oracle.com/javaee/1.4/api/javax/servlet/jsp/PageContext.html Java EE 5: http://docs.oracle.com/javaee/5/api/javax/servlet/jsp/PageContext.html Java EE 6: http://docs.oracle.com/javaee/6/api/javax/servlet/jsp/PageContext.html Java EE 7: http://docs.oracle.com/javaee/7/api/javax/servlet/jsp/PageContext.html I don't see a reason to set the same value in different scopes. If you need a global value (to the entire application) you will use application scope don't you? If you set the same thing in different scopes, you will need to reset the same value lo

Categories : Jsp

Scopes and @PostConstruct
Running your initialization code under 'preRender' every time, is probably not correct. Since initialization will wipe out the data you want. Separate your preRender from your initialization. You can either hook them separately, or have a flag to only call initialize() once. Avoid Session-scoped beans if possible; session-scoping is the mark of badly-designed web applications and (in it's simplest forms) a very bad way to implement inter-page flow. Pass URL or POST parameters between web pages to implement flow. If necessary, the inter-page parameters can be unique handles to objects stored in the HttpSession. But don't just dump stuff into the Session without it either being genuinely global to the application (such as "loggedInUser") or referenced by a uniquely-allocated handle.

Categories : JSF

Rails Cocoon: Removing a child without removing the parent (Deeply Nested Forms)
I was able to fix this problem in my project by using the wrapper-class option in link_to_remove_association. I used a div in the child partial as the wrapper. So see if changing _property_template_options to <div class="myclass" > <li style='padding-left:35px;'><%= f.input :value, :label => 'Field Option' %></li> <li style='float:right;'><%= link_to_remove_association "Remove Option", f, { wrapper_class: "myclass" } %></li> <%= f.hidden_field :position %> </div> or something similar resolves the problem.

Categories : Ruby On Rails

Understanding scopes in Ruby
See the reason :- class ScopeTest attr_accessor :flag def flagtest p defined?(flag) if flag == 1 p defined?(flag) flag = 0 p defined?(flag) self.flag = 0 flagtest else p defined?(flag) end end end st = ScopeTest.new st.flag = 1 output "method" "method" "local-variable" "method" "local-variable"

Categories : Ruby

How does pickling works in different scopes?
You are tying to use pickle.load() on a file that is opened for appending, not for reading. Besides, your function openFile() does basically the same as open(). My suggestion: import pickle def writeScore(file_, score): """Write score to file.""" try: cache_file = open(file_, 'rb') except IOError: open(file_, 'a').close() cache_file = open(file_, 'rb') try: highScores = pickle.load(cache_file) highScores.append(score) highScores.sort() except EOFError: highScores = [score] finally: cache_file.close() writing_file = open(file_, 'wb') pickle.dump(highScores, writing_file) writing_file.close() def displayScores(file_): """Display score from file.""" cache_file = open(file_, 'rb'

Categories : Python

Rails scopes for even and odd record IDs
If getting records by odd and even ids is really what you want to do, then your solution is fine. AFAIK there isn't a shortcut for it, because it isn't often done. One thing you should consider is that the columns may become unbalanced once you start deleting records. That might not be a concern for you, though.

Categories : Ruby On Rails

What exaclty are scopes in devise?
Devise allows you to separate your users into different "scopes" such as "admin" and "member", the effect of this is that you get a set of routes, controllers and views for each scope. A user can belong to multiple scopes and sign in to any/all of them at any time - so when the option sign_out_all_scopes is true, signing out as any scope will sign out all of that users currently signed in scopes. Regarding your specific question - why are you defining your own sign out method? Devise provides one for you. If you want to modify the sign out method make sure you follow the instructions for properly extending the devise controllers.

Categories : Ruby On Rails

Why does Facebook login ask for different (more) scopes?
You are doing nothing wrong, the message App_name would like to access your public profile, friend list appears along with your permission because Facebook adds the basic Public Profile and Friend List permission to all the apps as a default, even if you are not asking for any permissions. And you cannot stop Facebook from adding these basic permissions so that you may have permission request like App_name would like to access your photos. Edit: if you request permission without defining any scope, accept it, then request another one with scope=user_photos, then it will just say App_name would like to access your photos.

Categories : Facebook

Spring Bean Scopes
From the spring specs, there are five types of bean scopes supported : 1. singleton(default*) Scopes a single bean definition to a single object instance per Spring IoC container. 2. prototype Scopes a single bean definition to any number of object instances. 3. request Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext. 4. session Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext. 5. global session Scopes a single bean definition to the

Categories : Java

Set ActiveRecord Scopes In A Loop
Try this in ruby 1.9 Status.each do |status| scope status, -> { where(status: status) } end or in previous ruby versions Status.each do |status| scope status, lambda { where(status: status) } end -- EDIT -- I guess your problem is somewhere else, since this code is working for me: class Agency < ActiveRecord::Base attr_accessible :logo, :name validate :name, presence: true, uniqueness: true NAMES = %w(john matt david) NAMES.each do |name| scope name, -> { where(name: name) } end end I can create new models just fine and use the scopes irb(main):003:0> Agency.new => #<Agency id: nil, name: nil, logo: nil, created_at: nil, updated_at: nil> irb(main):004:0> Agency.matt Agency Load (0.5ms) SELECT "agencies".* FROM "agencies" WHERE "agenc

Categories : Ruby On Rails

What scopes exist in spring mvc?
• Singleton: This scopes the bean definition to a single instance per Spring IoC container (default). • Prototype: This scopes a single bean definition to have any number of object instances. Message aMessage; //object // singleton bean scope aMessageA = new Message(); aMessageA = (Message) applicationContext.getBean("message"); aMessageA.setText("message1 :D"); System.out.println(aMessageA.getText()); aMessageB = new Message(); aMessageB = (Message) applicationContext.getBean("message"); System.out.println(aMessageB.getText()); // result will be the same for both objects because it's just one instance. // Prototype bean scope. scope="prototype" aMessageA = new Message(); aMessageA = (Message) applicationContext.getBean("message"); aMessageA.setText("message :D"); System.out.p

Categories : Java

Refactoring has_many with scopes
There's nothing inherently bad with conditions in your associations, specially if you need to eager load a subset of products. However to achieve the scope you need, you must add it on the Product model and resort to plain sql since the filter is applied on a different model than the one it's defined on. class Product # not tested scope :wanted, ->{ where("ownerships.owning_dates IS NULL AND ...") } end IMHO you're better off with the first solution. The reason is, if for some reason you apply that scope inside a block of many users, you'll hit the O(n) wall despite eager loading the products. User.includes(:owned_products).each do |user| user.onwned_products.wanted # => SQL connection end Update : just found out about merge an amazingly undocumented feature of Activ

Categories : Ruby On Rails

Performance in different variable scopes?
I have converted this to use the STDLIB benchmark and got this result require 'benchmark' iterations = 10 ** 7 $global = 0 local = 0 @instance = 0 Benchmark.bmbm(8) do |x| x.report('global') {iterations.times { $global } } x.report('local') {iterations.times { local } } x.report('instance') {iterations.times { @instance } } end The results: Rehearsal -------------------------------------------- global 1.580000 0.010000 1.590000 ( 1.600952) local 1.540000 0.000000 1.540000 ( 1.555683) instance 1.600000 0.000000 1.600000 ( 1.642781) ----------------------------------- total: 4.730000sec user system total real global 1.560000 0.000000 1.560000 ( 1.575711) local 1.540000 0.000000 1.540000 ( 1.547040) insta

Categories : Ruby

Rails named scopes
Until Rails 4 you should use scoped method if you want to have ActiveRecord::Relation instance (on which you can call other scopes) returned instead of Array: @all_courses = Course.scoped @specific_course = @all_courses.specific_course_scoped This should work. If you want to use includes(:courses), you just do it, for example with: @specific_course = @all_courses.specific_course_scoped.includes(:courses)

Categories : Ruby On Rails

Dagger custom scopes, how to?
Dagger doesn't do scope using the same sort of mechanism that Guice does. Dagger, specifically, does not transparently handle scope the way Guice does, with various scoping annotations, one Injector, and different instance caches behind the scenes. Instead, it uses two principles. First, that @Singleton means "one per graph" (the strictest interpretation of JSR-330) and, secondly, that graphs can be linked in a hierarchy. Dagger uses this tree of hierarchically linked graphs, where you create a graph by adding more modules and extending it via the plus() method, to create a "scoped" graph which can be of a shorter lifetime. This similar to Child Injectors in guice. An important principle here is that instances in the extended graph can see instances in the originating graph, but not

Categories : Java

Filtering using Scopes in rails
All of the filter inputs you are submitting have the same parameters key, brand. So, the parameters hash can only have one value for that key. You want to use a check_box_tag instead for 'brand_ids[]': <%= check_box_tag 'brand_ids[]', brand.id, false, class: 'filter_check_box' %> Finally, and this is important, you cannot send an array to the parameters via a GET action. You will need to use a POST. As the second link below notes, this is a limitation of HTTP, not Rails. See also: Select checkbox pass array in ruby on rails Passing array of parameters through get in rails Aside I would humbly recommend you refer to variables with more consistent names, for ease of readability and maintenance of code. If you're using a brand_id, as in that Product scope, call it a brand_i

Categories : Ruby On Rails

Type Error when removing a child and removing it from an array
First in the second loop I think you want to remove spartans[spcount] So change this line removeChild(spartans[bcount]) To removeChild(spartans[spcount]) Second In the second loop you should check if bcount is less than zero. Because in the first loop and second loop, you both reduce bcount, so bcount could be -1. For example, bullets[0]'s x is bigger than 1055, so bcount would be -1. And if this not happen, in the second loop, if the collisions happen in some times, bcount will be less that 0.

Categories : Actionscript

Access token doesn't contain any scopes
Replace the code under response.status === 'connected' with this. Remove all other parts in the original code where the scope was added. (you only have to add it here) if (response.status === 'connected') { // The response object is returned with a status field that lets the app know the current // login status of the person. In this case, we're handling the situation where they // have logged in to the app. if(accessToken) { // alert("Connected WITH accesToken"); testAPI(); } else{ // alert("Connected WITHOUT accesToken"); FB.login(function(response) { // handle the response uid = response.authResponse.userID; accessToken = response.authRe

Categories : Facebook

Jquery UI draggable and droppable - scopes
See this FIDDLE Basically, you can only have one scope easily. However, the drop method of droppable allows you access to the element being dragged by passing in 2 properties, event and ui. so if you only use one drop function and change it to : $('ol li').droppable({drop: function(event, ui){ alert($(ui.draggable).prop('id'));}}) you can see whichever draggable is dropped has its id alerted. You can pretty much then do whatever you need to do by putting data-props or whatever on each draggable element and accessing them with: $(ui.draggable)._jquery-method_();

Categories : Jquery

Returning values between different scopes in javascript
This has nothing to do with scope, it is about timing. readdir is asynchronous. It sends off the request to the filesystem and then lets the previous function carry on. console.log(b); executes before b=self.loader() does. If you want to work with data from a function that takes a callback, you need to perform that work inside the callback.

Categories : Javascript

node js - understanding variable scopes
I am trying to understand the scope of the counter variable - Will it be different for every client or will it be common across clients. It will be common across clients since you are defining it globally. Also, I am looking for a way to increment counter for the same client, so in other words, I'd like a counter for each visiting client. Basically what you need to do is to listen on connection & disconnection of every client and save the counter in the respective client object. Have a look at this implementation it may help you.

Categories : Javascript

Accessing variables across different scopes in Javascript & YUI 3
It might not be the "best" way to do it, but one way would be to define the treeview variable in a scope that is available in both places. YUI.add('treetool.TreeView', function(Y) { var treeview; //... and treeview = new Y.TreeView({ // removed "var "

Categories : Javascript

Multiple AngularJS directives with different scopes
In order to make sure each of your directive as a different scope, you could add a scope : true to the object returned by your directive function. You should definitely check out the documentation ("Writing directives (long version)"), it explains the power of the scope attribute, how to isolate the scope, bind arguments, etc... This stackoverflow question provides an even better explanation.

Categories : Angularjs

How to apply scopes to joins in rails?
I'd try to write Budget.joins(:forfeitures).merge(Forfeiture.between(from, to)) So, merge method should work for you. I'd suggest you to watch episode 215 and episode 239 from railscasts.com

Categories : Ruby On Rails

Wcf with SimpleInjector throws "WCF scopes can not be nested"
This is a known problem with Simple Injector 2.2.3 for some WCF configurations. Some WCF configurations force a second call to IInstanceProvider.GetInstance. The SimpleInjectorInstanceProvider.GetInstance methods call into the internal BeginScope method, which is limited to one scope. There are two solutions: First solution is to upgrade to the latest Simple Injector WCF Integration package. The 2.3.0 release of the WCF integration package fixed this issue. Second solution is to not use the Per WCF Operation at all, but use the lifetime scope (which works similar as the Per WCF Operation lifestyle). This is especially a good solution in your case, since you use command handlers and query handlers. In other words, your WCF service will probably consist of just two WCF operations. This ma

Categories : Wcf

Add scopes to authentified oAuth2 user
HWIOAuthBundle requests only "https://www.googleapis.com/auth/userinfo.profile" scope by default. In order to manage user's Google Calendar, you want to request "https://www.googleapis.com/auth/calendar" scope too. Check this out on how to customize the scope you request: https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/resource_owners/google.md

Categories : Symfony2

AngularJS: rootScope in directives scopes
scope: true not isolated, not shared, but a new prototipically inherited scope per directive instance. http://jsfiddle.net/4LAjf/1 You can log the id of the scope with console.log(scope.$id). With scope: {} you'll get, for example, 003 and 004. With scope: false (or nothing), the scope is shared, e.g. both have 002. With scope:true they have different id's but can read $rootScope. In the live example you can see the scope ID in your local variable localName. I named the dummy directive mydir instead of module. It just looks weird naming module a directive. More about AngularJS scopes

Categories : Angularjs

Independent scopes for similar controllers in Angular
You can see a modified plnkr that works as you described here. Personally, I would restructure the architecture of the app and rethink the styleFactory implementation. Some points for thought: data = {"style":"color:"+color} replaces the whole data object, thus $scope.data = styleFactory.getData() works only for the last controllerA as the reference is lost for all others. Try creating a parent controller that will be on top of controllerA and controllerB. Try solving this problem using directives.

Categories : Angularjs

Difference between Static variable declared in different scopes
static int a; means the variable a is a file scope variable, i.e, it can't be seen from other files. void getVol(..) { static int b; } means the local variable b has a life cycle that goes from the program starts to the program ends, i.e, you can assign it some value, while on the next call of the function, it remembers that value. c and d are similar to b.

Categories : C++

Angular.js nested Controller $scopes must be predefined?
Because in the first case, you access $scope.forms via reference value (both controllers point to the same value in memory), and in the second case you just create a boolean primitive in the child controller, in which case the parent is completely unaware of it (and vice versa).

Categories : Angularjs

What about variable scopes inside a callback function
Why is this? It is not. You can simply access something, it is in the scope of the load function that you posted. What am I doing wrong!? You're not passing the load function itself as the callback, but it's result - you're immediately calling it (without arguments). You want $('#' + locatie).hide(effectout, optionsout, timeout, load); // ^^ //It seems I can't reach html and other variables here console.log(this.html); That's not a variable, that's a property of this (and the this keyword points to different things in the different calls). What you want is a simple variable: console.log(html); Same story for this.locatie and the others.

Categories : Javascript

is there a deep dive on google's oauth2 scopes?
List of scopes in your client code - this is what a user authorizes your app to do When you request authorization from a user, you need to specify what you would like the user to consent to. This is what the list of scopes is used for - it controls the text the user sees when they authorize your application, and the refresh / access tokens granted by that authorization are limited to making API calls that are allowed by those scopes. List of enabled services in the API Console - this is what your app authorizes users to do To my knowledge there is no list of scopes specified in the API Console. There is however a list of Google services that can enabled. Enabling/disabling a service here is more about turning on/off ability to make API calls and managing quota and/or accepting terms

Categories : Misc

Rails joining same table twice under different dynamic scopes
I agree with @zapico - use scopes. And you must use Lambda because List.good_list_ids and List.bad_list_ids are dynamic. #Book.rb has_many :lists scope :good_lists, -> { joins(:lists).where('lists.id IN (?)', List.good_list_ids) } scope :bad_lists, -> { joins(:lists).where('lists.id IN (?)', List.bad_list_ids) } Update now you can get books which are in these lists # in bad list Book.bad_lists # in good list Book.good_lists # in both lists (this is intersection! for these lists) Book.bad_lists.good_lists If you would like to have records belong to good_list OR bad_list then it seems to me the easiest way is # join arrays scope :good_bad_lists, -> { joins(:lists).where('lists.id IN (?)', List.good_list_ids | List.bad_list_ids) }

Categories : Mysql

how to individually call search scopes in spree
To do what you want. Take a look at the method add_search_scope. This method is defined in the file below https://github.com/spree/spree/blob/master/core/app/models/spree/product/scopes.rb This allows you to create the scope and register it as a search_scope (which is causing you problems)

Categories : Ruby On Rails

How to handle different Ninject scopes for shared library?
I would suggest to create a new project like NinjectModules. Move declaration of bindings into separate modules like WinAppModule, MvcModule and put it into NinjectModules project. Then reference NinjectModules from win app project and mvc project. They won't need to reference EF and System.Web anymore. UPDATE You can see my answer on similar question.

Categories : Asp Net Mvc

AngularJS - Transcluded scope with child scopes
http://plnkr.co/edit/F1e1mKA2UU3EL1M9yaJ0?p=preview This is what I tried to achieve it with usage of directive controller and letting child directive update the value in the parent directive though its controller. I'm upvoting this question as I'm not satisfied and want to see the better solution.

Categories : Javascript

understanding click(),change() and inputs scopes
I have added some explanation with the code.. $('.myOptions').change(function () { // Remove the active class $('.list').removeClass('active'); // Add the active class // this.value holds the current value that is selected // No need to use filter $('.' + this.value).addClass('active'); }); $('#butt').click(function () { // Better to have Lesser variables , var active = $('.list.active'), $boxOne = active.find('.box1'), $boxTwo = active.find('.box2'), $boxThree = active.find('.box3'), $output = $('#output'), total = (parseInt($boxOne.val(), 10) + parseInt($boxTwo.val(), 10) + parseInt($boxThree.val(), 10)), msg = ''; $output.addClass('error'); var dropdownValue = $('.myOptions').val(), //

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.