SSRS randomly gets error for parameter - solution is to rebuild report...then it happens again Posted: 27 Apr 2021 07:49 AM PDT I am pretty experienced in SSRS, I have been doing it for quite some time so I know when I see the error: "An error has occurred during report processing. (rsProcessingAborted) An attempt was made to set a data set parameter '@SiteId' that is not defined in this data set. (rsUnknownDataSetParameter)" I know what causes this error and can fix it. However, this error randomly happens every so often. What I end up doing is simply rebuilding the project and redeploying it and all is well for a few days, then suddenly again this same error will pop up again. I know there is no issue with the parameter as I have a @SiteId parameter as shown: So when I get an email from a user that "The Report Is Down" I just go to my report and rebuild and republish and the error vanishes without ANY other changes. A few days later when they want to run the report again this same error happens. What is causing this issue to come back over and over. We are running SQL Server 2016 with SSRS. It happens to ANY one of my reports on the report server. Its not a specific project it randomly happens on any project. |
MPI One Sided Message Epochs Posted: 27 Apr 2021 07:49 AM PDT We're tuning a benchmark that relies upon MPI windows and one-sided messages. We've found some rather bizarre behavior with respect to the benchmark as a function of how often we nudge the window epochs using MPI_Win_fence calls. Is there a standard methodology to tune the frequency by which to fence the window? Consider the following pseudocode: MPI_Win_fence(0,AWin); for( i=0; i<iters; i++ ){ MPI_Compare_and_swap(...) if( (i%Foo) == 0 ){ MPI_Win_fence(0, AWin); } } MPI_Win_fence(0,AWin); In this case, is there a way to derive an optimal Foo based upon the number of MPI ranks? Assume that this window is enabled for MPI_COMM_WORLD and all ranks are participating in the same loop. iters in this case is >= 100,000 (and growing to 1M+). What we've found is, for small numbers of ranks distributed uniquely across nodes (purely distributed memory), the benchmark hangs on fencing the windows and never completes. We've tried modulos of Foo as 10, 50, 100, 1000, etc. All hang when using two ranks across two nodes. However, the same benchmark running across three nodes (same algorithm, same values of Foo ), the benchmark runs to completion fine. We're currently using OpenMPI 4.1.0 compiled using GCC 7.5.0 running over 1GbE. |
Has Clarifai stopped supporting Javascript? Posted: 27 Apr 2021 07:49 AM PDT |
R: Issues when pulling values from a nested list into a dataframe Posted: 27 Apr 2021 07:49 AM PDT so this should be a relatively easy question on pulling items in a list into a dataframe, but I'm stuck on something. I have the following list (I'm showing just part of the list for you, it's far longer than this): str(raw_jobs_list) List of 2 $ :List of 4 ..$ id : chr "3594134" ..$ score : int 1 ..$ fields:List of 16 .. ..$ date :List of 3 .. .. ..$ changed: chr "2020-04-18T00:35:00+00:00" .. .. ..$ created: chr "2020-04-07T11:15:37+00:00" .. .. ..$ closing: chr "2020-04-17T00:00:00+00:00" .. ..$ country :List of 1 .. .. ..$ :List of 6 .. .. .. ..$ href : chr "https://api.reliefweb.int/v1/countries/149" .. .. .. ..$ name : chr "Mali" .. .. .. ..$ location :List of 2 .. .. .. .. ..$ lon: num -1.25 .. .. .. .. ..$ lat: num 17.4 .. .. .. ..$ id : int 149 .. .. .. ..$ shortname: chr "Mali" .. .. .. ..$ iso3 : chr "mli" .. ..$ title : chr "REGIONAL MANAGER West Africa" I tried pulling them out using: jobs_data_df <- list.stack(list.select(raw_jobs_list, fields$title, fields$country$name, fields$date$created)) Where raw_jobs_list is the list, but I get these NAs and am not sure how to get past it. glimpse(jobs_data_df) Rows: 2 Columns: 3 $ V1 <chr> "REGIONAL MANAGER West Africa", "Support Relief Group Public Health Advisor (Multiple Positions)" $ V2 <lgl> NA, NA $ V3 <chr> "2020-04-07T11:15:37+00:00", "2020-05-04T15:20:37+00:00" It's possible there's something obvious I'm overlooking as I haven't worked much with lists before. Any ideas? Thanks so much! C PS. If you're interested, I'm working with this API. "https://api.reliefweb.int/v1/jobs?appname=apidoc&preset=analysis&profile=full&limit=2" |
How can find a USB flash drive's path on Android with NDK? Posted: 27 Apr 2021 07:49 AM PDT I want to detect a USB flash drive and copy some files to this storage device. How can I find this device's path on Android by using C? |
Tkinter after_cancel method is not working and is blocking button python Posted: 27 Apr 2021 07:49 AM PDT from tkinter import * import tkinter as tk from multiprocessing import Process import time def notify(text): notify_heading_text.set(f"App : {text}") def on_restart(): global callId callId = root.after(100,print_hi) def on_stop(): print("Stopping") global callId if callId is not None: root.after_cancel(callId) callId = None def print_hi(): print("Task is begining") time.sleep(10) print("task over") if __name__ == '__main__': root = Tk() # root = Tk() root.geometry('400x400') root.resizable(0, 0) global notify_heading_text fact = "tree is infact intact" notify_heading_text = tk.StringVar() notification1 = Label(height=1, textvariable=notify_heading_text, bd=0) notification1.pack(fill=X, side=TOP) notification1.configure(bg='white', fg='black', font=('Helvetica', 12, 'bold'), pady=10) bind2 = tk.StringVar() bind3 = tk.StringVar() b2 = Button(root, borderwidth=0, fg="white", activebackground='#40556a', activeforeground='white', bg="black", textvariable=bind2, command=on_stop, font=('Helvetica', 12, 'bold'), padx=10, pady=6) bind2.set('Stop') b2.pack(side=LEFT) b3 = Button(root, borderwidth=0, fg="white", activebackground='#40556a', activeforeground='white', bg="black", textvariable=bind3, command=on_restart, font=('Helvetica', 12, 'bold'), padx=10, pady=6) bind3.set('Restart') b3.pack(side=RIGHT) root.mainloop() As I run the above program and press the 'Restart' button on_restart() method is called which with help of Tkinter's root.after() method, in turn, calls the print_hi() method. The problem is I can't stop the program when print_hi() is still in execution(i.e in this case it is sleeping) and the stop button is jammed and gets only executed when print_hi() method gets complete. The stop button does not work and only works after print_hi() method gets completed. The question is how to stop the program with the stop button. I used thread in place of the after method but was not able to update text inside label it, issue:Not able to update text in tkinter python |
Crop images from a folder, process the images, and then save the images Posted: 27 Apr 2021 07:49 AM PDT First post and relatively new to python I am looking to loop through a folder of images, crop a section/ROI, apply some processing techniques, and then save the new image somewhere. I have working code to crop and save multiple images in the loop (see code block 1). However, I can't seem to get the saving aspect after the processing to work (see code block 2). It provides the following error for the final line...AttributeError: 'numpy.ndarray' object has no attribute 'save'. I'm probably (hopefully) being really stupid and it's an easy fix. Thanks in advance for any help Code Block 1 - Works fine for cropping a folder of images and saving filepath = '/some/file/path/Frames/' for filename in os.listdir(filepath): if "." not in filename: continue ending = filename.split(".")[1] if ending not in ["jpg", "gif", "png"]: continue try: image = Image.open(os.path.join(filepath, filename)) except IOError as e: print("Problem Opening", filepath, ":", e) continue image = image.crop((535, 40, 600, 90)) name, extension = os.path.splitext(filename) print(name + '_cropped.jpg') image.save(os.path.join('/some/file/path/Frames/Cropped', name + '_cropped.jpg')) Code Block 2 - Trying to incorporate the image processing before saving but struggling/getting the error I mentioned above filepath = '/some/file/path/Frames/' for filename in os.listdir(filepath): if "." not in filename: continue ending = filename.split(".")[1] if ending not in ["jpg", "gif", "png"]: continue try: image = Image.open(os.path.join(filepath, filename)) except IOError as e: print("Problem Opening", filepath, ":", e) continue image = image.crop((535, 40, 600, 90)) # Greyscale image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Blur image = cv2.GaussianBlur(image, (3, 3), 0) # Threshold image = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] # Morph open to remove noise and invert image kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3)) image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel, iterations=1) image = 255 - image name, extension = os.path.splitext(filename) print(name + '_cropped.jpg') image.save(os.path.join('/some/file/path/Frames/Cropped', name + '_cropped.jpg')) |
Converting a Bytes object into a Pandas dataframe with Python3 results in an empty dataframe. Why? Posted: 27 Apr 2021 07:49 AM PDT I was reading about Bytes libraries and Pandas and I think the answers in the following post should work for me: How to convert bytes data into a python pandas dataframe? However, neither of them are working. I have a CSV file with a few content. When I load it to Odoo, it returns the file into a Bytes object. I want to read this Bytes object with pandas and convert it into a dataframe in order to using dataframe methods. The Bytes object comes in the attribute file_to_import of my class (self.file_to_import ). If I show its type it returns <class 'bytes'> . If I decode it, I get its respective string: ZGVmYXVsdF9jb2RlO25hbWU7ZGVzY3JpcHRpb25fc2FsZTtjYXRlZ29yeV9pZC9pZDtzdGFuZGFyZF9wcmljZTtsaXN0X3ByaWNlOzs7dHlwZTtiYXJjb2RlO3NlbGxlcl9pZHMvbmFtZS9pZDtzZWxsZXJfaWRzL3Byb2R1Y3RfbmFtZTtzZWxsZXJfaWRzL3Byb2R1Y3RfY29kZQpXNS5GLTA2NjY2ODtOZXN0YSBDaHJvbWUgNjA7TmVzdGEgQ2hyb21lIDYwLiBDYWxkZXJhIGRlIGNvbmRlbnNhY2nDs24gbXVyYWwgZGUgZ2FzIGRlIDYwIGtXLCBjb24gcXVlbWFkb3IgZGUgcHJlbWV6Y2xhIGUgaW50ZXJjYW1iaWFkb3IgcGlyb3R1YnVsYXIgYXV0b2xpbXBpYWJsZSBkZSBhY2VybyBpbm94aWRhYmxlLCByYXRpbyBkZSBtb2R1bGFjacOzbiAxMDoxMDA7Q2FsZGVyYXMgeSBjYWxlbnRhZG9yZXMgZGUgYWd1YTsxMTI5OzM2NTA7U0k7U0k7cHJvZHVjdDs7QUlDIFNBOzYwIGtXIFdhbGwgaHVuZyBib2lsZXIgaW4gY2FydG9uIGJveCB3aXRoOiBib2lsZXIgQW5jbGFqZSBwYXJlZCwgcGxhc3RpYyBzaXBob24gd2l0aCBnYXNrZXQgYW5kIGNsaXAsIHVzZXIncyBtYW51YWwgaW4gRW5nbGlzaCBsYW5ndWFnZTtXNS5GLTA2NjY2OApXMS5GLTA2NjY2OTtTYWZhcmkgMTAwMDtTYWZhcmkgMTAwMCBwbHVzIDI4OTM0MDE7Q2FsZGVyYXMgeSBjYWxlbnRhZG9yZXMgZGUgYWd1YTsxMTI5OzM2NTA7U0k7U0k7cHJvZHVjdDs7QUlDIFNBOzYwIGtXIFdhbGwgaHVuZyBib2lsZXIgaW4gY2FydG9uIGJveCB3aXRoOiBib2lsZXIgQW5jbGFqZSBwYXJlZCwgcGxhc3RpYyBzaXBob24gd2l0aCBnYXNrZXQgYW5kIGNsaXAsIHVzZXIncyBtYW51YWwgaW4gRW5nbGlzaCBsYW5ndWFnZTtXMS5GLTA2NjY2OQo7OztTdXN0aXR1aXIgQ2FsZGVyYXMgeSBjYWxlbnRhZG9yZXMgZGUgYWd1YSBwb3IgY8OzZGlnbyByYXJvO8K/UHJlY2lvIGRlIGNvbXByYSBkZSB0b2RvcyBsb3MgcHJvdmVlZG9yZXMgbyBzw7NsbyBkZSBlc3RlIHByb3ZlZWRvciBjb25jcmV0bz87O8K/Pzs7OztTdXN0aXR1aXIgQUlDIFNBIHBvciBzdSBjw7NkaWdvIHJhcm87Owo= It looks OK, so this should be enough: from io import BytesIO import pandas as pd df = pd.read_csv(BytesIO(self.file_to_import)) However, df does not have any rows, and if I check df.empty , it returns True , so the dataframe does not have any info. If I check the size of the BytesIO object before trying to convert it into a dataframe , it returns 1376 bytes, which seems to be OK, since Dolphin shows a size of 1,0 KiB (1.031) for the file. x = BytesIO(self.file_to_import) _logger.critical(x.getbuffer().nbytes) df = pd.read_csv(x)) Can anyone tell me why is this happening? Why the dataframe is empty? |
netCDF files has no variables in python when importing with xarray Posted: 27 Apr 2021 07:49 AM PDT |
ColdFusion / jQuery Autocomplete clashing with Chrome Posted: 27 Apr 2021 07:49 AM PDT I've got a ColdFusion application that uses jQuery autocomplete to allow users to select an email address from a list of suggestions, and then upon doing so it autopopulates the rest of the form. The issue that I'm running into is since it's an email input, Chrome is autosuggesting forms inputs, and when the user selects Chrome's selections instead of jQuery's, it doesn't trigger the code in the autocomplete's select option. Some of the things that I have considered / tried to implement are: - Setting autocomplete="bogus-value", which seems to disable the jquery autocomplete
- Setting input type="search", which I can't do because I am using
- Considering having the autopopulate function called when the email input loses focus, but not seeing focus events as an option in ColdFusion.
Any suggestions for a solution that gets jQuery autocomplete and Chrome working well together, that can be implemented in a ColdFusion app would be great. Thanks! |
format json in angular textarea Posted: 27 Apr 2021 07:49 AM PDT I'm trying to pretty print a json when copying it in a textarea in angular. I have tried to format it capturing the data through ngModelChange with no success. Any idea how can I make it? I also tried to format it through a button. I made a stackblitz to show you my code. Thanks in advance for your response. stackblitz |
VBScript does not oFS.FileExists a file in oFS.CreateFolder Posted: 27 Apr 2021 07:48 AM PDT I'm having a strange problem with VBScript. I'd like to implement some other code with a following test: If there is a file named like [that] in the [folder], do not copy it into the [folder]. Thing is, I found a strange relation in oFS.FileExists, I'm able to use it in a manually created folder, as long as I manually copy and paste a file into it. Then oFS.FileExists works like a charm. Dim oFS Set oFS = CreateObject("Scripting.FileSystemObject") filestr = "C:\where\file\is\file.file" If (oFS.FileExists(filestr)) Then WScript.Echo("File exists!") WScript.Quit() Else WScript.Echo("File does not exist!") End If But it's not exactly my point. I'd like to test if a file is already in the desired folder, and such folder will be generated automatically with oFS.CreateFolder. But when it comes to testing an automatically generated folder, it's a different story. Dim oFS Set oFS = CreateObject("Scripting.FileSystemObject") oFS.CreateFolder(destination & objFoldername) Initially I thought it might be something wrong with the file I'm looking for. I moved it to some other place and the oFS.FileExists found it. So I figured it might be the case of the folder itself. I can see the folder is a Read Only folder. I tested it in other manually created Read Only folder, also found it. Finally I manually created the folder exactly like oFS.CreateFolder would do it, pasted manually a file into it and... it also found a file just fine. As I witnessed, every test I conduct in a generated folder is failed, but done in a manually created one, pass. Remarkable! Had anyone such a case? Do you know why oFS.FileExists puts a blind eye on something created itself? I'm using 64-bit Windows 10 Home, and I wrote both scrips in Visual Studio Code if that would be relevant. Cheers guys, I can't be the first one. |
Handle static and media files on django develop and production environment Posted: 27 Apr 2021 07:48 AM PDT I'm trying to understand how static and media files have to be handled on Django in Development and production environment. On development I have a folder called "media" where, for example, user's images are stored. My settings.py and urls.py, looks like this and works fine: MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,"media") urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) My question is regarding to production environment. I want that media files (After run collectstatic) to be saved on another folder (/api/vol/media) on the production server. Should I have another settings.py for my production environment? Or how should I handle this? Thanks a lot |
GET DropDownMenu items from API and POST the selected item Posted: 27 Apr 2021 07:48 AM PDT I'm new to flutter and I have a contacts application where I've received all the contacts from the API using HTTP Client and also have made a POST request to add a contact using form. The problem I'm facing is I don't know how to get the DropDownMenu items from the json and populate it in the DropDownButtonFormField and also how to send back the selected item to the contact properties. For now I've made a list of static data for the DropDownMenu , but my json is a map and I can't find the DropDownMenu items anywhere in the JSON. My JSON sample code: { "total": "187144", "contacts": { "897": { "isPublished": true, "id": 897, "fields": { "core": { "points": { "id": "47", "label": "Points" }, "firstname": { "id": "2", "label": "First Name", "value": "Jason" }, "lastname": { "id": "3", "label": "Last Name", "value": "Lamuda" }, "...": { "..." : "..." } }, "ipAddresses": [ { "ip": "70.127.91.131", "ipDetails": { "city": "Bradenton", "region": "Florida", "timezone": "America/New_York", } }, "...": { "..." : "..." } API_Manager class: class API_Manager { Future<ContactsModel> getContacts() async { var client = http.Client(); var contactsModel; String getContactUrl = 'https://example.com/ma/api/contacts'; String basicAuth = 'Basic exampleauthkey'; try { var response = await client.get(getContactUrl, headers: <String, String>{ 'content-type': 'application/json', "Accept": "application/json", 'authorization': basicAuth, }); print(response.statusCode); developer.log(response.body); if (response.statusCode == 200) { var jsonString = response.body; var jsonMap = json.decode(jsonString); contactsModel = ContactsModel.fromJson(jsonMap); } } catch (Exception) { return contactsModel; } return contactsModel; } Future<AddContactModel> addContact( String firstName, String lastName, String email, ) async { var client = http.Client(); String addContactUrl = "https://example.com/ma/api/contacts/new"; String basicAuth = 'Basic exampleauthkey'; var response = await client.post(addContactUrl, headers: <String, String>{ 'authorization': basicAuth, "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", }, body: { "firstname": firstName, "lastname": lastName, "email": email }); // print(response.statusCode); // developer.log(response.body); if (response.statusCode == 201) { final String responseString = response.body; return addContactModelFromJson(responseString); } else { return null; } } } Add Contact Form Page: class _AddContactsState extends State<AddContacts> { AddContactModel _contact; TextEditingController _ipCountryCode, _eventRevenue, _sendsSinceLastEngagement, _marketingEmailsOpened, _socialAwarenessClicks, _firstName, _lastName, _email, _reasonForEmailUnsubscribe; final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); String contactOwner, stage, leadStatus, tags, emailAddressQuarantined, selectCompany; DateTime timeFirstSeen, lastMarketingEmailClickDate, createDate, becameAnEvangelistDate; List contactOwnerItem = [ "example owner 1", "example owner 2", "example owner 3", "example owner 4" ]; List stageItem = [ "Stage 1", "Stage 2", "Stage 3", "Stage 4", ]; List leadStatusItem = [ "Status 1", "Status 2", "Status 3", "Status 4", ]; List tagsItem = [ "tag1", "tag2", "tag3", "tag4", ]; List emailAddressQuarantinedItem = ["On", "Off"]; List selectCompanyItem = ["Company 1", "Other"]; @override void initState() { // TODO: implement initState super.initState(); _ipCountryCode = TextEditingController(); _eventRevenue = TextEditingController(); _sendsSinceLastEngagement = TextEditingController(); _marketingEmailsOpened = TextEditingController(); _socialAwarenessClicks = TextEditingController(); _firstName = TextEditingController(); _lastName = TextEditingController(); _reasonForEmailUnsubscribe = TextEditingController(); _email = TextEditingController(); } Future saveContact() async{ final String firstName = _firstName.text; final String lastName = _lastName.text; final String email = _email.text; final AddContactModel contact = await API_Manager().addContact(firstName, lastName, email); setState(() { _contact = contact; }); } @override Widget build(BuildContext context) { return Form( key: _formKey, autovalidateMode: AutovalidateMode.onUserInteraction, child: Scaffold( appBar: AppBar( title: Text('Add Contact'), actions: <Widget>[ FlatButton( textColor: Colors.white, onPressed: () async { // Validate returns true if the form is valid, or false otherwise. if (_formKey.currentState.validate()) { await saveContact(); } }, child: Text( 'SAVE', style: TextStyle( fontSize: 18, color: Colors.white, fontWeight: FontWeight.w600, ), ), shape: CircleBorder(side: BorderSide(color: Colors.transparent)), ) ], ), body: SingleChildScrollView( child: Container( margin: EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _contact == null ? Container() : TextFormField( onSaved: null, controller: _ipCountryCode, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'IP Country Code', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DateTimeFormField( decoration: InputDecoration( labelText: 'Time First Seen', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), onDateSelected: (DateTime value) { setState(() { timeFirstSeen = value; }); }, ), ), ], ), TextFormField( onSaved: null, controller: _eventRevenue, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Event Revenue', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), TextFormField( onSaved: null, controller: _sendsSinceLastEngagement, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Sends since last engagement', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), TextFormField( onSaved: null, controller: _marketingEmailsOpened, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Marketing Emails Opened', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DateTimeFormField( decoration: InputDecoration( labelText: 'Last marketing email click date', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), onDateSelected: (DateTime value) { setState(() { lastMarketingEmailClickDate = value; }); }, ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( isExpanded: true, decoration: InputDecoration( labelText: 'Email Address Quarantined', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: emailAddressQuarantined, onChanged: (newValue) { setState(() { emailAddressQuarantined = newValue; }); }, items: emailAddressQuarantinedItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), TextFormField( onSaved: null, controller: _socialAwarenessClicks, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Social Awareness Clicks', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( decoration: InputDecoration( labelText: 'Lead Status', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: leadStatus, onChanged: (newValue) { setState(() { leadStatus = newValue; }); }, items: leadStatusItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DateTimeFormField( decoration: InputDecoration( labelText: 'Create date', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), onDateSelected: (DateTime value) { setState(() { createDate = value; }); }, ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DateTimeFormField( decoration: InputDecoration( labelText: 'Became an evangelist date', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), onDateSelected: (DateTime value) { setState(() { becameAnEvangelistDate = value; }); }, ), ), ], ), TextFormField( onSaved: null, controller: _firstName, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'First Name', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), TextFormField( onSaved: null, controller: _lastName, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Last Name', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), TextFormField( //validator: validateEmail, onSaved: null, controller: _email, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Email', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), TextFormField( onSaved: null, controller: _reasonForEmailUnsubscribe, keyboardType: TextInputType.text, decoration: InputDecoration( labelText: 'Reason for email unsubscribe', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( isExpanded: true, decoration: InputDecoration( labelText: 'Tags', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: tags, onChanged: (newValue) { setState(() { tags = newValue; }); }, items: tagsItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( isExpanded: true, decoration: InputDecoration( labelText: 'Select a company', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: selectCompany, onChanged: (newValue) { setState(() { selectCompany = newValue; }); }, items: selectCompanyItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( isExpanded: true, decoration: InputDecoration( labelText: 'Contact Owner', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: contactOwner, onChanged: (newValue) { setState(() { contactOwner = newValue; }); }, items: contactOwnerItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Expanded( child: DropdownButtonFormField( decoration: InputDecoration( labelText: 'Stage', fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.all(8)), value: stage, onChanged: (newValue) { setState(() { stage = newValue; }); }, items: stageItem.map((valueItem) { return DropdownMenuItem( value: valueItem, child: Text(valueItem), ); }).toList(), ), ), ], ), ], ), ), ), )); } I've given all static data to the DropdownButtonFormField for now, but I need to populate it with the api response, please help me achieve that and post that selected dropdown item on clicking save |
How to set correct typescript type for setValue in react-hook-form? Posted: 27 Apr 2021 07:48 AM PDT I want to pass a the function setValue() down to a child component. Then I get the following error message: Type 'UseFormSetValue<Inputs>' is not assignable to type 'UseFormSetValue<Record<string, any>>' How can I pass down the function correctly? Sandbox example function App() { const { register, setValue, } = useForm<Inputs>({ }); return ( <form> <Field2 setValue={setValue} register={register} /> <input type="submit" /> </form> ); } |
Why is the ssh trust relationship between my Arista and my server not successfully created? Posted: 27 Apr 2021 07:49 AM PDT I'm trying to create a trust relationship between my Arista switch and an ubuntu server. I first created a key pair on my Arista and then i copied the public key to the server. I was hoping that it would not ask me for a password when accessing the server via ssh but it didn't happen. However, I did the same configuration between two ubuntu servers and it worked perfectly. [alic@Arista1-Core ~]$ ssh-keygen -t rsa [alic@Arista1-Core ~]$ cd .ssh/ [alic@Arista1-Core .ssh]$ ls -l total 8 -rw------- 1 alic eosadmin 1823 Apr 26 05:22 id_rsa -rw-r--r-- 1 alic eosadmin 399 Apr 26 05:22 id_rsa.pub [alic@Arista1-Core .ssh]$ ssh-copy-id -i id_rsa.pub ubuntu2@12.12.12.130 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Warning: Permanently added '12.12.12.130' (ECDSA) to the list of known hosts. ubuntu2@12.12.12.130's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'ubuntu2@12.12.12.130'" and check to make sure that only the key(s) you wanted were added. [alic@Arista1-Core .ssh]$ ssh ubuntu2@12.12.12.130 Warning: Permanently added '12.12.12.130' (ECDSA) to the list of known hosts. ubuntu2@12.12.12.130's password: As you guys can see, it keeps asking me for the password. Why is the trust relationship between my Arista and my server not successfully created? |
How to load text file in typedef struct? Posted: 27 Apr 2021 07:48 AM PDT I am having a problem to save all elements in when ı print it prints first line, or it prints with errors and bugs, ı want to start from second line. Text in file: 5 5 7 H 1 1 MILK White liquid produced by the mammals H 2 1 IN Used to indicate inclusion within space, a place, or limits H 3 3 BUS A road vehicle designed to carry many passengers H 5 3 DAN The name of a famous author whose surname is Brown V 1 1 MIND A set of cognitive faculties, e.g. consciousness, perception, etc. V 3 3 BAD Opposite of good V 2 5 ISBN International Standard Book Number #include <stdio.h> #include <stdlib.h> typedef struct { char *word; //word and corresponding hint char *clue; int x; //Starting x and y positions int y; char direction; //H for horizontal, V for vertical int f; //solved or not } Word_t; int main() { int nrWords=7; FILE * fpointer = fopen("puzzle2010.txt","r"); loadTextFile(fpointer,nrWords); return 0; } Word_t* loadTextFile( FILE* fpointer, int nrWords ){ Word_t* tfile; int deta,dete,data; int i=0; char skip[100]; tfile = (Word_t*) malloc(sizeof(Word_t)*nrWords); for(i=0;i<nrWords;i++){ if(i==0){ fscanf(fpointer,"%d %d %d ",&data,&dete,&deta); printf("%d %d %d \n",data,dete,deta); } else{ fscanf(fpointer,"%c %d %d %s %s ",&tfile[i].direction,&tfile[i].x,&tfile[i].y,tfile[i].word,&tfile[i].clue); printf("%c %d %d %s %s ",tfile[i].direction,tfile[i].x,tfile[i].y,tfile[i].word,tfile[i].clue); } } fclose(fpointer); } |
Building CI/CD for Python Azure Functions Using Jenkins Posted: 27 Apr 2021 07:48 AM PDT I am trying to build CI/CD Pipeline for Python Azure function. Here in the below code, I am trying:- Once I start the Jenkins Build option, my docker images should be deployed to the azure function app. stage('Publish to Azure'){ def RESOURCE_GROUP = '<resource_group>' def FUNC_NAME = '<function_app>' // login Azure withCredentials([usernamePassword(credentialsId: 'azuresp', passwordVariable: 'AZURE_CLIENT_SECRET', usernameVariable: 'AZURE_CLIENT_ID')]) { sh ''' az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET -t $AZURE_TENANT_ID az account set -s $AZURE_SUBSCRIPTION_ID ''' } sh 'cd $PWD/target/azure-functions/odd-or-even-function-sample && zip -r ../../../archive.zip ./* && cd -' sh "az functionapp deployment source config-zip -g $RESOURCE_GROUP -n $FUNC_NAME --src archive.zip" sh 'az logout' } What I am doing wrong in this? Or Is this the right way to do it? I am not getting any document or article related to Python Azure function deployment through Jenkins. |
How do I remove duplicates in R? Posted: 27 Apr 2021 07:48 AM PDT So I have file1.txt: L["Corn Flakes"] = "" L["Rice Oats"] = "" L["Shreddies"] = "" and file2.txt: L["Marshmellows"] = "Tesco" L["Golden Syrup"] = "Morrisons" L["Corn Flakes"] = "Tesco" L["Bran Flakes"] = "Asda" L["Super Flakes"] = "Asda" L["Rice Oats"] = "Asda" L["Shreddies"] = "Morrisons" L["Rice Krispies"] = "Tesco" So I have this script which merges file2 into file1 but only for rows that exist in file1. # Read file1 file1 <- read.table('file1.txt', sep = '=', quote = '', fill = TRUE) # Remove commented out rows from file1 file1 <- file1[!grepl('--', file1$V1), ] # Remove line that contains {} file1 <- file1[!grepl('\\{\\}', file1$V2), ] # Read file2 file2 <- read.table('file2.txt', sep = '=', quote = '', fill = TRUE) # Remove rows from file2 if they are incomplete file2 <- file2[!grepl('""', file2$V2),] # Merge file1 and file2 into result but only including rows that are complete result <- file2[file2$V1 %in% file1$V1, ] # Write to file write.table(result, 'result.txt', sep = '=', col.names = FALSE, row.names = FALSE, quote = FALSE) The script works fine except for one small thing. I don't want result to include rows that are identical in file1 and file2. So if file1 contains L["Shreddies"] = "Tescos" and file2 contains L["Shreddies"] = "Tescos", I don't want L["Shreddies"] = "Tescos" to be included in result. How do I do this? |
get max value for each document Posted: 27 Apr 2021 07:48 AM PDT I have this table named register and I need to get the max date for each personid that i have re_id | re_personid | re_datetime(timestamp without time zone) 4 | 19343834063 | 2021-04-27 10:30:42 7 | 34534534534 | 2021-04-26 11:00:42 8 | 34534534534 | 2021-04-26 12:00:42 9 | 4234234 | 2021-04-27 10:01:42 10 | 4234234 | 2021-04-27 10:05:42 11 | 56790134567 | 2021-04-27 10:00:42 12 | 56790134567 | 2021-04-27 10:15:42 13 | 56790134567 | 2021-04-27 10:20:42 |
How do I merge a JSON child with it's parent using JavaScript Posted: 27 Apr 2021 07:48 AM PDT I have a JSON like so: { "parent": { "type": "Object", "value": { "type": "String", "value": "A string" } } } Pretty much, the pattern is parent has type and value , but I want the value of parent to be value { "parent": { "parent": "A string" } } How can I set the parent's value to be the child named value recursively in JavaScript? The main issue I am having is doing this recursively for a very large file. EDIT: My example JSON was invalid, fixed |
How to decompose irregular time series? Posted: 27 Apr 2021 07:49 AM PDT I have a time series with irregular time data from 2006 to 2020 including just the summer months (June, July, August). And I would like to get informations about trend, seasonality and mostly residuals. - 2007-07-15 / 23.3132725761094
- 2007-07-24 / 27.5978287205735
- 2007-07-29 / 29.305232884511
- 2009-06-25 / 25.6451943453992
- 2009-06-27 / 34.6152556850167
Now,I did a complete time axis for each day over the years and merged my lst data. library(forecast) library(xts) timestamps <- data$date dataRep <- data.frame(timestamps= as.Date(c("2007-07-15","2007-07-24", "2007-07-29","2009-06-25")), lst = c(23.3132725761094, 27.5978287205735, " ",25.6451943453992)) tstamp <- data.frame(x = seq(head(dataRep$timestamps,1),tail(dataRep$timestamps,1),by ="day")) res <- merge(tstamp,dataRep,by.x="x", by.y="timestamps", all.x=TRUE) tsData <-xts(res$lst,order.by =res$x) Now, I wanted to apply my tsData to decompose() or slt(), but it didn't work and I got the following errors. xts.stl <- stl(tsData,s.window="periodic") Error: Error in na.fail.default(as.ts(x)) : missing values in object decompose(as.ts(tsData)) Error: Error in decompose(as.ts(tsData)) : time series has no or less than 2 periods Could someone help me please? |
How to check if input string contains specific letters and is divisible by 3 in Python Posted: 27 Apr 2021 07:49 AM PDT I am writing a program that should check if: - a user input string contains a specific word
- OR contains 4 designated characters and is divisible by 3.
I can get the specific string check and the divisibility check to work but I can't seem to get the letter check to work. validationcheck = False while not validationcheck: InputSequence = input("Input: ") if (InputSequence == 'EXAMPLE' or len(InputSequence) % 3 == 0 and 'C', 'A', 'G', 'T', 't', 'g', 'a','c' in InputSequence): validationcheck = True else: print("Invalid input") InputSequence = input("Input: ") My desired output would be that if the user types EXAMPLE , or they type a sequence of letters containing C , A , G , T that is divisible by 3, there would be no invalid input. Otherwise the program would print an invalid input message and prompt the user to re enter |
Write a feature Test using capybara when using sidekiq `perform_in` method Posted: 27 Apr 2021 07:49 AM PDT Most stuff I can find related is about testing that the background job is scheduled like this question. However, I need to write a feature test that actually waits for the execution of the background job, so let's say: BatchWorker.perform_in(30.minutes) I will need to write a feature test that makes some assertions based on the results of this job that will execute in 30 minutes. How to do that? UPDATE Just to clarify... I don't need to test if the job is enqueued, for example with rspec-sidekiq gem you can do something like Awesomejob.perform_in 30.minutes, 'Awesome', true # test with... expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(30.minutes) This is not what I need... I need to make an assertion on the page with capybara after the execution of the job. |
Argument 1 passed to ArrayCollection::__construct() must be of the type array object given Posted: 27 Apr 2021 07:49 AM PDT I am programming in Symfony 4.4. I have a Recipe entity with a categories property. When I try to make a recipe record using a form in the database, it gives me the following error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be of the type array, object given, called in C:\xampp\htdocs\proyecto_final_daw\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 675 I use and NEED a ManyToMany relationship. I can't change this type to relationship. UploadRecipesType form <?php namespace App\Form; use App\Entity\Recipe; use App\Entity\Category; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; class UploadRecipesType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('title',TextType::class,[ 'label' => 'Titulo', ]) ->add('image',FileType::class,[ 'label' => 'Imagen', ]) ->add('description',TextareaType::class,[ 'label' => 'Descripción', ]) ->add('categories',EntityType::class,[ 'class' => Category::class, 'mapped' => true, 'label' => 'Categoria', 'choice_label' => 'name', ]) } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => Recipe::class, ]); } } Recipe.php Entity <?php namespace App\Entity; use App\Repository\RecipeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=RecipeRepository::class) */ class Recipe { public function __construct() { $this->categories = new \Doctrine\Common\Collections\ArrayCollection(); } /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $title; /** * @ORM\Column(type="string", length=255) */ private $image; /** * @ORM\Column(type="string", length=255) */ private $description; /** * @ORM\ManyToOne(targetEntity="User", inversedBy="recipes") * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\Column(type="integer", nullable=true) */ private $score; /** * @ORM\Column(type="boolean") */ private $visible; /** * @ORM\ManyToMany(targetEntity="Category", inversedBy="recipe") * @ORM\JoinTable(name="recipes_categories") */ private $categories; public function getId(): ?int { return $this->id; } public function setId(int $id) { $this->id = $id; return $this; } public function getTitle(): ?string { return $this->title; } public function setTitle(string $title): self { $this->title = $title; return $this; } public function getImage(): ?string { return $this->image; } public function setImage(string $image): self { $this->image = $image; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(string $description): self { $this->description = $description; return $this; } public function getUser() { return $this->user; } public function setUser($user) { $this->user = $user; return $this; } public function getScore(): ?int { return $this->score; } public function setScore(?int $score): self { $this->score = $score; return $this; } public function getVisible(): ?bool { return $this->visible; } public function setVisible(bool $visible): self { $this->visible = $visible; return $this; } public function getCategories() { return $this->categories; } public function setCategories($categories) { $this->categories = $categories; return $this; } public function __toString() { return $this->getTitle(); } } Category.php Entity <?php namespace App\Entity; use App\Repository\CategoryRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=CategoryRepository::class) */ class Category { public function __construct() { $this->recipe = new \Doctrine\Common\Collections\ArrayCollection(); } /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255, nullable=false) */ private $name; /** * @ORM\ManyToMany(targetEntity="Recipe", mappedBy="categories") */ private $recipe; public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getRecipe() { return $this->recipe; } public function setRecipe() { return $this->recipe; } public function addRecipe(Recipe $recipe): self { if (!$this->recipe->contains($recipe)) { $this->recipe[] = $recipe; $recipe->addCategory($this); } return $this; } public function removeRecipe(Recipe $recipe): self { if ($this->recipe->removeElement($recipe)) { $recipe->removeCategory($this); } return $this; } } |
how to make a plot line default to not visable in pine script Posted: 27 Apr 2021 07:48 AM PDT Ok so I have this line of code, and I would like for it not to default to visable, as it is right now sure I can just open it and turn it off in the style menu, but If possible I would like to have it start off that way. Thanks in advance for taking a look plot(tsl, color=colr, linewidth=3, title="BUY/SELL Chart Line") |
How to make a plot invisible by default in pinescript Posted: 27 Apr 2021 07:49 AM PDT Clicking on the cogwheel 'settings' of an indicator on a chart pops up a dialog with a tab 'inputs' and a tab 'style'. Every style is preceded by a checkbox that controls the visibility of that particular plot. By default, all plots are visible. I want some plots to be hidden by default. The only way I know to do this is to manually uncheck some styles in the dialog, and then save these settings as the new default with the dropdownbox 'default' > 'save as default'. But how can I do this in code? How can I set the default state of a plot to 'hidden' with pinescript? thanks! |
xchart java swing not drawing data correctly when using updateOHLCSeries Posted: 27 Apr 2021 07:49 AM PDT Hi I have a weird issue with xChat lib(org.knowm.xchart) in java swing. I am able to create a chart(Candle) when I first time add data to it, but when I add data to it say 5 sec after it is not drawing the candles. - In Init i used
chart.addSeries("Candle", xData, openData, highData, lowData, closeData, volumeData); - In Timer 5 sec after(done by using WSS onmessages i.e. the message is recieving after few seconds)
chart.updateOHLCSeries("Candle", xData, openData, highData, lowData, closeData, volumeData); Result: I am not able to understand why it wors first time and not 2nd time, i suspect it has something to do with the chart.updateOHLCSeries but cannot find a solution for it. In the image above, the first 5 candles are drawn using the chart.addSeries and last 2 are being addedd in using chart.updateOHLCSeries |
TypeError: ShallowWrapper::renderProp() can only be called on custom components Posted: 27 Apr 2021 07:48 AM PDT I am trying to test the render props of my React component, and have followed some advice in doing so, however it is not working. Component: const AppMain = () =>{ return ( <main> Enter datapack details here. <Formik initialValues={{ pack_name: '', pack_mcmeta:{ pack_format: '', description: '' }, data: { } }} onSubmit={(values, { setSubmitting }) => { setTimeout(() => { alert(JSON.stringify(values, null, 2)); setSubmitting(false); }, 400); }} render={({ isSubmitting }) => ( <Form className="form-container"> <MetaFields /> <Divider variant="middle"></Divider> <Button variant="outlined" type="submit" disabled={isSubmitting}> Submit </Button> </Form> )}> </Formik> </main>) } And my test: import Enzyme, {shallow} from 'enzyme'; import AppMain from './AppMain'; import Adapter from 'enzyme-adapter-react-16'; import { Formik } from 'formik'; Enzyme.configure({ adapter: new Adapter()}) describe('<AppMain />', () => { let wrapper; beforeEach(() => { wrapper = shallow(<AppMain />); }); it('Renders a form', () => { const renderedForm = wrapper.renderProp('render')(false) expect(renderedForm.exists('.form-container')).toEqual(true); }) }); But I get this error message: ● › Renders a form TypeError: ShallowWrapper::renderProp() can only be called on custom components 17 | }); 18 | it('Renders a form', () => { > 19 | const renderedForm = wrapper.renderProp('render')(false) | ^ 20 | expect(renderedForm.exists('.form-container')).toEqual(true); 21 | }) 22 | }); at ShallowWrapper.<anonymous> (node_modules/enzyme/build/ShallowWrapper.js:1471:19) at ShallowWrapper.single (node_modules/enzyme/build/ShallowWrapper.js:1960:25) at ShallowWrapper.renderProp (node_modules/enzyme/build/ShallowWrapper.js:1469:21) at Object.renderProp (src/AppMain.spec.js:19:38) I have not found anything online about the error message title: TypeError: ShallowWrapper::renderProp() can only be called on custom components |
Find bottom of Excel worksheet in VBA Posted: 27 Apr 2021 07:48 AM PDT I'd like to select to the bottom of the worksheet, but not below what is used/stored. I might have 10,000 rows, but I certainly don't have 65,536. I won't know ahead of time how many rows. In Excel itself (in recent versions, anyway; Excel 97 wasn't so kind) you can press Ctrl + End to be taken to the last row and column. I'd like the same functionality. |
E-Techbytes: Recent Questions - Stack Overflow >>>>> Download Now
ReplyDelete>>>>> Download Full
E-Techbytes: Recent Questions - Stack Overflow >>>>> Download LINK
>>>>> Download Now
E-Techbytes: Recent Questions - Stack Overflow >>>>> Download Full
>>>>> Download LINK N8