Categories
Mastering Development System & Network

How to get rid of a faulty drive in a BTRFS array

I have a HP MicroServer G8 running Debian 10. It has an embedded pseudo-hardware array management called B120i but that’s mostly irrelevant. It had 2x2TB drives and one 4TB drive set up as a BTRFS RAID1 array. One of the 2TB disks started acting up around 6 months ago with 2 Currently unreadable (pending) sectors […]

Categories
Mastering Development

is there a way to know (and not fail) at compile time if this is a array or an integer?

OP: is there a way to know at compile time if the current object is an array or an integer? #include <stdio.h> #define IS_INDEXABLE(arg) (sizeof(arg[0])) #define IS_ARRAY(arg) (IS_INDEXABLE(arg) && (((void *) &arg) == ((void *) arg))) int main(void) { int a[5]; // array int *b = a; // pointer int n = 10; int c[n]; […]

Categories
CMS Development Magento

Extending third party extension but Class does not exist when compiling

I’m extending a third party extension, and it looks like this, with registration and module I know their right. di.xml <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <preference for=”Invoicing\Moloni\Libraries\MoloniLibrary\Controllers\Products” type=”Custom\Moloni\Libraries\MoloniLibrary\Products” /> </config> and products.php <?php namespace Custom\Moloni\Libraries\MoloniLibrary; use Invoicing\Moloni\Libraries\MoloniLibrary\Controllers\Products as custommoloni; use Invoicing\Moloni\Libraries\MoloniLibrary\Controllers; use Invoicing\Moloni\Libraries\MoloniLibrary\Moloni; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\ResourceModel\Order\Tax\Item; use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory; use Magento\Catalog\Model\Category […]

Categories
Development

Update value inside mongodb array object

I’m trying to update a value inside my array of objects. Looking at the above mongoDB schema what I want is: Find an expense with the ID match with the _id and need to update the fields with new ones from the req.body. Just need to update the: expensesType, description, price and status. The following […]

Categories
Development

Update value inside mongodb array object

I’m trying to update a value inside my array of objects. Looking at the above mongoDB schema what I want is: Find an expense with the ID match with the _id and need to update the fields with new ones from the req.body. Just need to update the: expensesType, description, price and status. The following […]

Categories
Development

Update value inside mongodb array object

I’m trying to update a value inside my array of objects. Looking at the above mongoDB schema what I want is: Find an expense with the ID match with the _id and need to update the fields with new ones from the req.body. Just need to update the: expensesType, description, price and status. The following […]

Categories
Development

How To Convert Multidimensional Array To Another Format Multidimensional Array

I have data from a database that I want to convert to another format. The data is in the form of an array as below $array = [ [‘type 1’, ‘Country 1’, 243], [‘type 1’, ‘Country 2’, 500], [‘type 1’, ‘Country 3’, 400], [‘type 2’, ‘Country 1’, 234], [‘type 2’, ‘Country 2’, 1234], [‘type 2’, […]

Categories
Development

How to efficiently get the parameters datatype in C#?

To get the parameters datatype of some method we should do: using System.Reflection; static void Main() { Assembly assembly = Assembly.GetExecutingAssembly(); Type[] t = assembly.GetTypes(); foreach(var element in t) { MethodInfo[] methods = element.GetMethods(); foreach(var m in methods) { ParameterInfo[] params = m.GetParameters(); foreach(var p in params) { Console.WriteLine(“Parameter : {0}, Type : {1}”, p.Name, […]

Categories
Development Heroku JSON

Erroneous successful validation by JSON-schema

The fields in nodes depend on the value of entity. That is, if entity = “pd”, then nodes has some fields, while entity = ” top ” – nodes has completely different fields, despite the fact that they are strictly required. For some reason, the JSON string is accepted by the valid schema, even if […]

Categories
Development

Recursive Filter on Nested array

I need to filter a nested structure, that looks like this, based on query. I need to return all objects, including the parent object of the subtree, which match the query string in object name. Please help, i am stuck. [ { name: ‘bob’, type: 1, children: [ { name: ‘bob’, type: 2, children: [ […]