Monday, May 3, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Problem instantiating a package with subtype access to variant record

Posted: 03 May 2021 07:54 AM PDT

I try to compile an Ada 95 program with an Ada 2012 compiler. However there are problems with instantiation of the generic package Garbage_Collector. The subtype A_Term is not accepted in the package instantiation:

prolog.adb:27:15: designated type of actual does not match that of formal "Link"  prolog.adb:27:15: instantiation abandoned  

I have tried to change A_Term to type A_Term is access A_Node;. Then the package will instantiate, but the rest of the code breaks. Has something changed since Ada 95 and how can I make it work in Ada 2012?

procedure Prolog is       generic        type Item is limited private;        type Link is access Item;     package Garbage_Collector is        procedure Get (L : in out Link) is null;     end Garbage_Collector;       type Node_Tag is (A, B);       type Node (Tag : Node_Tag);     type Term is access Node;       type Node (Tag : Node_Tag) is        record           case Tag is              when A => null;              when B => null;           end case;        end record;       subtype A_Node is Node (A);     subtype A_Term is Term (A);     package Gc_A is new Garbage_Collector       (Item => A_Node,        Link => A_Term);       T : Term;  begin     Gc_A.Get (T);  end Prolog;  

The code is from a Prolog module from Stanford University. The project on GitHub

Get 500 error after uploading mvc asp.net web site in ajax calls

Posted: 03 May 2021 07:54 AM PDT

I am working on a project. For checking uniqeness of email and username I have used [Remote] data annotation. It works on local perfect and withoud delay, but when I published my proj and test it on Server I face error 500 when system wants to check. here is my model

public class RegisterViewModel      {          [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredItem")]          [Display(Name = "Email", ResourceType = typeof(Resource))]          [StringLength(128, ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "StringMaxLength")]          [Remote("IsEmailAvailable", "Account", HttpMethod = "POST", ErrorMessageResourceName = "UniqueField", ErrorMessageResourceType = typeof(Resource))]          [EmailAddress]          public string Email { get; set; }            [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredItem")]          [Display(Name = "Username", ResourceType = typeof(Resource))]          [Remote("IsUsernameAvailable", "Account", HttpMethod = "POST", ErrorMessageResourceName = "UniqueField", ErrorMessageResourceType = typeof(Resource))]          [StringLength(64, ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "StringMaxLength")]          public string Username { get; set; }            [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredItem")]          [Display(Name = "Password", ResourceType = typeof(Resource))]          [StringLength(32, ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "StringMaxLength")]          [DataType(DataType.Password)]          public string Password { get; set; }        }  

this my account controller methods:

        [HttpPost]          [AllowAnonymous]          public JsonResult IsUsernameAvailable(string username)          {              var user = UserManager.FindByName(username);              if (user == null)                  return Json(true);              return Json(false);          }            [HttpPost]          [AllowAnonymous]          public JsonResult IsEmailAvailable(string email)          {              var user = UserManager.FindByEmail(email);              if (user == null)                  return Json(true);              return Json(false);          }  

and this my view

<div class="p-2 frm-container">          @using (Ajax.BeginForm("Register", "Account", new AjaxOptions                      {                          HttpMethod = "POST",                          OnBegin = "AjaxOnBegin",                          OnSuccess = "AjaxSuccess"                       }, new { @class = "form-horizontal m-t-20" }))                       {                          @Html.AntiForgeryToken()                          <div class="form-group row">                          <div class="col-12">                                          @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" , placeholder = @Html.DisplayNameFor(m=>m.Email) } })                                          @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })                                      </div>                                  </div>                                    <div class="form-group row">                                      <div class="col-12">                                          @Html.EditorFor(model => model.Username, new { htmlAttributes = new { @class = "form-control" , placeholder = @Html.DisplayNameFor(m=>m.Username) } })                                          @Html.ValidationMessageFor(model => model.Username, "", new { @class = "text-danger" })                                      </div>                                  </div>                                    <div class="form-group row">                                      <div class="col-12">                                          @Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control" , placeholder = @Html.DisplayNameFor(m=>m.Password)} })                                          @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })                                      </div>                                  </div>                                  <div class="form-group row">                                      <div class="col-12">                                          <div class="custom-control custom-checkbox"><input type="checkbox" class="custom-control-input" id="customCheck1"> <label class="custom-control-label font-weight-normal" for="customCheck1">I accept <a href="#" class="text-primary">Terms and Conditions</a></label></div>                                      </div>                                  </div>                                  <div class="form-group text-center row m-t-20">                                      <div class="col-12"><button class="btn btn-primary btn-block waves-effect waves-light" type="submit">Register</button></div>                                  </div>                                  <div class="form-group m-t-10 mb-0 row">                                      <div class="col-12 m-t-20 text-center"><a href="@Url.Action("Login", "Account")" class="text-muted">Already have account?</a></div>                                  </div>                              }                          </div>  

Is there a C/C++ Tor API?

Posted: 03 May 2021 07:54 AM PDT

I am looking for a (preferably Open Source) API usable in C/C++, that enables one to send/receive data over the Tor network. So I want to build an application that uses sockets to communicate data over a network, but I want that data to be sent over the Tor network instead. Is that possible? Is there a API for it?

Removing specifying comma's from output - bash

Posted: 03 May 2021 07:54 AM PDT

This is my output:

2020-06-03T16:00:00.000+0000, High, Cisco IOS, IOS XE, IOS XR, and NX-OS Software One Platform Kit Remote Code Execution Vulnerability, 7.3(7)N1(1),

There is a generic solution in bash to remove the bolded commas (its may be different words every time) ?

Thanks!

How is gas usage calculated when using if statements

Posted: 03 May 2021 07:54 AM PDT

Let's say I have a smart contract with branch, where each branch has a different number of operations.

if (someCondition) {    // do operations costing 10 gas  } else {    //do operations costing 100 gas  }  

When a user goes to call this function from their client, say metamask, how do they know how much gas their transaction will cost? Do they just have to guess and include enough gas for the most expensive path?

ChromeDriver default download directory not working in ChromeDriver v89,90

Posted: 03 May 2021 07:54 AM PDT

I had been using below code to set default download directory in chromedriver

System.setProperty("webdriver.chrome.driver", "C:\\test\\chromedriver.exe");  String downloadFilepath = System.getProperty("user.dir");  HashMap<String, Object> chromePrefs = new HashMap<String, Object>();  chromePrefs.put("profile.default_content_settings.popups", 0);  chromePrefs.put("download.default_directory", downloadFilepath);  ChromeOptions options = new ChromeOptions();  options.setExperimentalOption("prefs", chromePrefs);  DesiredCapabilities cap = DesiredCapabilities.chrome();  cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);  cap.setCapability(ChromeOptions.CAPABILITY, options);    WebDriver driver = new ChromeDriver(cap);  

The code was working fine with chromedriver-2.38, but when I tried to use the same code with ChromeDriver-v89 & v90, the download directory is not setting to workspace directory, instead it is downloading files to C:\Users<username>\Downloads. I have tried many options but not able to identify what's wrong in the code

Selenium-server version 3.5.3
Chromedriver-2.38 works fine
Chromedriver-89.0.4389.23 - doesn't work
Chromedriver-90.0.4430.24 - doesn't work

How to extract POI from Leaflet / OSM

Posted: 03 May 2021 07:53 AM PDT

Imagine a custom map based on Leaflet / OSM with certain POI, e.g. https://www.proplanta.de/maps/windkraftanlagen_points1404907272.html

Afaik, the map and its content are drawn by Javascript / Ajax requests. How can I get access to the POI shown from a script (python / php)?

Pickling a Keras Regressor model Error: can't pickle _thread.RLock objects

Posted: 03 May 2021 07:53 AM PDT

I would like to pickle a pipeline which contains a Keras regressor and a standard scaler. But I get the following error:can't pickle _thread.RLock objects. Any ideas on what could be the problem?

 scaler=StandardScaler()   scaler.fit(X_train)   X_train=scaler.fit_transform(X_train)   X_test=scaler.fit_transform(X_test)    #Defining Model   def build_model():    model = Sequential()    model.add(Dense(1, input_dim=1, activation='relu'))    model.add(Dense(10583, activation='relu'))    model.add(Dense(1, activation='linear'))    model.compile(loss='mean_squared_error', optimizer = keras.optimizers.Adam(lr=0.0001), metrics=['mse'])    return model    callback = tf.keras.callbacks.EarlyStopping(monitor='loss', patience=3)      #Wrapping Keras model in KerasRegressor    clf = KerasRegressor(build_fn=build_model,epochs=100, batch_size=32, validation_split=0.2,   validation_data=None, verbose=1, callbacks=[callback])     #Defining Pipeline:      pipeline = Pipeline([  ('scaler',scaler),  ('clf', clf)])    pipeline.fit(X_train, Y_train)  joblib.dump(pipeline, open(filename, 'wb'))       

Invalid Character in File

Posted: 03 May 2021 07:53 AM PDT

I am using ml64 (MASM for 64) to compile a .S file on Windows 10 with bazel 4.0. I keep getting an invalid character in file error. This project originally compiled just fine with CMAKE but when I converted it to bazel it started failing like this. I am not sure what other detail would be helpful here so please let me know.

 Assembling: src/crypto/CryptonightR_template.S  src/crypto/CryptonightR_template.S(1) : error A2044:invalid character in file  src/crypto/CryptonightR_template.S(2) : error A2044:invalid character in file  src/crypto/CryptonightR_template.S(3) : error A2044:invalid character in file  src/crypto/CryptonightR_template.S(4) : error A2044:invalid character in file  .  .  .    

for this file

#ifdef __APPLE__  #   define ALIGN(x) .align 6  #else  #   define ALIGN(x) .align 64  

No comments:

Post a Comment