JavaScript : How to Calculate the Check Digit according to ISO 6346

Learn how to calculate the check digit according to ISO 6346 for shipping containers. Prevent errors in tracking and documentation with this simple algorithm.… Read More JavaScript : How to Calculate the Check Digit according to ISO 6346

Operator function defaults to first if statement in JavaScript calculator project

I’m creating a calculator with JavaScript and most functions are working properly, but the operator function defaults to the first if statement each time (I switched add with subtract to test this). i.e. if the add function is in the first if statement of my operator function, every operator button will add the numbers instead… Read More Operator function defaults to first if statement in JavaScript calculator project

Removing a dictionary from a list of dictionaries to avoid a divide by zero error

I have a list of dictionaries for example: [{‘askPrice’: ‘0.06671700’, ‘askQty’: ‘20.50280000’, ‘bidPrice’: ‘0.06671600’, ‘bidQty’: ‘11.01110000’, ‘symbol’: ‘ETHBTC’}, {‘askPrice’: ‘0.00237300’, ‘askQty’: ‘34.35000000’, ‘bidPrice’: ‘0.00237200’, ‘bidQty’: ‘33.33300000’, ‘symbol’: ‘LTCBTC’}, {‘askPrice’: ‘0.00000000’, ‘askQty’: ‘0.00000000’, ‘bidPrice’: ‘0.00000000’, ‘bidQty’: ‘0.00000000’, ‘symbol’: ‘BCCBTC’}] The third dictionary in the list with ‘symbol’:’BCCBTC’ has ‘askPrice’: ‘0.00000000’ so when I try to divide… Read More Removing a dictionary from a list of dictionaries to avoid a divide by zero error

Converting maturities to numeric format

I am trying to make a function to replace weird looking maturities into numbers: For a reproducable example: the following block contains the data. dict <- c("ON","TN","1W","1M","2M","3M","6M","9M","1Y","1Y3M","1Y6M","1Y9M","2Y","2Y3M", "2Y6M","2Y9M","3Y","3Y3M","3Y6M","3Y9M","4Y","4Y3M","4Y6M","4Y9M","5Y","5Y3M","5Y6M","5Y9M","6Y","6Y3M","6Y6M","6Y9M","7Y","7Y3M","7Y6M","7Y9M","8Y","8Y3M","8Y6M","8Y9M","9Y","9Y3M","9Y6M","9Y9M","10Y","11Y","12Y","13Y","14Y","15Y","20Y","25Y","30Y","40Y","50Y") I tried to think about it as follows: make a sub() function for the months (extract everything before M and after Y). Divide by 12. Then add… Read More Converting maturities to numeric format

How to join two fields in JSON array with jq

I’m trying to get output in one line for 2 fields in the array using ‘jq’ curl -X ‘GET’ "https://api.coingecko.com/api/v3/coins/ethereum/market_chart?vs_currency=USD&days=10&interval=daily&quot; -H ‘accept: application/json’|jq ‘.prices[][] gives me output like this: 1652227200000 2344.797715643986 1652313600000 2080.910243657776 1652400000000 1966.6991711336661 1652486400000 2010.214051125259 1652572800000 2064.229357512243 1652659200000 2147.047447880575 1652745600000 2025.8886983912162 1652832000000 2095.178884796724 1652918400000 1915.1771232664505 1653004800000 2023.8482593608173 1653070323000 1931.3963167096579 and I would like… Read More How to join two fields in JSON array with jq

MySQL Throws error after defining the location of table

I have this ‘information’ table below with 4 columns in it: ‘creator_id’,’viewer_id’,’date_format’,’donation’ CREATE TABLE information ( creator_id INT NOT NULL, viewer_id INT NOT NULL, date_format DATE NOT NULL, donation INT NOT NULL ); INSERT INTO twitch.information(creator_id,viewer_id,date_format,donation) VALUES (10,11,’2014-01-02′,34), (20,14,’2014-01-02′,150), (30,15,’2014-01-02′,717), (31,17,’2014-01-02′,177), (32,17,’2014-01-06′,737), (33,16,’2014-01-07′,37), (40,18,’2016-03-08′,442), (41,19,’2016-03-09′,142), (42,10,’2016-03-10′,152), (43,11,’2016-03-11′,512), (44,12,’2016-01-12′,340), (60,0,’2012-01-02′,1000), (70,1,’2012-01-02′,100); SELECT creator_id, MAX(SUM(donation)/COUNT(donation)) AS "TOP… Read More MySQL Throws error after defining the location of table