object-oriented – Instance of code smell

The use of example of could be a smell of code and i'm in front of the following code that looks ok. Do you consider that example of should not be used in such a case? What would be the reason to use?

private accounts;
} else if ($ account instanceof PublicAccount) {
$ haystack = $ this-> publicAcounts;
}

foreach ($ haystack like $ someAccount) {
if ($ account-> getId () == $ someAccount-> getId ()) {
return true;
}
}
returns false;
}
}

To be more precise, $ private accounts and $ publicCounts are objects that will be lazy loaded by an ORM from a relational database, calling getId () is expensive (each call results in a database request). PublicAccount and PrivateAccount are two tables in the database.

Using $ haystack = array_merge ($ privateAccounts, $ publicAccounts) would remove the use of example of but would have a performance cost.

angular – The "value" must be a valid JavaScript date instance. When using the kendo date picker

I'm trying to store in the database a date via the kendo date selector component that it sends to my bank in this format:

2019-07-23T00: 00: 00

When I look for it at the bank and give it value through the

formcontrol.setValue ()

I receive:

Error: The value & # 39; Must be a valid JavaScript date instance. Check
http://www.telerik.com/kendo-angular-ui/components/dateinputs/datepicker/#toc-using-with-json
for a possible resolution.

That's the amount that comes from my bank: 2019-07-25T00: 00: 00


I've already tried to get the value and let the formControlName added, but there were no differences.

design templates – Which form of unique instance class for an Android cache?

The application must communicate with a Bluetooth device with matching data (configuration, metrics, service logs, status telemetry) – and must cache the resulting data so that the user does not go from one activity to another. other. previous activity, or the data was obtained in a previous activity (for example, the activity "Summary" consists of retrieving pieces of data from others).

This means a cache object that should contain this data – and be a single instance class.

It has come to my mind that singletons are bad. But with Android applications having multiple entry points, I can not guarantee a single initialization path for the application or the lifetime of the object. So I do not know if the singleton is still wrong here – or if so, how do we approach the single instance class on the right in this scenario. What form of single-instance object should I use to boot it to creation and access it everywhere?


Xamarin, C #, if that is important.

Availability Groups – Error in the WSFC Role When Applying SQL 2016 CU7 in a Multiple Instance SQL Environment

Please advise on the following error:

The Cluster Resource & # 39; AG1_NAME & # 39; of type 'SQL Server Availability Group & # 39; in the clustered role & # 39; AG1_NAME & # 39; failed`

Depending on the failure policies for the resource and the role, the Cluster service may try to put the resource online on that node or move the group to another node in the cluster and then restart it. Check the resource and the status of the group using the failover cluster manager or the Windows PowerShell cmdlet Get-ClusterResource.

Environment:

AG1: (primary = SRV01 DEV1, secondary = SRV02 DEV1, SRV03 DEV1)
AG2: (primary = SRV02 DEV2, secondary = SRV03 DEV2, SRV01 DEV2)

The error occurred while updating AG2 replicas with SQL SERVER 2016 SP2 CU7, which corresponded to SQL Server 2016 SP2 CU4.

Update the order as follows, and there was no error during the update wizard

  1. Set the switch to manual on SRV01 DEV2
  2. Update SRV01 DEV2Notice the WSFC error (mentioned above) here
  3. Set the failover to Auto on SRV01 DEV2
  4. Set the switch to manual on SRV03 DEV2
  5. Update SRV03 DEV2
  6. Set the failover to Auto on SRV03 DEV2
  7. Manual switching from SRV02 DEV2 (Primary) to SRV03 DEV2
  8. Update SRV02 DEV2
  9. Manually fail at SRV02 DEV2 (Primary) of SRV03 DEV2

Is it normal that when updating the second instance of SQL Server, the first instance should be interrupted when the server is involved in availability groups, or should we follow a particular method in this case to avoid any errors? as is.

Fortunately, especially AG1 and all WSFC resources were working normally when I looked immediately (after the error) on the WSFC Manager Roles page. also PowerShell Get-ClusterResource. but I am concerned about the production update and future updates. Any suggestions would be appreciable. Thank you!

Amazon Web Services – Removing and then reinstalling Anaconda on an AWS Ubuntu Deep Learning EC2 instance and unable to enter in-depth learning environments

I just set up an Ubuntu Deep Learning AMI EC2 instance. I am a beginner on AWS / Packet Processing.

My goal is to use the instance to run a Python deep learning script. This script uses a variety of packages.

When installing some of these packages with conda, an error has occurred indicating inconsistencies in the environment for more than 100 packages. After several attempts to solve this problem, I thought that removing Anaconda and reinstalling it could do the trick. After that, I realized that I had perhaps further spoiled my instance. I can no longer use the predefined deep learning environments for which the AMI has been configured because they have been accessed using conda commands, which seems to have been removed (IMO).

I've tried repeating the commands, but I get an error stating that these environments no longer exist. A tutorial using these commands is mentioned here:
https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-conda.html

active source tensorflow_p36

I was expecting the above to enter the tensorflow_p36 environment. A sin:

(tensorflow_p36) ubuntu @ ip-172-31-45-96: ~ / scripts

However, this gives an error message:

impossible to find the environment: tensorflow_p36

I realize that the uninstallation of conda was a major rookie error that seems to have totally disabled my instance. If anyone has any ideas to get it back, it would be very appreciated!

thank you so much

jquery – How to empty the instance of CKEDITOR by Angularjs after submitting AJAX?

I have a form with a textarea to initiate an instance of CKEDITOR, then I write an Angularjs directive to bind the value in the instance of ckeditor to model, it works fine. After sending the form with AJAX and the response with status 200, I want to reset the form (the CKEDITOR instance data is also empty), but when CKEDITOR.instances.editor.setData (& # 39;), then the browser gives me the error:

Error: $ rootScope: inprog
Action already in progress

Code of the directive:

app.directive (& # 39; ckeditor & # 39 ;, function () {
return {
Restrict: 'A',
link: function ($ scope, element, attr, ngModel) {
var ckeditor = CKEDITOR.replace (element[0].id); // The id is & # 39; editor & # 39;
ckeditor.on (& # 39; change & # 39; function () {
var content = this.getData ();
$ scope.dataContent.content = content;
$ scope. $ apply ();
})
}
}
});

Controller code:

$ scope.addContent = function () {
$ http.post (...., $ .param ($ scope.dataContent), {headers: {Content-Type: application / x-www-form-urlencoded & # 39; # 39;}})) then (function (answer) {
var res = response.data;
if (res.status === 200) {
msgSuccess (res.message);
CKEDITOR.instances.editor.setData (& # 39;); // This line is problematic.

} other {
msgError (& # 39; An error occurred & # 39;);
}
});
};

Amazon Web Services – How to make my Airflow EC2 HTTPS instance?

I'm using Apache Airflow on an AWS EC2 instance and listening on port 8081,
http://ec2-X-XX-YYY-ZZZ.compute-1.amazonaws.com:8081/

How can I make this Airflow instance use HTTPS? I followed the instructions here: Configuring HTTPS in Amazon EC2 and made changes to the security group, but I did not do anything for my instance (I did not restart my EC2 server).

Is there anything I miss here?

Why can not I use the gcsfuse command on an instance of Google with preinstalled GPU and TF, etc.?

My goal is to mount a Google storage compartment in my Google Compute instance computer.

I created a Google Compute instance of type

c2-deep learning-TF-1-14-CU100

He came with various preinstalled libraries, including CUDA, CuDNN, TensorFlow and GCFS (Python).
After creating it, I followed the instructions for the installation of gcsfuse order. No mistakes have been made. However, during any attempt to use gcsfuse command in bash I get the following error:

: I tensorflow / stream_executor / platform / default / dso_loader.cc: 42]Dynamic library successfully opened libcudart.so.10.0
Traceback (last most recent call):
File "/ usr / local / bin / gcsfuse", line 7, in 
    from gcsfs.cli.gcsfuse main import
File "/usr/local/lib/python3.5/dist-packages/gcsfs/cli/gcsfuse.py", line 3, in 
    fuse import FUSE
File "/home/user/.local/lib/python3.5/site-packages/fuse/__init__.py", line 3, in 
    since .defect_augment import DefectAugment
File "/home/user/.local/lib/python3.5/site-packages/fuse/defect_augment.py", line 11, in 
    import of BatchFilter gunpowder
File "/home/user/.local/lib/python3.5/site-packages/gunpowder/__init__.py", line 3, in 
    of. import nodes
File "/home/user/.local/lib/python3.5/site-packages/gunpowder/nodes/__init__.py", line 3, in 
    from .add_affinities import AddAffinities
File "/home/user/.local/lib/python3.5/site-packages/gunpowder/nodes/add_affinities.py", line 6, in 
    from gunpowder.ext import malis
File "/home/user/.local/lib/python3.5/site-packages/gunpowder/ext/__init__.py", line 51, in 
    increased imports
File "/home/user/.local/lib/python3.5/site-packages/augment.py", line 181, in 
    def _surround (aux_fn, around = False, forward = False, after = False):
File "/home/user/.local/lib/python3.5/site-packages/augment.py", line 130, decorator
allargs, fn_name = _get_args_and_name (fn)
File "/home/user/.local/lib/python3.5/site-packages/augment.py", line 37, in _get_args_and_name
code = fn.func_code
AttributeError: The object 'function & # 39; does not have attribute 'function_code & # 39;

It appears not only when I try to mount a bucket in my machine, but even at the call gcsfuse --help.

I guess, because the error is clearly Pythonic and not Go-like, maybe the preinstalled Python GCSFs are somehow corrupt here. However, according to the documentation, the GCSF should also allow the use of bash gcsfuse order.

Any help greatly appreciated. Thank you!

More than 100 databases in one instance or divide and conquer: MariaDb Ubuntu 64bits

I have an office application (over 100 clients and more to come) running on the local small server of the client, all of which have the same structure in tables (different information). I migrate this application to the Web (almost done) and I need to store all these databases on a new server: Xeon 4cores 4 ghz, 64 GB of RAM, 1 TB of SDB memory. What could be the best approach for handling information correctly: 1 instance for all databases or multiple instances with few databases? each database contains 150 tables, with a few thousand records and some with 100,000 records. At the moment, I have an instance with 13 databases that works pretty well, but I'm not sure that 100+, any advice is appreciated.

google cloud platform – How to start an instance from another instance in the same project (GCP)

I have 2 instances in one project in GCP. One needs to be turned on and off at will from the other one. So inside one instance I try to use gcloud compute instances start instance1 --zone==us-east1-b and I get ERROR: (gcloud.compute.instances.start) HTTPError 403: Insufficient Permission: Request had insufficient authentication scopes.

I’ve made a custom role with compute.instances.start permission and gave it to every user trying to get it to work but I still get the same error. Can someone point me into the right direction to resolve this?