w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
AWS - Automatic deployment (.NET) to CloudFormation stack
cloud-init is used with windows too. See the documentation for bootstrapping Windows stacks.

Categories : Amazon

Column stack and row stack with H5py to existing datasets
After rereading some of the documentation on H5py, I realized my mistake. Here is my new script structure that allows me to stack arrays in the HDF5 file: import h5py import numpy arr1 = numpy.random.random((2000,2000)) with h5py.File("Plot0.h5", "w") as f: dset = f.create_dataset("Plot", data = arr1, maxshape=(None,None)) dsetX, dsetY = 2000,2000 go = "" while go == "": go = raw_input("Current Size: " + str(dsetX) + " " + str(dsetY) + " Continue?") arr2 = numpy.random.random((2000,2000)) with h5py.File("Plot0.h5", "r+") as f: dset = f["Plot"] print len(arr2[:]) print len(arr2[0][:]) change = "column" dsetX, dsetY = dset.shape if change == "column": x1 = dsetX x2 = len(arr2[:]) + dsetX

Categories : Python

Excel VBA Modify Existing Equation
if the formula is changed to =A1+A3+A5 then code could be: Range("B1").Formula = Range("B1").Formula & "+" & Range("A7").Address or, without dollar signs, Range("B1").Formula = Range("B1").Formula & "+" & Range("A7").Address(False, False) Added in response to OPs comment. If I assume the new cell is two rows above where the formula is, which is the currently the active cell: ActiveCell.Formula = Replace(ActiveCell.Formula, ")", "," & _ ActiveCell.Offset(-2, 0).Address(False, False) & ")") Adjust the value -2 as necessary.

Categories : Excel

How to modify the existing stl find function in C++?
If you only want to make std::find work for your array of structure, you need to define operator== for struct data: struct data { data(int value=0) : val(value) {} int val; }; bool operator==(const data& l, const data& r) { return l.val == r.val;} auto x = find(A, A+LEN, value); OR auto x = find(A, A+LEN, data(value)); To get index of value in A, use std::distance std::distance(A, x); Note: For more sufficent search with sorted container, use std::lower_bound, std::uppper_bound, std::binary_search instead. auto lower = std::lower_bound(A, A+LEN, data(3)); auto upper = std::upper_bound(A, A+LEN, data(3)); Your operator< function signature better be like: bool operator < (const data &a1, const data &a2) // ^^^^^ ^^^^^

Categories : C++

itextsharp modify existing pdf (no new source pdf) and add watermark
iTextSharp isn't intended to be used to edit files in-place. What if while it was writing your changes there was an exception? You'd lose both your old and new file in the process. Even if iTextSharp was 100% bug free, user-code could still break it. And then there's the edge cases like where you grow a 1MB file to 10GB by adding a bunch of images and run out of space on a drive. The only way for iTextSharp to reliably test these cases is to actually write a file. There's also testing. Whenever I'm editing a file I always want to compare my input file to my output file. If iTextSharp kept erasing my input file I'd constantly have to copy it from another location which I might have to do dozens of times an hour. So those are some of the why's. But there is a way to do what you want to do.

Categories : C#

Modify existing inline code for asp.net in a gridview
Since the markup for each is very similar, I'd use a simple lookup object: <script runat="server"> private Dictionary<int, string> TypeNames = new Dictionary<int, string> { { 1, "Change to Performance Test" }, { 2, "Change to Unit Test" }, // etc }; </script> <ItemTemplate> <a target="_self" href="TestRequestOverview.aspx?testCaseId=<%# DataBinder.Eval(Container.DataItem, "testType") %>&mode=toggle" class="myToggle"> <%# TypeNames[Int32.Parse(DataBinder.Eval(Container.DataItem, "testType").ToString())] %> </a> </ItemTemplate>

Categories : Asp Net

How to enable other programs to modify existing program
The "robot programs" are just stored as plain text files. There's a general-purpose text editor in editor.py. When you open a robot in a given view, e.g., the Qt4 view in qt4view.py, it just instantiates a text editor and hands it the robot's file. Again, the fact that the robot's file is a Python script doesn't matter; it just edits it as a text file. The battle code, meanwhile, opens the same robot files as Python code that the text editor opens as text files. You can see this code in game.py: It just uses the subprocess module to run Python, passing the robot file as an argument.

Categories : Python

Programmatically modify existing mongo document
Give this a try instead: exports.modify = (req, res) -> fields = if (typeof req.body == 'string') then JSON.parse(req.body) else req.body db.collection "data-center", (erreur, collection) -> // check erreur here collection.update { _id: new mongo.BSONPure.ObjectID(req.params.id) }, { $set: fields }, (erreur, resultat) -> // check erreur here res.send resultat res.end() It is important to note that inserting data directly from req.body without some sort of validation/content checking is not secure and should be avoided (even if it works as expected).

Categories : Node Js

How do I modify an existing button's onclick to open a new tab using Greasemonkey?
You can just do this: <button onClick="window.open('*my-url*');">Stock in Shop</button> There is no way to force a new tab -- the browser will respect the user's setting whether to create a new tab or a new window. I've created a JavaScript fiddle for you so that you can see for yourself how simple this is: http://jsfiddle.net/Fnz9R/ Good luck!

Categories : Javascript

Simplest way to modify an existing java application and get it online
If you already have an OO code, rather than every LOC in main method, then you are already half way done. Go to this SO to decide on MVC

Categories : Java

Ext: how can I use data from an ajax request to modify an existing Javascript element?
The problem was something else entirely. I thought it was not possible to communicate with a variable declared outside of an Ajax statement from within the Ajax statement. Turns out I had a '[' and a ']' too much. My target was expecting something like this '' but I gave it an array with only one member '[]'. It is kinda weird though, because in other cases Ext will only accept nodes as an array, no matter how many there are.

Categories : Javascript

How do you write a program to automatically modify existing SQL database every x minutes?
If your web & PHP server is running on Linux (which is often the case) and if the delay x is more than a few minutes (i.e. x>=5 minutes) then you could use crontab(1) and add a crontab(5) entry. Remember to use absolute paths there. That entry would run (periodically) some script (which you could code in PHP, but also in some other scripting language like Python or OCaml) which would update the MySQL database.

Categories : PHP

How do I modify an existing database table (add/remove columns) with PetaPOCO (Umbraco 6, MVC)
If you are using PetaPoco, you could use the db.Execute("alter table ...") but then you would need to have sufficient access rights to execute a DDL statement like that. Also I would run this within a PetaPoco transaction too, as it's good practice. Finally, if you were running this at Application_Start (which is fine) you would need to perform a check to ensure that the column didn't already exist.

Categories : C#

Modify existing code for creating menu names in an interactive shell script
Assuming you can pull out the "Add", "Delete" ... and other "titles" from the 7th line of each *.mod file, then you need to modify your script where it looks at the file a1.out somewhere before the line which seems to create the menu, namely: tr ' ' ' ' < ~/a1.out > ~/b.dat. I say "assuming" because, even though you mention awk NR==7, I don't see where you are using it in the script. In any case, if you can get the "title" from the 7th line of a given *.mod file, then you can get the menu "name" from the file name (which seems to be the way you are constructing your menu) like this: awk '{ln=length(ARGV[1]); if(NR==7) print substr(ARGV[1],0,ln-4)"..."$0}' ABC.mod outputs: ABC...Add There's may be a shorter, easier way to do this using sed, but you mentioned awk. For me at le

Categories : Bash

Modify an existing scrapy spider the website implemented a captcha - how to get an image that pops up for decode and continue?
You should extract the image of captcha using xpath like hxs.select("//div[@class='captcha']/img[@src]") and then handle it. Above is example of HtmlXPathSelector , you can use others also. For more information http://doc.scrapy.org/en/0.18/topics/selectors.html

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

setting up mongodb via AWS opsworks
I just tested this repo on github, it works for MongoDB / OpsWorks. Goto OpsWorks > Layers > In the "Custom Chef Recipes" section reference this github link "https://github.com/Cyclic/cookbooks" then add "yum::default" to the Setup lifecycle event. Then add "mongodb::10gen_repo" "mongodb::default" and "mongodb::10gen_remrepo" to the Setup lifecycle event

Categories : Ruby On Rails

AWS OpsWorks Layer during Chef run
Solved. SSH connect to my instance, then : sudo opsworks-agent-cli get_json This shows me the Opsworks JSON that is merged with Chef Custom JSON... and there is my layer's name: node["opsworks"]["instance"]["layers"][0] Then i used some logic in my recipe...

Categories : Amazon

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 Opsworks Custom Layer Deployment
Yes, you will need to write your own custom deploy recipe for a custom layer. Your deploy recipe can configure where the deployment goes and any steps required to deploy your software. Alternatively you can extend the OpsWorks static web server layer, which deploys Nginx, to meet your needs.

Categories : Amazon

OpsWorks - what to include in custom cookbook
OpsWorks, at the moment, does not support a single cookbook directory style. It works to build the repository like this: delayed_job recipes deploy.rb undeploy.rb s3cmd attributes default.rb recipes setup.rb configure.rb templates default s3cfg.erb whenever recipes deploy.rb undeploy.rb Then under stack settings, under custom cookbooks, one can add e.g. whenever::deploy under deploy. For default.rb recipes, once can just add e.g. sphinx instead of sphinx::default. And after changing and pushing to the repositiory, one has to run the update_custom_cookbooks command from the deployments page.

Categories : Ruby On Rails

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

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

OpsWorks overriding database.yml / ignoring custom JSON
Using the short name for the app worked (without hyphens). I was using the full name before. See: https://forums.aws.amazon.com/message.jspa?messageID=444711

Categories : Ruby On Rails

OpsWorks Config Data: TypeError - Symbol as array index
The error is correct: you can't use a symbol as an array index. By the output of you last line, since it starts with a [, it is an array. Most likely you are trying to index the dictionary on the second position of the array with the symbol :private_ip. In this case, the correct line is node[:opsworks][:layers][:admin][:instances].first[1][:private_ip] You need to go step by step in your mind. If node[:opsworks][:layers][:admin][:instances].first returns ["admin1", {"elastic_ip"=>"54.221.245....}] Then node[:opsworks][:layers][:admin][:instances].first[1] will return {"elastic_ip"=>"54.221.245....}

Categories : Ruby

Amazon OpsWorks Custom Cookbooks not updating when using Load-based instances
According to the opsworks documentation: http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-installingcustom-enable-update-.html To manually update custom cookbooks Update your repository with the modified cookbooks. AWS OpsWorks uses the cache URL that you provided when you originally installed the cookbooks, so the cookbook root file name, repository location, and access rights should not change. For Amazon S3 or HTTP repositories, replace the original .zip file with a new .zip file that has the same name. For Git or Subversion repositories, edit your stack settings to change the Branch/Revision field to the new version. On the stack's page, click Run command and select the update custom cookbooks command.

Categories : Amazon

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)
My solution for these kinds of issues was to use a legitimate programming language to compile a template into a CloudFormation JSON document. I used PHP 5.4, Twig and Symfony Console, but YMMV. Essentially, you do the math ahead of time in the programming language, then use that data as you write-out your JSON document.

Categories : Amazon

How can we write a function List multiPop(int k) that pops k elements from the stack or until the stack is empty?
Translate the following concept in to Java: create a list to store the popped members in. while (the stack is not empty and we have to pop more elements) { add a popped member from the stack to the list } return the list. Done

Categories : Java

Disadvantages of increasing Stack Size and difference between Stack Commit and Reserve
The OBVIOUS consequence of increasing the stack-size is more memory usage. Since the stack isn't enormous in comparison to overall memory in most cases, it's not a big issue. Obviously, if there are many threads using large stacks each, then that can amount to a large amount of the available memory in the machine - particularly if the machine hasn't got huge amounts of memory in the first place. "Reserved" space is allocated but not actually physically present until it has been "touched" - in other words, the physical memory space is not allocated for the stack here - just some space taken out of the virtual memory map for the allocation (so, if you are tight on virtual space because your application needs as much memory as it can get in a 32-bit environment, then it may still be a fact

Categories : C++

How to modify the buffer-list using modify-frame-parameters
(frame-parameter 'nil 'buffer-list) returns a list of buffers, not their names; thus you might want to replace (lambda (tab) (buffer-name (tabbar-tab-value tab))) with 'tabbar-tab-value

Categories : Emacs

stack columns in dataframe, and also stack index column
Is this what you're after? In [11]: df1 = df.set_index(['aware', 'aware_2', 'aware_3', 'resp']) In [12]: df1.columns.name = 'heading' In [13]: df1.stack() Out[13]: aware aware_2 aware_3 resp heading 1 0 1 1 respondent a brand volvo engine p country swe age 23 volvo True 0 0 1 2 respondent b brand volvo engine None country swe age 45

Categories : Python

Is the vim clipboard a stack? If yes, how can I paste copied data from that stack?
I wouldn't say it is a stack. it works like stack ( for deletion) . I think you need to take a look "numbered registers". Vim has 0-9 numbered registers. If you think it as a stack, the size of the stack is 9 (1-9) for deletion. Yanked things were stored in register 0 and "", no stack structure. I said it works "stack like" but not stack (for deletion) because, with stack data structure, you could not randomly fetch element. you can just pop or push. but with vim's register, you could get any (0-9) element by "1 "3 "5 for example, and keep the "stack" without changing. read :h registers for detail.

Categories : Vim

How to find the call stack when there is just a corrupt stack corefile?
Displaying the call stack requires correct instruction pointer (eip), stack pointer (esp) and valid stack contents. From your output it looks like the stack had been corrupted and the previous function returned to some random address (eip=0x04229c7a). So, you are out of luck. Try running your program under valgrind.

Categories : C

Stack by pointers in C working except at stack underflow
When you create the stack you allocate space for a node -- and don't fill it with anything. So after the call to create_stack() you have a blank node on your stack already. I guess you don't want that, doing just void create_stack(stack_node **top, int *status) { *top = NULL; *status = PUSH -1; } will work just fine. You allocate the memory during the push() call anyway any you check for top_stack == NULL during the functions. Alternatively you could have a flag in your stack node to indicate it's not used (then during push you'd not create a new one) but that's too complex for what you want here.

Categories : C

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

In linux, all kernel processes share the same kernel stack, each user process has its own stack, correct?
Incorrect. There's one kernel address space, and no kernel processes. There are kernel threads, and there are user space threads that enter the kernel. These run in the kernel address space. Each of these has a separate stack, within the kernel address space.

Categories : Linux

How to append an existing XML file using DOM without overwriting the existing data? in java
It's pretty easy. Say, you want to append new Employees to your XML. Instead of creating a new root you'd simply find it using getElementsByName() like // find root NodeList rootList = doc.getElementsByName("Employees"); Node root = rootList.item(0); Element employee = doc.createElement("employee"); //create new Element root.appendChild(employee); // append as before There's a Document.getElementById() method as well that you could use if an element has been assigned an identifier. To insert something deep down the tree use XPath to find the node first then append() as usual. EDIT : (Sample code added) You can't have two root nodes i.e. two <Employees> tags as root. That's invalid XML. What you need is multiple <Employee> tags inside one single root <Employees> tag.

Categories : Java

Thresholding for tiff stack looks at entire stack instead of individual tiff image
To correct a fluorescence signal bleaching over time, consider using the bleach corrector plugin for ImageJ. When thresholding a stack in ImageJ you can calculate the threshold separately for each slice: Image > Adjust > Threshold... leave Stack histogram unchecked to get a preview for the threshold calculated based on the current slice click on Apply in the dialog, choose Calculate threshold for each image to apply the chosen thresholding method to each stack slice separately. In order to get the macro source code for this procedure, start the ImageJ macro recorder via Plugins > Macros > Record... before starting.

Categories : Matlab

Stack in assembly vs stack in c?
The stacks are exactly the same. One can write a program mixed assembly / C and they use the same stack. The C compiler uses some conventions on how to use the stack : a well-formed stack frame is filled in at each function entry ; and cleaned-up at function leaving. There are compiler directives specific for altering the stack management. For example : gcc stack checking Some references on the web : google : c stack frame In Assembly, the stack has to be managed entirely by the programmer. It is a good practise to have rules on how to manage the stack (and mimicking C rules for example) The stack management instructions are also quite processor dependant (instructions like push and pop on x86, or stmia / ldmfd on ARM. Similarly, some processors have dedicated registers for stack poin

Categories : C

Replace existing content = local storage + existing content. Javascript, WebStorage, LocalStorage
The original script did not provide the means to load the logs from localStorage, and stored new input under the "logs" key, while the intent was to prepend. The solution is quite simple: load from localStorage on page load, and overwrite localStorage['logs'] with the contents of logContents as displayed on the page. .... window.onload = function(){ existing_log = localStorage.getItem("logs"); console.log(existing_log); if (existing_log){document.getElementById("logContent").innerHTML = existing_log;} } function enterPressed() { if (textBox.value == "") { return; } else { var logText = today + ":" + " " + document.getElementById("textBox").value + '<br> '; $("#logContent").prepend(logText); // Prepend textBox's content to the top of

Categories : Javascript



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