Categories
Mastering Development

How to add exception handling to check if a user input value is a key in a dict

In my code, i allow the user to enter the key value of the dictionary for them to edit. I would like to make It so the user can only enter those specific values so the dict doesnt get added to. here is my code. need exception handling on variables edit and value. def edit_items(info): […]

Categories
CMS Drupal Mastering Development

How to access backbone model from custom javascript outside of view

I was wondering if there is a way to access backbone model variable outside the scope of the backbone model/view.This is the backbone model: function (Backbone, Drupal) { Drupal.addToCart.AddToCartModel = Backbone.Model.extend({ defaults: { defaultVariation: ”, selectedVariation: ”, attributes: {}, renderedAttributes: {}, injectedFields: {}, variations: {}, variationCount: 0, quantity: 1, unit_box: 1, type: ‘commerce_product_variation_attributes’ }, initialize: […]

Categories
Mastering Development

Db2 nested JSON

I am trying to use Db2 JSON capabilities and in particular nested tables. CREATE TABLE JSON.TEST1 (COL1 VARBINARY(2000)); INSERT INTO JSON.TEST1 (COL1) VALUES (JSON_TO_BSON( ‘{"id" : 103, "orderDate": "2014-06-20", "items": { "item": [ { "partNum": "872-AA", "productName": "Lawnmower", "quantity": 1, "USPrice": 749.99 }, { "partNum": "837-CM", "productName": "Digital Camera", "quantity": 2, "USPrice": 199.99 } ] […]

Categories
Mastering Development

ASP.NET MVC creating paypal webhook

I’m using REST API SDK for Dotnet V2 github link to integrate with paypal orders [create and capture] it’s working fine. I’m trying now to implement the webhook, already spent lots of hours trying to find out how to create a controller to receive paypal webhooks to update my orders status but not able to […]

Categories
Mastering Development

Postman works but not react redux action (axios.post request)

Something really weird is going on. I am building an API using Cloud Functions. Basically the Cloud Function makes a request to the server and retrieves a token. This is the code exports.Klarna = functions.https.onRequest((req, res) => { // const app = express(); // app.use(cors({ origin: true })); res.set(‘Access-Control-Allow-Origin’, ‘*’); const url = “https://api.playground.klarna.com/payments/v1/sessions”; const […]

Categories
Mastering Development Software

How to calculate differences on item balances using retrieved snapshot data

I’m currently getting data of all my users current inventory balances on a daily basis from a third party system. JSON data structure of the retrieved data is basically looking like this: [ { “UserId”: 1, “Items”: [ { “ItemName”: “Item A”, “Quantity”: 2 }, { “ItemName”: “Item B”, “Quantity”: 5 } ] }, { […]

Categories
Mastering Development

Python / Pandas using pandas.io.json.json_normalize to drill down in json

The following json (otherwise known as ‘Cus_data’) is what I am working on deciphering with the pandas.io.json.json_normalize package. I can get within the json at a base level by cus_data = json_normalize(cus_data, ‘data’) or cus_data = json_normalize(cus_data[‘data’], max_level=1) ….Not sure which is best practice I can’t seem to figure out how to enter “Sources”, “subscriptions”,”plan” […]

Categories
Mastering Development

In local Firebase, how do I set a projectId for the current environment?

I’m trying to write some test data to a local version of Firebase. I have these variables defined in my .env.local (and .env.development files) … REACT_APP_MB_ACCESS_TOKEN=”accesstoken” ALGOLIA_APP_ID=”appid” ALGOLIA_API_KEY=”apikey” NODE_ENV=”development” FIREBASE_EMULATOR_HOST_VAR=localhost:9000 FIRESTORE_EMULATOR_HOST=localhost:8080 GCLOUD_PROJECT=mutualaid-123f6 I have the below set up (via npm run dev:upload) to upload dummy data into my local Firebase … const admin = require(“firebase-admin”); […]

Categories
Mastering Development Software

How does TDD behave when the tested unit needs to be expanded?

I want to write some invoicing logic, and I start coding it, using TDD. The following example is silly, but I’m confident it represents well the everyday dilemma I’m facing function createTestInvoice(client) { return Invoice.new( { client: client, rows: [ {item: ‘apple’, quantity: 1, unit_price_ 1} {item: ‘banana’, quantity: 2, unit_price: 2} ] } ) […]

Categories
Mastering Development

Stripe Checkout PHP Integration

I’m having a great deal of “fun” geting Stripe integration working. I’m building on an old payments page but had it working on the legacy version of checkout. With the upgrade I’ve had many issues but the documentation doesn seem to help. I have the below code running in a single index.php file require(‘../config.php’); <script> […]