w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Can I remote debug tomcat running in intelliJ from a different instance of intelliJ?
IntelliJ is probably adding his own -Xrunjdwp: argument to attach his agent. If you look at the first line in your debug console, you will see the command IntelliJ has built. JDWP support only one debugger at the time. You'll have to choose between the two. Running the command outside of IntelliJ should fix this problem.

Categories : Tomcat

How do you make instance variable in a controller and use the instance variable in the view?
1) Why are you checking if File.exists? You just globbed the directory, so each item in the results does in fact exist. 2) I want to store the @type of only empty directories. @empty_dir_types = [] ... fname = "...." if Dir.entries(fname).empty? @empty_dir_types << File.basename fname end Or, @type = params[:type] @empty_dir_types = [] ... fname = "...." if Dir.entries(fname).empty? @empty_dir_types << @type end Or, @type = params[:type] @empty_dir_type = nil fname = "...." if Dir.entries(fname).empty? @empty_dir_type = @type end

Categories : Ruby On Rails

Trace and log values of a variable with GDB
You can set a breakpoint command to run when your watchpoint hits; have it log and execute a continue command to let the program keep running.

Categories : C

Pass in an instance variable to a static method -- and modifies another instance variance?
Am I correct in saying that it is impossible for the other HashMap to be modified by foo as a result of just this one method call? Answer is may be. It is true that if you dont pass the reference of a object to method, you can not access it. But Map stores key-value Object pair refernece, it does not store the Objects, if both map share Object as key or value, then it would effect.

Categories : Java

Does python allow calling of an instance variable name from an instance method?
globals() return a dictionary that represents the namespace of the module (the namespace is not this dictionary, this latter only represents it) class A(object): def get_instance_name(self): for name,ob in globals().iteritems(): if ob is self: return name obj = A() print obj.get_instance_name() blah = A() print blah.get_instance_name() tu = (obj,blah) print [x.get_instance_name() for x in tu] result obj blah ['obj', 'blah'] . EDIT Taking account of the remarks, I wrote this new code: class A(object): def rondo(self,nameinst,namespace,li,s,seen): for namea,a in namespace.iteritems(): if a is self: li.append(nameinst+s+namea) if namea=='__builtins__': #this condition prev

Categories : Python

Automatic variable expansion in IntelliJ
Rumel, welcome to the java world, and this one is easy... First, type the method name (start typing it and use Ctrl+Space to autocomplete, if you like...) newStringList() With your cursor still on the method, or the parenthesis, now hit Ctrl+Alt+V (refactor: Introduce Variable) and type the variable name you want (instead of the default, which is strings). List<String> strings = newStringList(); Good luck!

Categories : Java

Using descriptor to access variable instead of binding this variable with the target in the instance
It makes db read-only. You cannot set base_handler.db, there is no setter associated with the property: >>> class Foo(object): ... @property ... def bar(self): return 'spam' ... >>> foo = Foo() >>> foo.bar 'spam' >>> foo.bar = 'ham' Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: can't set attribute You'd need to add a setter for it to be writable: class Foo(object): _bar = 'spam' @property     def bar(self): return self._bar @bar.setter def bar(self, value): self._bar = value Note the @name_of_property.setter decorator; the property object itself gives you a decorator function to create a new decorator with the setter replaced with the new decorated f

Categories : Python

Accessing value of local variable for an instance variable in java
while(x < amount) will return false, since both x and amount are 0 at the beginning, so amount will always keep 0 value. Why not just doing amount = items ? Your startup method would look like this.- public void startup(int Items) { amount = Items; } By the way, following java naming conventions, Items should be called items, camelCase.

Categories : Java

Difference between Ruby's class variable and instance variable
i don't think there is a distinct difference between class variable and instance variable. No there is a subtle difference. As Wayne Conrad states in his answer here: A class variable (@@) is shared among the class and all of its descendants. A class instance variable (@) is not shared by the class's descendants. @@ : class variable( I will recommend the use of class instance variable instead. of saying class variable,which will reduce confusion,that newbie people generally did.) class Foo;end #setting class variable @@var Foo.class_variable_set(:@@var, "good morning!") #getting class variable @@var via Foo Foo.class_variable_get(:@@var) # => "good morning!" class Bar < Foo ;end #getting class variable @@var via Bar subclass of Foo Bar.class_variable_get(:@@var) # =&

Categories : Ruby

Class variable Vs. Instance variable in python for int value
In the first example, self.d = self.d + 1 rebinds self.d, making it independent of test.d. In the second example, self.d.append("1") modifies test.d. To see that for yourself, print id(self.d) at the end of both constructors. If you modified the second example to match the first: self.d = self.d + ["1"] you'd see that the behaviour would also change to match.

Categories : Python

How to make the variable available without creating instance variable
Perhaps I don't understand your question, but if this really is a class and the methods in A are really instance methods, then there's really nothing inherently wrong with storing a1 in an instance variable and referencing it from call_c. BTW, I'm assuming that 1_function, 2_function and call_c are all supposed to be method names, the illegal syntax of the former two notwithstanding.

Categories : Ruby On Rails

multiple instance can't use the same variable, variable not changing
You have this code: camera = getInformation(camera); displayInfo(); camera2 = getInformation(camera2); displayInfo(); Here your method displayInfo() is not really taking any argument and printing information from camera object both the times it is called. Even though you are getting reference of camera2 object in second call of getInformation you aren't really printing it. You can declare displayInfo like this: public static void displayInfo(DigitalCamera camera) { //users the getters to pull the values //the price is calculated using an if statement System.out.println("Brand: " + camera.getBrand() + " " + "Megapixels : " + camera.getMegaPixels() + " " + "Price : $" + camera.getPrice() + " "); }

Categories : Java

Intellij Code Completion for all setter/getter methods of local variable object
In your project, right-click anywhere on the typing screen, and click 'Generate...' and then 'Getter and Setter'. Then, hold down Ctrl and click on the fields you wish to create getters and setters for, then click on 'OK'.

Categories : Java

e/trace : error opening trace file: No such file or directory (2)
To open a file in your raw folder, yo can try this: InputStream is = ctx.getResources().openRawResource(R.raw.katadasar); InputStreamReader isr = new InputStreamReader(is); Also, you should change the code in your catch from what you have: catch (Exception e) {//Catch exception if any System.err.println("Error: " + e.getMessage()); } to this, to print the correct error: catch (Exception e) {//Catch exception if any Log.e("YourTag", "Error:" + e.getLocalizedMessage() ); } Try the above code (with the corret error logcat output) and if it does not work, please update the logcat output to try to locate the error

Categories : Android

IntelliJ Play2 and Scala plugins are not compatible. Makes IntelliJ 12 no longer work as expected
Use the IntelliJ sbt plugin and compile your classes from sbt with "~compile". You can start play with "container:start". Here is my own Build.scala file I run from within IntelliJ: import sbt._ import Keys._ import play.Project._ object ApplicationBuild extends Build { val appName = "Blade_Night_App" val appVersion = "1.0-SNAPSHOT" val appDependencies = Seq( // Add your project dependencies here, jdbc, anorm ) val main = play.Project(appName, appVersion, appDependencies).settings( // Add your own project settings here ) } And here the plugins.sbt: // Comment to get more information during initialization logLevel := Level.Warn // The Typesafe repository resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releas

Categories : Scala

If there is one instance of a class with variable=x
If you don't want to iterate like this, then probably the best thing to do is carry an external count of those classes that are "fat". Normally you would do this a static variable in the class and you should increment the count in the setter for that variable. public class Dude{ static int nFats = 0; public void setFat(){ Dude.nFats++; } } If you wanted to be safer (and probably more correct in this case) you could also use an AtomicInteger which is specifically designed for threadsafe counters.

Categories : Java

How to set an instance variable within a decorator?
You've made Salary.basic into a property, and Salary.basic() has side effects! So every time your other functions reference self.basic, it recalculates and resets self.RemainingAmount to its original value, self.grossPay - basic. Properties with this kind of side effects are bad design. I hope you see why now. Even after you fix this, accessing your other properties in different order will give you different results. Property accessors should not have durable side effects. More generally: Setters must set, getters must get. Properties look like simple variables, so they must behave accordingly or you'll never be able to understand or debug your code again.

Categories : Python

PHP - Global/Instance Variable
This works using the DependencyInjection component. DI is what you're looking for! When using symfony2 standard if you extend ContainerAwareCommand - symfony will inject the container automatically ... use SymfonyBundleFrameworkBundleCommandContainerAwareCommand; class MyCommand extends ContainerAwareCommand .. configure container-parameters in parameters.yml or config.yml parameters: my_parameter: my_value then access your container-parameters using $this->container->getParameter('my_parameter') This way you can access those parameters from any "service" in your application as long as you have access to the container. You can even inject only the parameters which is advised as injecting the whole container is costly in terms of performance and makes testing harder.

Categories : PHP

as3 what is the difference between the variable name and the name of an instance?
The instance name is a way of referring to the movieclip. The variable is the way to access functions, variables applicable to that movieclip. var currentTile:MovieClip = this.getChildByName("MyClip") as MovieClip; currentTile.someFunction(); From here you can manipulate the movieclip. If you created a variable, private to the chapter1 class, you would not have to name the movieclip as the scope of the variable would cover all the code in the class. When you add a movieclip to the stage at design time, it seems to me flash assigns a variable called 'instancex' and names it 'instancex'. When you name it, it changes the names. There is also no need to name the movieclip if the variable is within the scope of your code or if you dont have to refer to it at a later stage. Another way of l

Categories : Actionscript

Objective-C: Instance variable used while 'self' not set... but it is
Do not use -> to access instance variables, especially when the ivar is from some other object. Do this: _buffer = [[attr string] mutableCopy]; Same goes for that nasty attr->_attributes. Apparently, ZAttributedStringexposesattributes` as a property in the private header. That compiler warning does seem, at the very most optimistic, entirely misleading and, likely, quite wrong in description. Filing a bug to have that clarified would be useful. Note that @maddy's claim that using -> to access the instance variables directly in the attr string passed as it acts like a copy constructor is incorrect. The incoming attr may be a ZAttributedString instance or an instance of a subclass or, really, an instance of any class that implements the same interface as ZAttributedStr

Categories : Objective C

Instance variable always returning zero
Call [tableView reloadData] after NSLog(@"Frequencies count: %lu", (unsigned long)[arrayofFrequencies count]);//the count here is correct, I have data in the array Point to understand is in viewDidLoad tableView delegates are called. At that time array count is zero. Later array is filled with object. reloadData method call delegate method of table again.

Categories : IOS

Get the variable map from process instance
Have a look at org.activiti.engine.RuntimeService.getVariable*(*), it gives you access to all process instance variables. Of course you need an execution ID in order to identify the process instance. If this is not what you are looking for, please refine your question.

Categories : Java

get a instance variable from another class?
I would suggest you should add readonly properties to access those instance variables. @property (nonatomic,assign,readonly) CCSprite *enemy1; @property (nonatomic,assign,readonly) CGSize winSize;

Categories : Objective C

Accessing instance variable or local var
I guess the second approach is ever-so-slightly faster because in the second case the run time will not have to perform a arr.length each time in the loop . However the difference is very insignificant . Since the length property of an array is like its public final member, so fetching that length is a constant time operation. It would have been different case if you had done list.size().

Categories : Java

Rails - calling an instance variable from anywhere in the app
You can just set this method in ApplicationController, and expose it to a helper method. class ApplicationController helper_method :access_user def access_user #blah blah end end When method in ApplicationController, it's available to all controllers. When you use helper_method, it is exposed as helper method to be used in View. More about helper_method: http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method

Categories : Ruby On Rails

iOS: Moving instance of AVAudioPlayer from one variable to another
Assuming that primaryPlayer player points to a valid AVAudioPlayer instance at address 0x1234 and secondaryPlayer has an arbitrary value and that both are declared as strong properties. secondaryPlayer=primaryPlayer; Now both variables point to the same object (at address 0x1234). primaryPlayer=[[AVAudioPlayer alloc] initWithContentsOfURL:songURL error:nil]; secondary player still points to the same object and being a strong reference, that object is still alive. primaryPlayer now points to the newly created object, so now you have two different player objects.

Categories : IOS

How to access instance variable from ajax?
//user.js function retrieve_radars() { $.ajax({ type: "GET", url: "/radars", success: function(data) { //load the response from radar#index into the div (or any other element $("#my_div").html(data); } }); } #app/controllers/radars_controllers.rb def index user = current_user; @radars = Radar.where(:user_id => user.id) render :partial => "radars", :layout => false #render partial. end #app/views/radars/_radars.html.erb create partial file <% unless @radars.nil? %> <table> <% @radars.each do |radar| %> <tr> <td>Name</td> <td><%= radar.name %></td> </tr> <% end %> </table> <% end %>

Categories : Jquery

Objective C: instance variable as reference
If you do not copy objects explicitly the are passed by reference in Objective-C: void addWorld(NSMutableString *stringReference) { [stringReference appendString:@"world!"]; } passed by reference: NSMutableString *greeting = [NSMutableString stringWithString:@"Hello, "]; addWorld(greeting); NSLog(@"%@", greeting); See also the answer "How to pass values by reference in objective C".

Categories : IOS

using an instance variable in static block
this will not even compile. it will give you error "non-static variable cannot be referenced from a static context" because you are trying to access an instance variable from static block, this would have run had the initializer block been non-static or the variable were static.

Categories : Java

when to render with instance variable, and when to redirect?
Offcourse, the Option1 will work best, since you are rendering new in case of errors only. Also, redirection li'l bit mess up the user experience, it will take a bit long to render the page again with same query @important_data = .... running again.

Categories : Ruby On Rails

How do I set an instance variable on an Eloquent model?
You have to define a getFullNameAttribute accessor method: class User extends Eloquent { public function getFullNameAttribute () { return $this->attributes['first_name'] . ' ' . $this->attributes['last_name']; } }

Categories : PHP

Acces violation on instance variable
If I'm not mistaken, you should call the inherited constructor from your constructor: constructor TXmlEnpManager.Create(aRoot: IXMLNode); begin INHERITED Create; sgyIterator := 0; sgyRoot := aRoot; Self.GenerateAttribs; end;

Categories : Delphi

About naming the instance variable in Objective C
Just to avoid confusion (see comments): Using the = _variable part of the @synthesize is not required, nor is the @synthesize itself required any more. This effort is only requied, when you want to link the property to a specific instance variable. With earlier Objective-C versions this part of the statement was required to set the name to something different from the property name, so when you want to call the iVar _variable and the property variable. The default would be variable (unlike your question). Without that = something ivar and property have the same name. BTW, there is nothing wrong with using the same name for both. But having different names, a leading _ would do, makes it more clear to the programmer whether he/she accesses the ivar directly or though the accessor method

Categories : Objective C

Block stored as instance variable becomes nil
Blocks are the only objects (to date) created on the stack rather than the heap. If you want to keep a block around longer than the life of the stack frame in which it was created, you must copy the block (the copy is heap based). Even using a strong pointer will not stop the block from going away when the stack frame is popped. ADDED: the comments are correct, having a copy property is sufficient. My bad, I forgot the copy attribute was there.

Categories : IOS

How to set instance variable of activity in onPostExecute?
this should not be an issue. here is an example that works fine: public class Register extends AsyncTask<String,Integer,String>{ @Override protected void onPreExecute() { Log.d("", "on pre bool: " + bool); }//end of onPreExecute() @Override protected String doInBackground(String... params) { bool = true; return ""; } @Override protected void onPostExecute(String result){ super.onPostExecute(result); Log.d("", "on post, bool: " + bool); } } where bool = private boolean in your main activity. here is the logcat: 07-19 11:57:25.943: D/(21843): on pre bool: false 07-19 11:57:29.736: D/(21843): on post, bool: true my guess is that your variable, doubleEmail, is not getting set to "no".

Categories : Android

How to set a watch point for an instance variable?
You can set watchpoint on memory address. You should stop in your code somewhere after foo constructor execution and print bar variable address. Than you can set watchpoint on address like this: (gdb) p &bar $1 = (int *) 0x10793ad0 (gdb) watch *0x10793ad0

Categories : C++

Remove spaces in one instance of variable?
str_replace should do it fine - echo '<div class="teamname" rel="' . str_replace(' ', '', $member['team_name']) . '">' . $member['team_name'] . '</div>'; That will work for spaces, you could use preg_replace to remove a general whitespace pattern. EDIT (having seen your edit!): The preg_replace pattern you're probably after would be something like echo '<div class="teamname" rel="' . preg_replace('/[^a-z0-9]+/i', '', $member['team_name']) . '">' . $member['team_name'] . '</div>';` This will replace any non-alphanumeric character. If you really only want spaces, quote marks and periods, you can go back to a str_replace with an array as the search argument - it will be faster. str_replace(array(' ','"',"'",'.'), '', $member['team_name'])

Categories : PHP

How to mock instance variable of class?
Have a look at https://code.google.com/p/mockito/wiki/MockingObjectCreation - there are a couple of ideas there that may help you.

Categories : Java

Accept nil argument only is instance variable is set
You can use * before the argument: def config(*c) @config ||= c end Note however that you will now get multiple values for c if you run: config('hi', 'hello') apart from that it will work.

Categories : Ruby

Understanding private instance variable
Ivars have @protected attribute by default, means subclasses can access them. To declare ivar as private, use @private attribute before ivar declaration: @interface ClassA : NSObject { @private int x; } If you declare your ivars in @implementation section, the only way for them to be visible to subclasses is to import .m file in your subclass, but your can't use them because they're private. Or don't use ivars at all, since Objective-C properties now create ivars automatically. If you need a private property, you can declare it via anonymous category in .m file like this: @interface MyClass () @property (nonatomic) NSInteger x; @end UPDATE: I think I understand what's confusing you. Public and protected ivars are inherited by subclasses and can be accessed directly as instance

Categories : Objective C



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