Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

Atomic
is the default behavior
will ensure the present process is completed by the CPU, before another process accesses the variable
is not fast, as it ensures the process is completed entirely
Non-Atomic
is NOT the default behavior
faster (for synthesized code, that is, for variables created using @property and @synthesize)
not thread-safe
may result in unexpected behavior, when two different process access the same variable at the same time
4 years ago
For using [(ngModel)] in Angular 2, 4 & 5+, you need to import FormsModule from Angular form...

Also, it is in this path under forms in the Angular repository on GitHub:

angular / packages / forms / src / directives / ng_model.ts

Probably this is not a very pleasurable for the AngularJS developers as you could use ng-model everywhere anytime before, but as Angular tries to separate modules to use whatever you'd like you to want to use at the time, ngModel is in FormsModule now.

Also, if you are using ReactiveFormsModule it needs to import it too.

So simply look for app.module.ts and make sure you have FormsModule imported in...

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; // <<<< import it here
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, FormsModule // <<<< And here
],
providers: [],
bootstrap: [AppComponent]
})

export class AppModule { }
Also, these are the current starting comments for Angular4 ngModel in FormsModule:

/**
* `ngModel` forces an additional change detection run when its inputs change:
* E.g.:
* ```
*
{{myModel.valid}}

*
* ```
* I.e. `ngModel` can export itself on the element and then be used in the template.
* Normally, this would result in expressions before the `input` that use the exported directive
* to have and old value as they have been
* dirty checked before. As this is a very common case for `ngModel`, we added this second change
* detection run.
*
* Notes:
* - this is just one extra run no matter how many `ngModel` have been changed.
* - this is a general problem when using `exportAs` for directives!
*/
If you'd like to use your input, not in a form, you can use it with ngModelOptions and make standalone true...

[ngModelOptions]="{standalone: true}"
4 years ago
Promise

A Promise handles a single event when an async operation completes or fails.

Note: There are Promise libraries out there that support cancellation, but ES6 Promise doesn't so far.

Observable

An Observable is like a Stream (in many languages) and allows to pass zero or more events where the callback is called for each event.

Often Observable is preferred over Promise because it provides the features of Promise and more. With Observable it doesn't matter if you want to handle 0, 1, or multiple events. You can utilize the same API in each case.

Observable also has the advantage over Promise to be cancellable. If the result of an HTTP request to a server or some other expensive async operation isn't needed anymore, the Subscription of an Observable allows to cancel the subscription, while a Promise will eventually call the success or failed callback even when you don't need the notification or the result it provides anymore.

While a Promise starts immediately, an Observable only starts if you subscribe to it. This is why Observables are called lazy.

Observable provides operators like map, forEach, reduce, ... similar to an array
4 years ago
Instead of injecting ElementRef and using querySelector or similar from there, a declarative way can be used instead to access elements in the view directly:


@ViewChild('myname') input;
element

ngAfterViewInit() {
console.log(this.input.nativeElement.value);
}
4 years ago
You can use [attr.data-index] directly to save the index to data-index attribute which is available in Angular versions 2 and above.


  • {{item}}

  • 4 years ago
    this below code will change datatype of column.

    df[['col.name1', 'col.name2'...]] = df[['col.name1', 'col.name2'..]].astype('data_type')
    in place of data type you can give your datatype .what do you want like str,float,int etc.
    4 years ago
    Using the Standard C++ Library: std::bitset.

    Or the Boost version: boost::dynamic_bitset.

    There is no need to roll your own:

    #include
    #include

    int main()
    {
    std::bitset<5> x;

    x[1] = 1;
    x[2] = 0;
    // Note x[0-4] valid

    std::cout << x << std::endl;
    }
    [Alpha:] > ./a.out
    00010
    The Boost version allows a runtime sized bitset compared with a standard library compile-time sized bitset.
    4 years ago
    append-adds its argument as a single element to the end of a list. The length of the list itself will increase by one.
    extend-iterates over its argument adding each element to the list, extending the list. The length of the list will increase by however many elements were in the iterable argument.
    4 years ago
    1. Static defined local variables do not lose their value between function calls. In other words they are global variables, but scoped to the local function they are defined in.

    2. Static global variables are not visible outside of the C file they are defined in.

    3. Static functions are not visible outside of the C file they are defined in.
    4 years ago
    React:

    React is a declarative, efficient, and flexible JavaScript library for building user interfaces.

    React Native:

    React Native lets you build mobile apps using only JavaScript. It uses the same design as React, letting you compose a rich mobile UI from declarative components.
    With React Native, you don't build a “mobile web app”, an “HTML5 app”, or a “hybrid app”. You build a real mobile app that's indistinguishable from an app built using Objective-C or Java. React Native uses the same fundamental UI building blocks as regular iOS and Android apps. You just put those building blocks together using JavaScript and React.
    React Native lets you build your app faster. Instead of recompiling, you can reload your app instantly. With hot reloading, you can even run new code while retaining your application state. Give it a try - it's a magical experience.
    React Native combines smoothly with components written in Objective-C, Java, or Swift. It's simple to drop down to native code if you need to optimize a few aspects of your application. It's also easy to build part of your app in React Native, and part of your app using native code directly - that's how the Facebook app works.

    So basically React is UI library for the view of your web app, using javascript and JSX, React native is an extra library on the top of React, to make a native app for iOS and Android devices
    4 years ago
    setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules.

    This allows you to easily install Python packages. Often it's enough to write:

    $ pip install .
    pip will use setup.py to install your module. Avoid calling setup.py directly.
    4 years ago
    Type[] variableName = new Type[capacity];

    Type[] variableName = {comma-delimited values};



    Type variableName[] = new Type[capacity];

    Type variableName[] = {comma-delimited values};
    is also valid, but I prefer the brackets after the type, because it's easier to see that the variable's type is actually an array.
    4 years ago