w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Amazon autoscaling scale-down instance
you need to specify ami id for template ami only. all will be scaled up and down based on this single ami id. PLEASE NOTE: it is an ami id or image id that will be utilized and not an instance id. The scale will be a range from 1 to 3 and will be configured in your autoscaling group with these tags: --min-size 1 --max-size 3 based on the metrics that you supply in the autoscaling policy. With a minimum size of 1 instance, 1 instance will always be running. With a maximum size of 3 instances, 3 can run. There is not a need to scale non running instances. Here is a complete tutorial: http://www.cardinalpath.com/autoscaling-your-website-with-amazon-web-services-part-2/

Categories : Amazon

Determine which AutoScaling Group a Launch Configuration is attached to
The answer as of this moment is that the solution I am looking for does not yet exist. In light of this current lack I have proceeded to evaluate my Undesirable Solutions. I first considered using a try/catch|except block and parsing the error when trying to delete a Launch Configuration that was attached to a group. The cost of parsing was more than I wanted to deal with so I decided to go with looping through the AutoScaling Groups and finding a match for each individual Launch Configuration. While the solution is less than ideal, it is working quite nicely. I hope to post the code on GitHub shortly so that others can also benefit from it. Update: 07 August 2013 Here is some code on GitHub that I have been working on. Hope it is helpful to others.

Categories : Amazon

how to construct a string of physical subnet ids to create db subnet group on the fly in a cloudformation script?
I run into the same issue, after working with AWS support I understood that List of String does not mean what we initially thought. Also, if you want to place the DB inside a VPC you must not use AWS::RDS::DBSecurityGroup objects. Here is a full sample, it took me a while to get it working: "dbSubnetGroup" : { "Type" : "AWS::RDS::DBSubnetGroup", "Properties" : { "DBSubnetGroupDescription" : "Availability Zones for RDS DB", "SubnetIds" : [ { "Ref" : "subnetPrivate1" }, { "Ref" : "subnetPrivate2" } ] } }, "dbInstance" : { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBInstanceIdentifier" : { "Fn::Join" : [ "", [ { "Ref" : "AWS::St

Categories : Amazon

terminate instance; Amazon cloudwatch
you have to add these two lines PutMetricAlarmRequest alarmreq=new PutMetricAlarmRequest() .withActionsEnabled(true) .withAlarmActions("arn:aws:automate:us-east-1:ec2:stop"); //This stops the instance in the requests

Categories : C#

Terminate called after throwing an instance of 'char const*'
Based on the discussion on the OP, I recommend that you keep the file name as a QString. Replace char* bmpName; with QString strBmpName; in your header. Then convert the QString to a char* for the following line. BmpFile bm(MainWindow::bmpName); to QByteArray ba = strBmpName.toLocal8Bit(); BmpFile bm(ba.data());

Categories : C++

C++ Game Started terminate called after throwing an instance of 'std::out_of_range'
levelList.at(rand()% wordList.size()); This is likely to be out of range some of the time, since wordList is likely to be larger than levelList. Presumably, you meant levelList.at(rand()% levelList.size()); ^^^^^^^^^ You are also not initialising the level variable declared in startGame, so it's likely that levelList will be completely empty. Presumably, you want to use the function argument to specify the level instead.

Categories : C++

Any way to snipe or terminate specific sidekiq workers?
Async loop is the best way to do it as sidekiq has no way to terminate running job. def perform main_thread = Thread.new do ActiveRecord::Base.connection_pool.with_connection do begin # ... ensure $redis.set some_thread_key, 1 end end end watcher_thread = Thread.new do ActiveRecord::Base.connection_pool.with_connection do until $redis.del(some_thread_key) == 1 do sleep 1 end main_thread.kill until !!main_thread.status == false do sleep 0.1 end end end [main_thread, watcher_thread].each(&:join) end

Categories : Ruby

KineticJS: How to scale the radius of a Group in Tween?
Set up multiple tweens where the circle expands+fades and the number fades: group.on('mousedown', function(){ var tweenCirc = new Kinetic.Tween({ node: circ, duration: 0.8, width: 80, opacity: 0, }); var tweenComplexText = new Kinetic.Tween({ node: complexText, duration: 0.8, opacity: 0, }); // start tween after 20 seconds setTimeout(function() { tweenCirc.play(); tweenComplexText.play(); }); }); Here is code and a Fiddle: http://jsfiddle.net/m1erickson/dvfr2/ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Prototype</title> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"><

Categories : Javascript

How do I return the index of a group of values from a list for a specific value in the group?
You can use next and enumerate: >>> list1 = [(12, "AB", "CD"), (13, "EF", "GH"), (14, "IJ", "KL")] >>> next(i for i,x in enumerate(list1) if 13 in x) 1 With a simple for-loop: for i, item in enumerate(list1): if 13 in item: print i break ... 1 Update: If the first item in each tuple is unique and you're doing this multiple times then create a dict first. Dicts provide O(1) lookup while lists O(N) >>> list1 = [(12, "AB", "CD"), (13, "EF", "GH"), (14, "IJ", "KL")] >>> dic = {x[0]:x[1:] for x in list1} Accessing items: >>> dic[12] ('AB', 'CD') >>> dic[14] ('IJ', 'KL') #checking key existence >>> if 17 in dic: #if a key exists in dic then do something #then do something

Categories : Python

Deleting a specific managed object from persistence store ?
Get the instance of the managed object that you create and pass that to the second view controller. When you want to delete it: NSManagedObjectContext *moc = self.managedObject.managedObjectContext; [moc deleteObject:self.managedObject]; [moc save:&error];

Categories : Iphone

How to properly auto-scale AWS EC2 Instances group in a relatively complex infrastructures?
Auto-scaling creates new nodes based on the launch configuration. So you would have two separate auto scaling groups and two separate launch configurations. ie "VarnishScalingGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "LaunchConfigurationName" : {"Ref" : "VarnishLaunchConfiguration" }, "LoadBalancerNames" : {"Ref" : "ELB"}, ... } }, "VarnishLaunchConfiguration" : { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Properties" : { ... "UserData" : { .... }, "MetaData" : { ... } }, "ApacheScalingGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "LaunchConfigurationName" : {"Ref" : "ApacheLaunchConfiguration" }, "LoadBalancerNames" : {"Ref" : "InternalELB"}, ...

Categories : Amazon

Why doesn't my managed object see the other managed objects that are in a to many relationship to it?
In a recent application I wrote I noticed that the setter for my relationship was not working and I had to write my own implementation based on another S.O. answer. Try adding the custom setter to your model and see if it works. -(void)add{objectName}Object:({ObjectName} *)value{ NSMutableSet* tempSet = [NSMutableSet setWithSet:self.{objectName}]; [tempSet addObject:value]; self.{objectName} = tempSet; }

Categories : IOS

A network-related or instance-specific error occurred while establishing a connection to SQL Server. Error Locating Server/Instance Specified)
causes this error is connectionString in webConfig Set connectionString in webConfig. name of connectionStrin in webConfig and code behind must be same. in web.config: <configuration> <connectionStrings> <add name="DSVUShort" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"/> </system.web> in code: SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DSVUShort"].ToString()); Connection.Open();

Categories : C#

EC2 Autoscaling issue
You can add all this to /etc/rc.local file to get it executed on server start-up. Create your own AMI and start your auto-scaled instanced with this AMI. e.g. /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 /sbin/iptables -t nat -I PREROUTING -p tcp --dport 8085 -j REDIRECT --to-port 91 /sbin/iptables-save /path/to/tomcat/bin/startup.sh /any/others/script.sh

Categories : Amazon

How to automatically add an autoscaled EC2 instance to a Security Group?
Create a security group called web. For the sake of an example, lets say the id of that group is: sg-7aa91911 Create a security group called db. Add a new rule to the db security group for port 1433 with the source of sg-7aa91911 Create an Autoscaling launch configuration and set the SecurityGroups to sg-7aa91911 and any other configuration you need. Create Autoscaling group with that launch configuration. I wrote up a quick CloudFormation template to do this task. You should be able to just run it and it will create an Autoscaling group with the connected security groups. It'll also create a blank instance where you can store your db. If you prefer not to use a CloudFormation template, just look at where the security groups are defined. It shows how the 2 security groups are to be c

Categories : Amazon

Amazon AWS autoscaling leader_only attribute
The idea of a leader only exists during the execution of a deployment in an environment update. After deployment has executed, there isn't a concept of a leader anymore From: https://forums.aws.amazon.com/thread.jspa?messageID=411720&#411720 The link also has some code for a roll-your-own leader implementation, although depending on your needs it may be easier to figure something else out.

Categories : Amazon

How to get maximum Y-axis value from autoscaling chart control
It doesn't compute the max value until the chart is displayed so the following code displays NaN: public Form1() { InitializeComponent(); this.chart1.Series.Clear(); this.chart1.Series.Add("My Data"); this.chart1.Series[0].Points.AddXY(1, 1); this.chart1.Series[0].Points.AddXY(2, 2); this.chart1.Series[0].Points.AddXY(3, 6); MessageBox.Show(this.chart1.ChartAreas[0].AxisY.Maximum.ToString()); // returns NaN } But checking after the chart is displayed will give the correct value: public Form1() { InitializeComponent(); this.chart1.Series.Clear(); this.chart1.Series.Add("My Data"); this.chart1.Series[0].Points.AddXY(1, 1); this.chart1.Series[0].Points.AddXY(2, 2); this.chart1.Series[0].Points.AddXY(3, 6); } private void button1_Click(o

Categories : C#

Is there any way to create an autoscaling Hadoop Hbase cluster
You can use Apache Mesos which a container based framework. Mesos works on container(e.g. dockers to start the services.) In mesos you can configure number of instances you need, configure resources, scale up/down etc. It will also take care of updating maintaining state of the process. This has been recently published hbaseconf 2015 where adobe has started using mesos for auto scaling in their production. You can also use google kuberneetes or marathon for managing the cluster and configurations. I have personally tried this on my local cluster. For more information to get started please follow this link Basic introduction and features of the mesos for quick reference [source: apache site] What is Mesos? A distributed systems kernel Mesos is built using the same principles as the Linux

Categories : Hadoop

Python and boto with autoscaling -- How to connect to a region
The method connect_to_region appears in every boto module and is the best way to create a connection to a service. The method, in this case, returns an AutoScaleConnection object so there is no need to try to create the connection object directly. So, something like this will work: import boto.ec2.autoscale region = 'ap-southeast-2' conn = boto.ec2.autoscale.connect_to_region(region, aws_access_key_id="<access_key", aws_secret_access_key="<secret_key>") mygroups = conn.get_all_groups() ...

Categories : Python

Why won't CloudFormation execute my command?
Your commands block should be nested inside the config block, at the moment it is at the same level in the hierarchy. "AWS::CloudFormation::Init" : { "config" : { "files" : { "c:\Packages\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } }, "commands" : { "1-installwebdeploy" : { "command" : "msiexec.exe /i c:\Packages\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } } }, }

Categories : Amazon

In a Rails view, how iterate a group of objects that should display as rows of 4 for instance?
You can try using each_slice enumerator http://apidock.com/ruby/Enumerable/each_slice Group.all.each_slice(4) do |slice_of_four| *now you can do your operations on the slices of four* end and try not using Group.all it will get all the groups in memory and if the the groups table is big you will have unneccesary problems

Categories : Ruby

Scale background image of div to a fixed width; auto-scale height
Any reason you can't add <img src='base64'/> inside the div elements then in the css have div{background: 0px 0px} to hide the div background and have img{width:171px}? See the modified jsFiddle. That solves the problem, but not sure if you are able to add the img tag. Let me know and i'll see if another solution can be found.

Categories : Javascript

A better way for a stacked area chart toggle between a percent scale and absolute scale?
So there are a lot of things you can do to avoid repeating yourself in the code. First of all a lot of the D3 functions you are using can be reused - they are general functions. This together with the concept of javascript closures means you only have to declare them once and initialize the parts that won't change. The stack layout does overwrite the y and y0 values, so to get the toggle to work I renamed your initial data to raw_x and raw_y and adjusted the accessors appropriately. Then the work of figuring out the yScale domain and actually updating the paths I wrapped into a function: function drawChart() { yScale.domain([0, d3.max(data, function (d) { return d3.max(d.values, function (d) { return d.y0 + d.y; }); })]); // new data items need t

Categories : Javascript

Why won't my CloudFormation script download a file?
Jonathon, I tried your template and the file downloaded successfully for me. You can check the cfn logs on the instance. They are in c:cfnlog. My cfn-init.log shows: 2013-07-19 21:30:18,269 [DEBUG] Parent directory c: est does not exist, creating 2013-07-19 21:30:18,269 [DEBUG] Writing content to c: estgoogle-logo.png 2013-07-19 21:30:18,269 [DEBUG] Retrieving contents from http://www.google.com/images/srpr/logo4w.png 2013-07-19 21:30:18,316 [DEBUG] No mode specified for c: estgoogle-logo.png 2013-07-19 21:30:18,316 [WARNING] Unsupported OS for setting owner/group: nt And my cfn-wire.log shows: 2013-07-19 21:30:18,269 [DEBUG] Request: GET http://www.google.com/images/srpr/logo4w.png [headers: {'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'pyth

Categories : Amazon

AWS - Automatic deployment (.NET) to CloudFormation stack
cloud-init is used with windows too. See the documentation for bootstrapping Windows stacks.

Categories : Amazon

Is it possible to create a SNS subscription with CloudFormation without creating a topic?
As you already discovered, AWS CloudFormation doesn't provide the expected AWS::SNS::Subscription resource (yet) and I'm not aware of this being possible by any other means, unfortunately - guess the rationale is that both are either managed within a template or externally, but your use case is sound and I can see no fundamental reason why this shouldn't be available (maybe they'll add it at some point, AWS is usually expanding their APIs over time to address such inconsistencies/missings).

Categories : Amazon

IOS- NSNotificationCenter- notify specific instance
You could add a new key with a tag in that data dictionary you are posting. In all of the view controllers that receive the notification check that tag to see if matches "their" tag is so then they can process the data or they can simply return from the method.

Categories : IOS

c++ overriding a function only for a specific instance
I think virtual function is just what you want, with virtual function, different instances of the same type can have different functions, but you need to inherit the base class. for example class A { public: ... virtual void update() { std::cout << "Class A "; } ... }; class B: public A { public: virtual void update() { std::cout << "Class B "; } }; class C: public A { public: virtual void update() { std::cout << "Class C "; } }; int main() { ... A *first_instance = new A(); // I want this to have a specific update() function. // ex. void update() { functionA(); functionB(); ... } A *second_instance =

Categories : C++

MySQL Specific Group by
This should do it: select name, min(time), max(time) from ( select name, time, @group_num := if(@name != name, @group_num + 1, @group_num) AS group_number, @name := name from yourTable , (select @group_num := 1, @name := NULL) variables order by id ) sq group by group_number

Categories : Mysql

AWS AutoScaling error Malformed input-Only one of EC2_CERT and EC2_PRIVATE_KEY is configured Usage:
I can't believe that the problem was that i was specifying both the credential file and the private key(stupid me), it worked just fine when i removed the private file specification i can't believe i wasted half day on that. I hope the solution can help any one stuck with this error

Categories : Amazon

Installing Windows applications/extensions with Amazon CloudFormation
For your example of WebDeploy, you could add this: "C:\Webdeploy\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } as a element of this section of the template "WindowsServer": { "Type" : "AWS::EC2::Instance", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "files" : { You could then add this command: "1-installwebdeploy" : { "command" : "msiexec.exe /i C:\Webdeploy\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } to the list of commands.

Categories : Amazon

How to identify if a string contains more than one instance of a specific character?
You can compare IndexOf to LastIndexOf to check if there is more than one specific character in a string without explicit counting: var s = "12121.23.2"; var ch = '.'; if (s.IndexOf(ch) != s.LastIndexOf(ch)) { ... }

Categories : C#

How can I tell if a specific Mongo instance has active connections?
The cursorInfo command should work. If there are no more cursors, then it's ok to shut off the mongos. Any connections that still exist will simply fail over to another mongos through the load balancer when they try to reconnect (assuming they have an appropriate reconnection policy in place). The only thing you need to worry about is cursors, since they have state, which is taken care of by cursorInfo.

Categories : Mongodb

Schedule one-off job that works on a specific object instance
For this case, i agree that a timer should be the preferred way to go. I feel a scheduler for this purpose is to complicate things. Using a scheduler or a timer will both make async stuff. If you do want to use a scheduler, you can communicate to your viewmodel using a [Messenger] to send a message that the given job is done, and register for that in the viewmodel.1

Categories : C#

How do you set an array instance variable to a specific set of data?
There are two ways to instantiate an array to a constant array: String[] subjects = {"Cat", "Dog", "Joe", "Teacher", "Policeman", "Doctor", "Dick"}; or: String[] subjects; subjects = new String[] {"Cat", "Dog", "Joe", "Teacher", "Policeman", "Doctor", "Dick"}; In your constructor, you need to use the latter (note the new String[] part).

Categories : Java

Connecting to a specific SQL Server instance on another machine
Even with an IP address, you must specify the instance name. Aka, Data Source=192.168.1.50SQLEXPRESS is your best candidate there. Firewalls. You may have to open the PORT NUMBER. But more importantly, you may have to open up the program name. Note this article: http://technet.microsoft.com/en-us/library/ms175043.aspx Note this area in the article: In the Program dialog box, select This program path. Click Browse, and navigate to the instance of SQL Server that you want to access through the firewall, and then click Open. By default, SQL Server is at C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLBinnSqlservr.exe. Click Next. ALSO: I like to use this program to "ping" my machine and port. Emphasis on the "and the port". http://www.microsoft.com/en-us/download/d

Categories : C#

How to Group specific Colomn in Oracle 9i
Here's one way of doing it. SELECT CASE WHEN r = 1 THEN w ELSE NULL END as s_no, column1, column2 FROM (SELECT column1, column2, ROW_NUMBER () OVER (PARTITION BY column1 ORDER BY column2) AS r, DENSE_RANK () OVER (ORDER BY column1) AS d FROM SAMPLE); Here ROW_NUMBER function returns unique number for each row within a group of column1. DENSE_RANK function returns unique rank to to each group of column1. Using this, you can chose to display the dense_rank column only for 1st row. SQL Fiddle here

Categories : Oracle

XSL - How to group a specific number of elements
You are on the right track with checking the position() mod 5, but the approach you need to take is rather than selecting all paragraph elements and checking the position with an xsl:if, is to change the xsl:for-each to select only the 1st, 6th, 11th, etc elements <xsl:for-each select="paragraph[position() mod 5 = 1]"> This would be the basis for your fo:block. And within this block, you can then select all the paragraph elements that make up the block. <xsl:apply-templates select="self::*|following-sibling::paragraph[position() &lt; 5]"/> Here is the full XSLT. Note I have parameterised the '5' to make it easy to adjust the number of paragraphs per block. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

Categories : Xslt

Java - Instance method for specific generic instances
You can change your constructor in this way: public MyArray (Class<T> clazz) { elms = (T[])java.lang.reflect.Array.newInstance(clazz,INITIAL_SIZE); size = 0; } And while creating the object of MyArray use the following code: MyArray<Integer> myArray = new MyArray<Integer>(Integer.class); UPDATE Further if you want to make your method to work depending upon the type of elms then you can work as follows: public void doSomething() { if (elms instanceof Integer[]) { .... } }

Categories : Java

Can different threads access different methods of a specific instance of a stateless EJB?
I think that secion 4.3.14 of the ejb 3.1 spec gives the answer. 4.3.14 Serializing Session Bean Methods The following requirements apply to Stateless and Stateful session beans. See Section 4.8.5 for Singleton session bean concurrency requirements. The container serializes calls to each stateful and stateless session bean instance. Most containers will support many instances of a session bean executing concurrently; however, each instance sees only a serialized sequence of method calls. Therefore, a stateful or stateless session bean does not have to be coded as reentrant. The container must serialize all the container-invoked callbacks (that is, the business method interceptor methods, lifecycle callback interceptor methods, timeout callback methods, befo

Categories : Multithreading



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