Categories
Mastering Development

File Not Found Matplotlib Line Plot with 2 lines

Thank you in advance for your help! Data for minot_air Data for minot_soil I am trying to graph two datasets to one plot and I want it to look somewhat like the first image. The problem is that I keep getting these errors when I run my code (provided below): FileNotFoundError: [Errno 2] File C:\Users\Xavier\Desktop\Graphs\minotDailyAirTemp.csv […]

Categories
CMS Drupal Mastering Development

I want to disable and enable form fields on ajax callback of a form with multiple submit handlers

I could no get it working the submit handler of the login button doesn’t get called. here is my code <?php namespace Drupal\otp_validate\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\scorecards\ScorecardsRepository; use Drupal\otp_validate\OtpValidateRepository; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\HtmlCommand; use Drupal\user\UserAuth; use Drupal\user\Entity\User; /** * UI to validate otp. * * @ingroup scorecards */ class OtpValidateForm extends […]

Categories
Bitcoin Cryptocurrency Mastering Development

XPub to YPub Converter (python) – Last digits wrong

The code below is generating an YPub from XPub with the last 6 digits wrong. How can I verify what’s happening and fix this error? e.g.: It should be ypub6X7aFbqxwbJHJQqUhfTEZDWxVT8qbu4qjN8fCz9ADRuAwaZQ243YiB1w5yTE2qRJzRJ3Kza9DbefU8pnqjk3GEmn6g9usvkZZrP94VcBVdz but it returns ypub6X7aFbqxwbJHJQqUhfTEZDWxVT8qbu4qjN8fCz9ADRuAwaZQ243YiB1w5yTE2qRJzRJ3Kza9DbefU8pnqjk3GEmn6g9usvkZZrP94YkSjSS The code is adapted from this function in JS, that works well. import hashlib import base58 prefixesPub = { ‘xpub’: ‘0488b21e’, […]

Categories
Mastering Development

How to Create Variables from OLS Regression Results?

import numpy as np import pandas as pd from scipy import stats import statsmodels.api as sm import matplotlib.pyplot as plt d = {‘City’: [‘Tokyo’,’Tokyo’,’Lisbon’,’Tokyo’,’Madrid’,’Lisbon’,’Madrid’,’London’,’Tokyo’,’London’,’Tokyo’], ‘Card’: [‘Visa’,’Visa’,’Visa’,’Master Card’,’Bitcoin’,’Master Card’,’Bitcoin’,’Visa’,’Master Card’,’Visa’,’Bitcoin’], ‘Client Number’:[1,2,3,4,5,6,7,8,9,10,11], } d = pd.DataFrame(data=d).set_index(‘Client Number’) df = pd.get_dummies(d,prefix=”, prefix_sep=”) X = df[[‘Lisbon’,’London’,’Madrid’,’New York’,’Tokyo’,’Bitcoin’,’Master Card’,’Visa’,’No’,’Yes’]] Y = df[‘Total’] X1 = sm.add_constant(X) reg = sm.OLS(Y, X1).fit() […]

Categories
Mastering Development

URL forwarding from one domain to another, keeping the parameters

How do I configure my short domain to forward to my primary domain but persist the url path? For example… example.org/<keep-this> should redirect to example.com/<keep-this> At the moment, the url path is being thrown out, so I’m seeing this… example.org/<keep-this> redirects to example.com Note: my primary domain is hosted and managed at AWS S3/CloudFont/Route-53. The […]

Categories
CMS Drupal Mastering Development

Default_value not working for radio buttons after ajax calback

I am having problem to set the default_value of radio button populated after ajax callback. After ajax callback radio button is populating but default_value is not selected. Here is my code. $check_status = $form_state->getValue(‘check_status’)?? 1; $form[‘check_status’] = [ ‘#type’ => ‘radios’, ‘#title’ => $this->t(‘Select Action: ‘), ‘#options’ => array(1 => ‘Yes’, 2 => ‘No’), ‘#required’ […]

Categories
CMS Drupal Mastering Development

Default_value not working for radio buttons after ajax calback

I am having problem to set the default_value of radio button populated after ajax callback. After ajax callback radio button is populating but default_value is not selected. Here is my code. $check_status = $form_state->getValue(‘check_status’)?? 1; $form[‘check_status’] = [ ‘#type’ => ‘radios’, ‘#title’ => $this->t(‘Select Action: ‘), ‘#options’ => array(1 => ‘Yes’, 2 => ‘No’), ‘#required’ […]

Categories
CMS Drupal Mastering Development

Default_value not working for radio buttons after ajax calback

I am having problem to set the default_value of radio button populated after ajax callback. After ajax callback radio button is populating but default_value is not selected. Here is my code. $check_status = $form_state->getValue(‘check_status’)?? 1; $form[‘check_status’] = [ ‘#type’ => ‘radios’, ‘#title’ => $this->t(‘Select Action: ‘), ‘#options’ => array(1 => ‘Yes’, 2 => ‘No’), ‘#required’ […]

Categories
CMS Drupal Mastering Development

Hi, I am created the custom form module and twig template.. but form doesnt render on page.. I am paste my code here.. please help me

Form <?php namespace Drupal\proposerdetails\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; /** * {@inheritdoc} / class ProposerDetailsForm extends FormBase { /* * {@inheritdoc} / public function getFormBaseUrl(){ $api_base_url = \Drupal::config(‘api_config.settings’)->get(‘api_link’); return $api_base_url; } /* * {@inheritdoc} / public function getFormId() { return ‘proposerdetails’; } /* * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form[‘nationality’] = array( […]

How does this recursive Python code work?

I came across this recursive function that’s supposed flatten a dictionary: def flatten(data, prefix=”, separator=’.’): """Flattens a nested dict structure. """ if not isinstance(data, dict): return {prefix: data} if prefix else data result = {} for (key, value) in data.items(): result.update(flatten(value,_get_new_prefix(prefix, key, separator), separator=separator)) return result def _get_new_prefix(prefix, key, separator): return (separator.join((prefix, str(key))) if prefix […]