w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Assigning values to a public byte array in one line C#
Your first example is fine but it may only be used in a declaration. The elements must be implicitly convertible to the element type. The size is determined from the number of elements given. byte[] foo = { 0x32, 0x00, 0x1E, 0x00 }; Alternatively you can also d this byte[] foo = new byte[4]; foo[0] = 0x32; foo[1] = 0x00; foo[2] = 0x1E; foo[3] = 0x00; as stated above that the syntax that you are trying to use can only be used in a declaration. so try like this. public byte[] SetSpeed; private void trackBar1_Scroll(object sender, EventArgs e) { if (trackBar1.Value == 0) { try { stop = true; UpdateSThread.Abort(); Thread.Sleep(350); } catch { } //note it will always create a new array SetSpeed

Categories : C#

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

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

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

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

Is there any pattern that provide similarities of public static, private and public methods and vars in JS?
"Static" methods in JavaScript are usually achieved by simply assigning a function to a property of the constructor function object: function MyClass() {} // Constructor MyClass.staticMethod = function () {};

Categories : Javascript

Singleton object w/ Private/Public: Public function dependency problems
You can simply define the functions inside (or alongside) the constructor and just "attach" them to the new instance. This way the functions are free to refer to one another as required: function PKMNType_Engine(){ "use strict"; function getEffectiveness(defenseType, offenseType){ return 1; } return { PKMNTypes_getEffectivness: getEffectiveness, PKMNTypes_getMatchup: function(type1, type2, offensiveType){ var output = getEffectiveness(type1, offensiveType) * getEffectiveness(type2, offensiveType); return output; } }; }

Categories : Javascript

Are "public" and "public final" redundant for interface methods?
You cannot have a final method declared in an interface. Fields are always final but methods are always abstract (and never final). You cannot define an interface method that is to be implemented only by classes in the same package.* From section 9.3 of the Java Language Specification: Every field declaration in the body of an interface is implicitly public, static, and final. It is permitted to redundantly specify any or all of these modifiers for such fields. and from section 9.4: Every method declaration in the body of an interface is implicitly public (§6.6). Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block. It is permitted, but discouraged as a matter of style, to redundantly

Categories : Java

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

Cannot access public field on public inner class
The A character in int А = new Main2().А; is not a UTF-8 character, and is not the same as the one used in the variable name in the Main2 class. Copy-paste the A from the inner class and use that. It will compile.

Categories : Java

PHP OpenSSL Public Key Encryption With String Public Key
The key that you should pass to this function is a PHP resource object, and not the string representation of the key itself. $pubkey = openssl_get_publickey(base64_decode($row['public_key'])); $success = openssl_public_encrypt($data, $encrypted, $pubkey);

Categories : PHP

Assigning tasks to threads in Cilk and assigning threads to NUMA nodes
The correct way to do this in Cilk would be something like: void task1_task2_task3() { cilk_spawn task1(); cilk_spawn task2(); task3(); } void task4_task5_task6() { cilk_spawn task4(); cilk_spawn task5(); task6(); } void task7_task8_task9() { cilk_spawn task7(); cilk_spawn task8(); task8(); } int main() { cilk_spawn task1_task2_task3(); cilk_spawn task4_task5_task6(); task7_task8_task9(); cilk_sync; finalize_stuff(); return 0; } Remember that cilk_spawn is a suggestion to the scheduler that the code after the cilk_spawn can be stolen, not a requirement. When a cilk_spawn is executed, it pushes a notation on tail of the worker's deque that the continuation is available for stealing. Thieves always steal from the head of the

Categories : Multithreading

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

Rails public profile creation and determining whether profile is public or not
How about this: User Model after_update :update_public_status! def update_public_status! required_fields_present = [ name, state, city, high_school, recruit_year, birthday, stat(:height), stat(:weight) ].all? if required_fields_present make_public! else make_private! end end def make_public! update_attribute :public, true update_attribute :removed_from_listing, false end def make_private! update_attribute :public, false update_attribute :removed_from_listing, true end

Categories : Ruby On Rails

integrate "public final class" into "public class"
Cou can combine them as following: public class GPSTracker extends Activity implements LocationListener { } and put all your code of both classes into this one. The onCreatOptionsMenu is only necessary if you're using a menu. The onCreate should be used because your GPSTracker class is an Activity.

Categories : Android

OOP Javascript - Accessing a privileged method from public method via another public method
var Person = function (name, age) { this.name = name; this.age = age; } Person.prototype.scream = function () { // get function screamAge from container WhatToScream, // which is available in the instance of the object, // because it was defined in the prototype // and then call it with thisArg being current this, // which is pointing to current container, // * which at runtime is man this.WhatToScream.screamAge.call(this); } Person.prototype.WhatToScream = { screamAge: function () { alert('I AM ' + this.age + ' YEARS OLD!!!'); }, screamName: function () { alert('MY NAME IS ' + this.name + '!!!') } } var man = new Person('Berna', 21); man.scream(); If you want to keep WhatToScream as a function, you will need to cal

Categories : Javascript

Difference between 'public static' and 'static public'
From the Java Language Specification, section 8.4.3: If two or more (distinct) method modifiers appear in a method declaration, it is customary, though not required, that they appear in the order consistent with that shown above in the production for MethodModifier. So they can appear in any order, but there is a recommended ordering. The order is: Annotation public protected private abstract static final synchronized native strictfp

Categories : Java

Call a public method of a class, from a public method of another class
How can I call methodOne from methodTwo? You need to access the instance on which you want to call the method (you could as well get it from the prototype and apply on some arbitrary object but I guess that's not what you want). To make it known in the scope of the methodTwo, pass it as a parameter to the function: ClassTwo.prototype.methodTwo = function (one) { one.methodOne(); }; … var classOne = new ClassOne(); var classTwo = new ClassTwo(); classTwo.methodTwo(classOne);

Categories : Javascript

Different Way for assigning value to a variable in SQL
Would this fit your need ? (Using a CTE: http://msdn.microsoft.com/en-us/library/ms175972.aspx. I wrote it partially in Notepad++ so I hope there aren't syntax error.) The CTE tASD (stands for tblAssetSubscriptionDetails) gathers only the rows that will be useful. EXISTS should normally be better than Count() > 0 since it doesn't actually need to count everything. WITH tASD(AssetMgmtId, IMEINumber, PhoneNo, SIMNo) AS ( SELECT AssetMgmtId, IMEINumber, PhoneNo, SIMNo FROM tblAssetSubscriptionDetails WHERE AssetMgmtId <> @Id AND ( IMEINumber = @IMEINumber OR PhoneNo = @PhoneNo OR SIMNo = @SIMNo ) ) SELECT @Message = ( CASE WHEN EXISTS (SELECT null FROM tASD WHER

Categories : Sql Server

Assigning .value to CSS style
like so: HTML <div id = "one"></div><div id = "two"></div><div id = "three"></div> Javascript var bordRad = parseInt(document.getElementById("BD").value, 10); document.getElementById("one").style.borderRadius = bordRad + "px"; i may have misunderstood your question though, please clarify, and/or add some of your code.

Categories : Javascript

assigning one shared_ptr to another
Yes, pA does not point to the char 'A' anymore, so the reference count is decremented. As it was the only reference to 'A', the reference count reaches zero and the char is deleted. It would be highly surprising and error-prone if you'd have to explicitly release the reference before reassignment. pA.reset(pB) should not compile, as reset can only take a raw pointer, not another shared_ptr.

Categories : C++

Assigning double * to V[3]
addVectors returns a pointer to a local array, when addVectors returns val becomes garbage data. you could pass in third parameter to addVectors, you need to make sure all vec have at least 3 elements though: void addVectors( double* vec1, double* vec2, double* vec) { for( int i = 0; i < 3; i++ ) vec[i] = vec1[i] + vec2[i]; } double A[3] = {1, 2, 3}; double B[3] = {4, 5, 6}; double C[3] = {}; // initialize all C elements to 0.0 addVectors(A,B,C); My Suggestion is use STL container like std::vector, std::list etc, or use st::array if C++11 is enabled. With STL container could archive your intention: std::vector<double> addVectors(const std::vector<double>& v1, const std::vector<double>& v2) { std::

Categories : C++

Assigning data to cv::Mat
You can just reassign a pre-initialized cv::Mat to new image data. Here are a few legal ways of assigning new image data to a cv::Mat that was already created. cv::Mat my_mat = cv::imread("some_image.jpg"); my_mat = cv::imread("another_image.jpg"); cv::Mat second_mat = cv::imread("one_more.jpg"); second_mat = my_mat.clone();

Categories : C++

Assigning a GUID in C#
If you already have a string representation of the Guid, you can do this: Guid g = new Guid("11223344-5566-7788-99AA-BBCCDDEEFF00"); And if you want a brand new Guid then just do Guid g = Guid.NewGuid();

Categories : C#

Assigning std::shared_ptr
std::shared_ptr does not let you assign a plain pointer to it directly. When you think about, there are quite convincing reasons to disallow it implicitly happening. First of all, shared_ptr needs an (external, in general) reference counter to be allocated. Consider for example the following (hypothetical) code: std::shared_ptr<A> p1 = obj; std::shared_ptr<A> p2 = obj; What happens when the pointers fall out of scope? Each assignment creates its own reference counter, since there is no way p2 can know about the one created by p1. In effect, obj is deleted twice - UB. Preferred solution is to use library function std::make_shared. It offers a number of benefits over wrapping externally created object: counter is created in the same heap chunk as the object, hence the over

Categories : C++

ReferenceField assigning
current_user.pk has ObjectId type (just id, no info about collection). current_user has LocalProxy type. You can't save reference as ObjectId because there are no information about reference collection and mongo use for this BDRef. You can get DBRef object from mongoengine document with Document.to_dbref method. So mognoenginge check type to get DBRef explicitly or get it from document with to_dbref. For current_user you can call to_dbref to get DBRef object or _get_current_object() to get real User object.

Categories : Misc

Assigning int value to an address
Your both expressions are incorrect, It should be: int x, *ra; ra = &x; // pointer variable assigning address of x & is ampersand is an address of operator (in unary syntax), using & you can assign address of variable x into pointer variable ra. Moreover as you question title suggests: Assigning int value to an address. ra is a pointer contains address of variable x so you can assigning an new value to x via ra *ra = 20; Here * before pointer variable (in unary syntax) is deference operator gives value at the address. Because you have also tagged question to c++ so I think you are confuse with reference variable declaration, that is: int x = 10; int &ra = x; // reference at time of declaration Accordingly in case of reference variable, if you wants to as

Categories : C++

Shorthand for assigning variables
TypeScript will allow you to cast the item in this case... although this means that test1 and test2 are the same object. interface Foo1 { a: string; b: boolean c: Object; } interface Foo2 extends Foo1 { d: number; } var test1: Foo1 = { a: '...', b: true, c: {} }; var test2: Foo2 = <Foo2> test1; test2.d = 1; If you want a copy, not the same object, you can create a method to copy the object's properties. Here is an example of a copy: var test1: Foo1 = { a: '...', b: true, c: {} }; var test2: Foo2 = <Foo2>{}; for (var variable in test1) { if( test1.hasOwnProperty( variable ) ) { test2[variable] = test1[variable]; } } With a little hint of generics, you can encapsulate this in a static helper method, like this: class ObjectHelper { st

Categories : Typescript

Assigning a Function into an Array
While im not 100% sure what you're asking you can place return values of functions anywhere you like. function roots_widgets_init() { register_sidebar(array( 'name' => __('Footer', 'roots'), 'id' => 'sidebar-footer', 'before_widget' => '<section class="widget span4 %1$s %2$s"><div class="widget-inner">', 'after_widget' => '</div></section>' . get_after_section(), 'before_title' => '<h3>', 'after_title' => '</h3>', )); } Will append the return value of get_after_section to the current value of 'after_widget'.

Categories : PHP

Javascript assigning value to variable
IMPORTANT: All JavaScript developers should know this. It will cause all kinds of weird bugs that is very hard to find. It is a common mistake of people who are new to JavaScript. I've made the same mistake before. A function inside a loop is NOT created for every iteration. It is the same one function object with the same closure scope. Thus, your cells will have the exact same onclick callback. My advice here is NEVER EVER create a function inside of loop. Instead, create and call a function that returns a callback function and assign it to onclick. for (var j = 0; j < 8; j++) { var cell = row.insertCell(j); cell.name = j; cell.onclick = createOnClick(cell); } function createOnClick(cell) { return function () { // do whatever you want to do with cell }

Categories : Javascript

ACL Error when assigning AD Rights
According to the error "Some or all identity references could not be translated.", it looks like the user with such still not exist in the Directory (or in the Directory the computer is connected to) when you try to use it. I would try to first look for the user in the directory before trying to use it. Check the value of $Account before using it.

Categories : Powershell

Re-assigning String variables
You'll want to use an ArrayList if you need to store the data. An ArrayList is just like an array, except that it grows dynamically as you add elements to it. Define it with: List<String> myList = new ArrayList<String>(); Then as the user enters something, write myList.add(someStringVariable);

Categories : Java

Automatically assigning a value to a Guid
if you want a new GUID every time use Guid guid = Guid.NewGuid(); If you want a specific guid use (wrt your example) Guid guid = new Guid("914aaa44-4e11-e311-96f7-d8d3855b1531");

Categories : Asp Net

Assigning a value for view asynchronously
Is this what you're going for? exports.index = function(req, res){ var deck = require('./../deck'); // No .js required deck.drawCard(function(err, card) { if(err) { res.render('error'); return; } res.render('index', { title: 'Bits AH', card: card }); }); }; You're wrapping the res.render call inside the callback to the drawCard function because you can't return until after the function is completed. It's possible however to load those files when the module is initialized, and then you can convert your drawCard function to be synchronous and then you could use it like you have in your example.

Categories : Javascript

Assigning 'wrap_content' or '-2' to dimension
As far as I'm aware you can't. Here are valid dimension types: http://developer.android.com/guide/topics/resources/more-resources.html#Dimension A dimension value defined in XML. A dimension is specified with a number followed by a unit of measure. For example: 10px, 2in, 5sp Valid units: dp, sp, pt, px, mm, in I would just put wrap_content directly in my xml layout or style since wrap_content is wrap_content whatever device/configuration you have.

Categories : Android

Boost::tuple - assigning to get<>()
From the looks of it, you try to assign a std::pair<std::string const, std::string> to a std::string. This won't work. Did you mean to write this? t.get<1>() = i->first;

Categories : C++

Python - RadioButton - assigning a value i can use?
First off, are you missing some code in your example? possibly a Starter initialisation in the App class? I get a traceback if I try to run: Traceback (most recent call last): File "test.py", line 165, in <module> main() File "test.py", line 160, in main app = App(root) File "test.py", line 10, in __init__ self.create_widgets() File "test.py", line 57, in create_widgets variable = self.Starter.menue, value = 55, command =self.determine_order AttributeError: App instance has no attribute 'Starter'

Categories : Python

Why are my properties assigning incorrectly?
When using loops like that you need to wrap it in an enclosure function ObservablePropertyList(nameCallbackCollection) { var propertyList = {}; for (var index in nameCallbackCollection) { (function(target){ var private_value = {}; propertyList["get_" + index] = function () { return private_value; } propertyList["set_" + index] = function (value) { // Set the value private_value = value; // Invoke the callback target(value); } })(nameCallbackCollection[index]); } return propertyList; }

Categories : Javascript

Assigning Multiple ips to a NIC using powershell
You want to call the EnableStatic method on the instance of the Win32_NetworkAdapterConfiguration WMI class for the network interface you want to configure. uint32 EnableStatic( [in] string IPAddress[], [in] string SubnetMask[] ); You can see above it takes two parameters. A string array of IP addresses and a string array of subnet masks. It will return an status code. 0 indicates success. Here is PowerShell example code: Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=true" | ForEach-Object { $result = $_.EnableStatic(("192.168.1.10","10.0.0.10"),("255.255.255.0","255.0.0.0")) if ($result -ne 0) { # handle non-successful response code here. } }

Categories : Powershell



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