w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Find My Instance Region in AWS
This should work for you: REGION=`curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F" '{print $4}'` echo $REGION It's from this thread: Find region from within EC2 instance

Categories : PHP

Copy (draw) one image inside region of another image in Matlab?
You can "blend" images using alpha channel (or fractional mask). Suppose you have master the large image, region the smaller image to be blended into master and alpha a fractional mask (the same size as region), where alpha=0 indicates that the corresponding output pixel should be taken from master, and alpha=1 indicates a pixel to be taken from region (alpha can be fractional to indicate a blend). I assume master, region and alpha has the same width and height, and are of type double. Then >> blend = bsxfun( @times, master, 1-alpha) + bsxfun( @times, region, alpha )

Categories : Image

LocationManager region monitor is not what I expected. The region boundary looks bigger than my settings
My experience is that this is normal behavior. I've been using region monitoring for about 2.5 years now and since iOS 6, the -didExitRegion delegate takes much longer to trigger than the -didEnterRegion. I also had this behavior confirmed by an Apple Engineer during WWDC 2013. It doesn't sound as if they plan to improve the accuracy, rather delay, in the exit events. According to the engineer, the OS takes a lot longer to decipher that you've left because it has to completely get out of range of known Wifi networks and to new cell towers. It is much easier to determine you've arrived than it is to determine you've left. If it is only taking 300M or so to trigger your geofence (outside the 300M radius), I'd say you are probably within the operating limits of the geofence. If you need prec

Categories : IOS

How to disable a region when a child window pops up in another region in prism mef wpf
You can bind your viewModel's main content's attribute IsEnabled to a boolean property IsPopupGone. In the constructor of your toolbar subscribe EventAggregator to an event PopupWindowStateChanged and payload as a boolean. Then when your popup window(s) display, publish this event with True, and when closed publish as False. private bool isPopupGone = true; // default/original state assumed to be no childs showing public bool IsPopupGone { get { return isPopupGone; } set { isPopupGone = value; /* implement notifypropertychanged */ } } public ToolbarViewModel(IEventAggregator eventAggregator) { EventAggregator = eventAggregator; EventAggregator.GetEvent<PopupWindowStateChanged>().Subscribe(UpdateEnabledState); } public void UpdateEnabledState(bool isPopupShowing

Categories : Wpf

HBase region over region servers load not balanced
Are you using sequential rowkeys, like timestamp?If that is the case you might end up with RegionServer Hotspotting, putting uneven load on the servers. Avoid using sequential keys, if you can. If it is not possible create pre-splitted tables.

Categories : Hadoop

Emacs: select a region and type to delete the region
I don't think it does it out of the box, it looks like you have to turn on delete-selection-mode as per this article on EmacsWiki. So, basically put the following line into your .emacs: (delete-selection-mode 1)

Categories : Emacs

Copy axes instance
Surely the easiest way would be to take the original image, clipImageSectionPix as you need, scales it with scaleImage and then create a new plot - the axes and labels should then be created, correctly and automatically for then new FOV, (you will even get the ticks adjusted).

Categories : Python

How to create more than one instance with own copy of global variables
There are several ways you can solve this: Spawn multiple processes (each with their own set of globals) and setup channels of communication between them and the main program. Get rid of the global variables. The easiest way to do this would be to dump them all in a class (as non-static members) and use instances of that class to access each set of variables. Either way, it's not a small problem to solve if you have a large number of globals.

Categories : C++

Easiest way to copy/clone a mongoose document instance?
Can you clarify what you mean by "copy/clone"? Are you going trying to create a duplicate document in the database? Or are you just trying to have two vars in your program that have duplicate data? If you just do: Model.findById(yourid).exec( function(err, doc) { var x = doc; Model.findById(yourid).exec( function(err, doc2) { var y = doc2; // right now, x.name and y.name are the same x.name = "name_x"; y.name = "name_y"; console.log(x.name); // prints "name_x" console.log(y.name); // prints "name_y" }); }); In this case, x and y will be two "copies" of the same document within your program. Alternatively, if you wanted to insert a new copy

Categories : Mongodb

Copy parameters to object instance with getters and setters
You are creating a closure that gets evaluated when the getter/setter functions execute, not when they are defined. At the time they execute, prop has the last value it was assigned during execution of the loop. You need to avoid creating a closure on prop. One way is with an IIFE. Instead of using this argument: function () { return obj[prop]; } use (function(p) { return function() { return obj[p]; }; }(prop));

Categories : Javascript

How can I get the country and region code using geolocation instead of full country and region names
You should use the short_name value for the country, which is the two-digit country code. These are ISO standard codes and should be the basis for your database lookup, not the localized country name.

Categories : Javascript

Copy instance variable of type java.util.Random to create object in same state
I think you should store in your State class, not only starting seed but also number of calls to nextInt() you already did. This is due to the intrisic fact that Random generates pseudo-random sequence of numbers. That is: A pseudo random number generator can be started from an arbitrary starting state using a seed state. It will always produce the same sequence thereafter when initialized with that state Let me explain show you with a sample first: public static void main(String[] args){ Random r = new Random(42); Random s = new Random(42); for(int i = 0; i < 5; i++){ System.out.println("First random " +r.nextInt()); } for(int i = 0; i < 5; i++){ System.out.println("Second random " +s.nextInt()); } } which result is:

Categories : Java

To create a copy of object in java w/o clone,copy constructor and copy factory
You can just create a new object for NewDog using OldDog Have you considered something like this? NewDog dog = new NewDog(someOldDogObject); While constructor of NewDog can be. public NewDog(OldDog oldDog){ this.dogWeight = oldDog.dogWeight; // keeping the same weight this.dogName = "newDog" + oldDog.dogName; // changing your dog name as per rquirement. }

Categories : Java

Running only one instance of an application,(Quit new instance and Display old instance or give Focus)
What you need to do is to add this to your main class: [DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr hWnd); Then you need to obtain a reference to the process that is already running, and then call the SetForegroundWindow method like this: SetForegroundWindow(SameProcess.MainWindowHandle); You do not need to kill the current process like you are currently doing, just return after focusing the other process' main window as shown above This is a full working example: [DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr hWnd); /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { var currentProcess = Process.GetCurrentProcess(); foreach (Process p in Process.GetP

Categories : C#

What service will copy a third-party JSON feed every few seconds so users can access the copy?
Check out Feed the Fire, which reads RSS feeds into Firebase. I think you'll find it a great idea bank and a close fit for your needs. Essentially, it uses a node.js process to read the source feeds on a regular interval and inject them into Firebase for consumption. The code involved is rather trivial: Var Firebase = require('firebase'); setInterval(function() { var jsonData = /* get data from your JSON feed */; new Firebase(URL).set( jsonData ); }, FREQUENCY_OF_CHECK_IN_MILLISECONDS );

Categories : Javascript

Write a function to dynamically create a new copy of string and return a pointer to the new copy (C)
I should start by pointing out that in my opinion, given the number and (especially) nature of the mistakes in this code, you probably need to get a good book on C. Your newString = s; overwrites the pointer instead of copying the string into the space you just allocated. Thus, you lose the pointer to what you just allocating (leaking the memory) without making a copy. You probably want to use strcpy instead of direct assignment. Your computation of the size you allocate isn't what you really want either. Typically, for a string of length N, you want to allocate N+1 bytes. You're currently attempting to allocat sizeof(int * strlen(s)) bytes, which shouldn't even compile.

Categories : C

how to use ZeroClipboard.js to copy static word when page load copy to clipboard
As mentioned in the comments, this requires a user interaction. I recommend having a div with this style. .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; text-align: center; background: rgba(255, 255, 255, .5); } Bind zero clipboard to that, and instruct the user to click to copy the text and continue. Users should always be notified of their clipboard modifications. If you end up replacing their college thesis with some arbitrary text, without warning, they might not be so happy...

Categories : Javascript

Doubly-linked List copy constructor (can't copy tail-to-head)
By having a const argument, you're calling a non-const member function on const object. Non-const functions do not promise to not modify the object. You can declare these member functions as const to avoid this error: Node *getHead() const .. and so on As for your first question, I don't know how to solve it (yet), I have a few recommendations: Use nullptr instead of NULL or 0 Use list initialisation for your strings: string f { curr->getData()->getFirst() }; I suggest you debug your code line by line, using a good debugger tool, like Visual Studio; it will help you solve your problem in minutes. If you are still unsure, you can cut the amount of code to be tested, down to a few lines and post it.

Categories : C++

If I instantiate a LinearLayout as a copy of an existing one, once I perform a chance on the original, it's also done on the copy
Any time you see changes to one object reflecting in what you think is a copy, 100% of the time the problem is that you don't have a copy but rather a second reference to the original object. You will need to do some digging into LinearLayout to determine whether the .clone() method is fully implemented, or manually make a copy of all the fields

Categories : Java

Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
ITEMS needs a definition available in the same translation unit to be used as an array size. Change its declaration (extern int const ITEMS;) to also be a definition: int const ITEMS = 9;

Categories : C++

To Copy the Selected text in Pdf which is inside an Iframe without using copy, paste
The adobe documentation says there's no way for JavaScript in the browser to access the PDF. Acrobat JavaScript does not have access to objects within an HTML page. Similarly, HTML JavaScript cannot access objects within a PDF file. http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSGuide.pdf What you could try is rendering the pdf itself in JavaScript using a library like pdf.js. Once the pdf is part of the dom, you could attach a listener in a similar fashion to what you've done for the text documents.

Categories : PHP

What is good practice? A copy constructor or a defensive copy method
As far I understand your question In copy constructor you would do something like Graph copy = new Graph(objectToBeCloned); and in getGraph() you would do Graph copy = objectToBeCloned.getGraph(); I suggest make your Graph class implement Cloneable interface and override clone() method to get a deep copy you need.

Categories : Java

XSL - Copy tree, copying some nodes twice and changing attribute in second copy
You are quite close. Only one lien missing. Add a line to copy all attribute <xsl:apply-templates select="@*"/> before changing the attr2 content. Try this: <xsl:template match="node()[@attr2='yyy']"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="attr2">changed</xsl:attribute> <xsl:apply-templates /> </xsl:copy> </xsl:template>

Categories : Xml

Is data handed over to UIPasteBoard deep copy or shallow copy?
If you ask about - (void)setData:(NSData *)data forPasteboardType:(NSString *)pasteboardType than it is surely a Deep copy. If you ask about strings, URL's, Colors they are also Deep copied. Only about the Images I am preety sure that it uses the same CGImageRef, because UImage does not implement NSCopying protocol You can test it just closing your application and see that data stays in the pasteboard.

Categories : IOS

Error when using angular.copy() to copy data returned from ngResource
Take a close look at angular.copy doc: destination(optional) – {(Object|Array)=} – Destination into which the source is copied. If provided, must be of the same type as source. The result you got back from service call is probably an array; you however initialized $scope.grid.originalData as an object or something else other than array, so you got this type error. Try to figure out what type the result is, and make $scope.grid.originalData the same type before calling angular.copy.

Categories : Javascript

Can a child instance access dynamic parent instance attributes and attribute values?
You're misusing inheritance. Rule doesn't need to inherit from Map to access a Map's attributes, and attaching a Rule to a Map won't make it see the Map's attribute values as its own. Inheriting from Map means a Rule is a Map, not that it's linked to or managed by a Map. If you want a Rule to know about its Map, have it record which Map it's associated with: class Rule(object): def __init__(self, number, map): super(Rule, self).__init__() self.number = number self.map = map def __str__(self): # __str__, not __repr__, because __repr__ should be unambiguous, # have a clear beginning and ending, and obviously indicate the type. return "Map {} rule number {}".format(self.map.mapName, self.number) Rule(1, map) # makes a rule associated

Categories : Python

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

Newly created instance takes the primary id of a deleted instance with same Account name
This is a known behavior of AUTO_INCREMENT fields in MySQL: http://forums.mysql.com/read.php?10,167180 If this is really your problem, you will have to find an other strategy to keep track of deleted user accounts. For more information, see Stop MySQL Reusing AUTO_INCREMENT IDs

Categories : SQL

Is there a way to reset a class instance's initialized attribute to the value entered when the instance was created?
There's nothing in Ruby that saves the initial value passed on, so nothing in Ruby that will let you automatically reset it. However, you can certainly save the value in an another instance variable and reset it as you wish, as in: def initialize(..., meat_quality) ... @original_meat_quality = @meat_quality = meat_quality end def reset_meat_quality @meat_quality = @original_meat_quality end

Categories : Ruby

Are object of my classes being created everytime there is a request or does it only create one instance of a class per instance server
Instances of resource classes are created "per-request" by default. You can mark them as singletons however and then one instance would be used for all requests. To do this you can use the following annotations: @com.sun.jersey.spi.resource.Singleton for Jersey 1.x (JAX-RS 1.1) @javax.inject.Singleton for Jersey 2.x (JAX-RS 2.0)

Categories : Java

Error: unbound method Dragon( ) must be called with Enemy instance as first argument (got Player instance instead)
You have to create an instance of a class first before you call any functions from it: myenemy = Enemy() myenemy.Dragon() In your code, it looks like you created self.enemy, but later you call self.enemy = Enemy.Dragon(self). Instead of this last line, put self.enemy = self.enemy.Dragon(self). It seems to be a recurring issue in the rest of your code as well. Commands = {'explore': Player.explore} should probably be Commands = {'explore': p.explore} (after you have created the instance p). Since your updated code, I think you're getting functions and classes mixed up. Dragon is a function, and when you do enemy = m.Dragon, you are simply copying the function onto enemy. And thus when you do enemy.name, thinking it's a class, an error is raised, because enemy is now a function, not a

Categories : Python

Copy vector struct to file using ostream_iterator and copy
You'll need to overload operator<< for AccDetails. It is what ostream_iterator calls internaly. Something like this: std::ostream& operator<<(std::ostream& stream, const AccDetails& obj) { // insert objects fields in the stream one by one along with some // description and formatting: stream << "User Name: " << obj.username << ' ' << "Real Name: " << obj.name << ' ' << obj.topicid << ' ' << obj.testid << ' '; return stream; } The operator takes the stream it inserts to as first parameter and a constant reference to the object it is streaming as the second one (this allows passing temporary AccDetails, too). Now you can also say: AccDetails acc; std::cout <&

Categories : C++

Use Sharepoint Copy web service to copy folder and contents
There is a simple solution to this problem , as its just about copy and paste use the simple XCOPY command XCOPY Copy files and/or directory trees to another folder. XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail. To copy a folder including all subfolders XCOPY C:utils* D:Backuputils /s /i here /i defines the destination as a folder for more detail please refer this link

Categories : C#

Warning: copy() [function.copy]: Filename cannot be empty
http://www.php.net/manual/en/ini.core.php#ini.post-max-size Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.

Categories : PHP

Override Windows copy (as in copy/paste) functionality?
No. The copy-paste is not done by Windows, so your assumption is wrong. You can see this from the fact that it's possible to copy many things that Windows is unaware of. For instance, parts of CAD drawings - Windows doesn't ship with support for that out of the box. And obviously, you can't copy a CAD drawing component either. Remember, I'm not hiding information from you here. If things worked as you assumed, you would need to copy anything that an application wants copied, without any knowledge up front. In fact, you would need the capability today to copy objects that I will only write tomorrow! In reality, copy-paste works by cooperation between the source and destination application.

Categories : C++

WPF, how to make a single instance and shows the MainWindow when another instance is launched in c#
If I havent misunderstood your question try something like this [STAThread] public static void Main(string[] args) { Task task = new Task(() => { Thread.Sleep(200); MessageBox.Show("what a marvelous engineering"); }); task.Start(); //If you want application not to run untill task is complete then just use wait task.Wait(); App app = new App(); app.InitializeComponent(); app.Run(); } But I am wondering if you want your C# work done before the your MainWindow instantiate why dont you just do your other wor just before App app=new App() and let the code run sequentially.

Categories : C#

How to use Angular.js service instance inside module config and keep the same instance
From the doc - Services as singletons All Angular services are application singletons. This means that there is only one instance of a given service per injector. Since Angular is lethally allergic to global state, it is possible to create multiple injectors, each with its own instance of a given service, but that is rarely needed, except in tests where this property is crucially important. It mean if you do injector.get for a single injector, it will always returns the singleton like this var injector = angular.injector(['app.services']); var singletonService1 = injector.get('singletonService'); var singletonService2 = injector.get('singletonService'); console.log(singletonService1 === singletonService2) // prints true However if you inject it to another the controller

Categories : Javascript

Calling an Instance method when user inputs the instance name as a String
You can use a Map for this. E.g.: Map<String, Skill> skills = new HashMap<String, Skill>(); To insert the values you put the values into the Map: skills.put(skill.getName(), skill); To retrieve your skill you can get the skill by name: Skill skill = skills.get(name);

Categories : Java

Objects and Arrays of one instance are getting referenced by new instance of Backbone model
There is a hack I have used to solve this problem. Reset all the objects and arrays used as attributes in Backbone model in initialize method. var myModel = Backbone.Model.extend({ defaults: { exp: [], name: '', json: { } }, getExp: function() { return this.get('exp'); }, getJSON: function() { return this.get('json'); }, initialize: function() { this.set('exp', []); this.set('json', {}); } }); var m1 = new myModel(); var experiences = m1.getExp(); experiences.push('arrayitem1'); experiences.push('arrayitem2'); m1.set('name', 'my name'); var json = m1.getJSON(); json.key = 'somevalue'; var m2 = new myModel(); console.log(m1.attributes); console.log(m2.attributes); Working Demo at JSBIN

Categories : Javascript

Assign instance id when the wpf app has multiple controls on page identified as one instance
An addendum to AdrianHHH's excellent suggestion is to iterate through the FindMatchingControls collection and figure out which one is the one you want. If it's always collection[3] then you can identify it and act on it as such. Your code would look like this: var button = new WinButton(winWindowChild(mainParentCtName, childParentCtName)); //if you pass parents when you construct an object it can speed up find button.SearchProperties.Add(/*any identifying properties*/); var allButtons = button.FindMatchingControls(); //test code foreach (var btn in allButtons) Mouse.Click(btn); //watch this to figure out what order the buttons are iterating through, then remove loop Mouse.Click(allButtons[3]); Mouse.DoubleCli

Categories : Wpf



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