Mockingbird c++ mocking framework – Code Review Stack Exchange

I have developed Mockingbird a mocking framework for c++, it depends on function injection, and here is an example on how it works:

Assume you have the following class Foo and you need to mock:

struct MyStruct{
    int x, y;
};

class Foo{
public:
    virtual const MyStruct CreateMyStruct(int x, int y) { return MyStruct{ x,y }; }
}; 

Then you write a testing fixture only once for the whole project:

const MyStruct CreateMyStructDummy(int x, int y) { return MyStruct{0,0}; }

START_MOCK(FooMock, Foo)
FUNCTION(CreateMyStruct, const MyStruct, (int x, int y), &CreateMyStructDummy, x, y)
END_MOCK(FooMock)

Then in the tests you write the desired substitute for example:

const MyStruct CreateMyStructSubstitute(int x, int y) { return MyStruct{ x + 10, y + 10 }; }

and inject it like:

FooMock fooMock;
fooMock.InjectCreateMyStruct(CreateMyStructSubstitute); // Mocking function injection.
auto created = fooMock.CreateMyStruct(5,5);
EXPECT_EQ(created.x, 15);
EXPECT_EQ(created.y, 15);

The code is in the file Mockingbird.hpp and totally depends on macros, it is short and straightforward, I ask for reviewing the code on github here, thanks.

What is the need of kotlin code inside build.Gradle?

I just saw a project on Github. It had kotlin code inside build.gradle app file. I searched on google why and when do we write code inside a gradle file, but couldn’t get a simplified answer.

My query is, what is the need for it.

applescript – My Apple Script Editor code doesn’t work gives “Syntax Error Expected end of line but found identifier.”

The problem is the version of Evernote I tried is not AppleScript scriptable.

When trying to add Evernote to the Library in Script Editor, in order to review its AppleScript dictionary, it errs with: Add Item Unable to add the item because it is not scriptable.

Additionally, when running the following command in Script Editor:

tell application "System Events" to ¬
    get has scripting terminology of application process "Evernote"

Its result is: false


Apparently at one time Evernote was AppleScript scriptable, however, in macOS Catalina, testing with Evernote from https://evernote.com/download/ and checking Evernote > About Evernote it shows:

10.11.5-mac-ddl-public (2530)
Editor: v121.2.15734
Service: v1.32.4
© 2019 – 2021 Evernote Corporation. All rights reserved

Looking for the typical AppleScript dictionary in /Applications/Evernote.app/Contents/Resources/ there is no Evernote.sdef files as would be expected if it was fully AppleScript scriptable.


If you do have a version of Evernote that is AppleScript scriptable then try the following, which I cannot test under the circumstances:

Change note1 to note in:

set myNote to create note1 with text myTitle title myTitle notebook "Imported Notes" tags ("imported_from_notes")

You might also want to put in some parentheses. e.g.

set myNote to (create note with text myTitle title myTitle notebook "Imported Notes" tags ("imported_from_notes"))

Unfortunately without a version of Evernote that is AppleScript scriptable, I cannot offer more.

data structures – Reverse An Array whats wrong with this type of code?

data structures – Reverse An Array whats wrong with this type of code? – Computer Science Stack Exchange

forms – PHP Code Not Generating Results

I wanted to create a calculator on my WordPress website.

But, my code is not generating results on the page after the form Submission.

Please help,
Thank you

MY CODE:

<form method="post" >
<label for="fname">Value</label>
<input id="value" name="inp1" type="number" value="" />
<label for="lname">Result</label>
<input type="submit" name="button1" value="Calculate" />

<?php

if(isset($_POST('inp1')))
        
    {
            $x=$_POST('inp1');
            
            function fact($x)
                {   
                                $fact=1;
                                for ($i=$x; $i>0; $i--)
                                    {
                                    $fact=$fact*($x);
                                    $x=$x-1;
                                    }
                                echo "Factorial of the number is $fact";

                }
        fact($x);
        
        
    }
        
        
    else 
            {echo "Enter the number";}
    
    
?>

customization – Adding Custom HTML/CSS/JS code in specific page

I’ve written a HTML/JS code, it’s something like a survey which consists of code like this:

 <div class="Question">
        <h3>1. I have the knowledge of procedures needed for starting and running a business <span class="star">
                *</span></h3>

        <br>

        <div class=None>
            <input type="radio" name="Q1" id="none1" value="None">
            <label for="none1">None</label>
        </div>

        <div class=Withguidance>
            <input type="radio" name="Q1" id="wguid1" value="With Guidance">
            <label for="wguid1">With Guidance</label>
        </div>

        <div class=Beginner>
            <input type="radio" name="Q1" id="beg1" value="Beginner">
            <label for="beg1">Beginner</label>
        </div>

        <div class="Intermediate">
            <input type="radio" name="Q1" id="inter1" value="Intermediate">
            <label for="inter1">Intermediate</label>
        </div>

        <div class="Expert">
            <input type="radio" name="Q1" id="ex1" value="Expert">
            <label for="ex1">Expert</label>
        </div>
    </div>

At the end of the questions, there is a button that uses jsPDF library to convert the answers inputted by the user into a custom PDF that i made. Now this works perfectly when running the raw html file. The problem comes when i tried to insert it on my WordPress site.
Firstly, i use the latest version of WordPress and Elementor (WordPress 5.7.1 and Elementor Pro 3.1.1)

At the trial phases , before my code was complete, i could add it perefectly fine using the HTML widget on Elementor. As the code got bigger and lines were added, Elementor started lagging everytime i copied pasted my code. When my code was finished, when i tried to copy paste my code in Elementor, the page tab got unresponsive and couldn’t do anything than close the tab. I couldn’t paste my code in the HTML widget regardless how many times i tried.
I then tried using the Gunberg editor, while the code pasted and the tab was responsive, when i tried to update, there was an error “Update failed”.
Is there anyway that i can paste the code to my page without it crashing? Maybe with a plugin or via source files?
I already tried WP Coder but it didnt work.

P.S. I use 2 base64 strings, one for an image and one for a font that may be the reason that the editors cant handle the code. The base64 strings worked perefectly fine at the beginning, before the code got bigger.

Thanks in advance!
(sorry if my English is poor, not a native speaker)

entities – Enable Layout Builder via code

I figured it out. You can enable Layout Builder by running the following code in a custom module:

$entity_type = 'node';
$content_type = 'article';
$view_type = 'default';

Drupallayout_builderEntityLayoutBuilderEntityViewDisplay::load("{$entity_type}.{$content_type}.{$view_type}")
  ->enableLayoutBuilder()
  ->setOverridable()
  ->save();

Hopefully this helps someone else. Having to do it via the UI is painful if you have a lot of content types. I’m actually surprised this isn’t a Drush command yet. Oh well.

Source: https://www.drupal.org/project/drupal/issues/3158916

can I use free version of mongodb (for camercial use) without publishing source code?

can I use free version of mongodb (for camercial use) without publishing source code??? I just want Download mongodb And use it in a project for datebase. (Google translate)

random – This code is a non-static C# class for rolling a number of dice

Fellow human beings, today I present to you my dice rolling script! Behold, in my amateurish attempt at some raw C# code. Perhaps this will remain here regardless of the dozens of other dice rolling scripts out there.

Contains a ‘for’ loop, a ‘switch’, and a method that returns a value.

I have indeed read through other, similar iterations of this class, and I have found them to be lacking in what I might learn from, usually due to over-complication for my tiny brain, or because it invoked the use of libraries I have yet to hear of.

I did my best to make it easy to read for whichever intrigued person stumbles upon this. I deeply respect and appreciate any who may take the time to offer any criticism on my code. What did I do right? What did I do wrong? I don’t have anyone or anywhere else to share it with.

using System;

namespace C_
{
    class RollDice : Program
    {


        //Variables

        int numOfDice;
        int numOfSides;

        int maxDice = 100;
        int minDice = 1;
        int maxSides = 100;
        int minSides = 1;
        int totalRolled;

        //Start method for number of Dice to throw - take the player input in InputMethod() which returns an int. If returning 0, then restart. Clamp the value between min/max. Continue to next function.

        public void GetDice()
        {
            Console.WriteLine("Welcome to Roll Dice!");
            Console.WriteLine("How many dice do you want to throw?");
            numOfDice = InputMethod();
            if(numOfDice == 0)
            {
                GetDice();
            }
            if (numOfDice > maxDice || numOfDice < minDice)
            {
                numOfDice = Math.Clamp(numOfDice, minDice, maxDice);
                Console.WriteLine($"Number of Dice set to {numOfDice}");
            }

            GetSides();
        }

        // Get the sides of each dice by using a similar process. Roll() for each dice, then sum the totals in RollTotal().

        public void GetSides()
        {
            Console.WriteLine("How many sides does each dice have?");
            numOfSides = InputMethod();
            if(numOfSides == 0)
            {
                GetSides();
            }
            if (numOfSides > maxSides || numOfSides < minSides)
            {
                numOfSides = Math.Clamp(numOfSides, minSides, maxSides);
                Console.WriteLine($"Number of Sides set to {numOfSides}");
            }

            for (int x = 1; x <= numOfDice; x++)
            {
                Roll();
            }

            RollTotal();
        }


        // Create a new Random() instance for the number of sides and add it to the totalRolled variable.

         public void Roll()
        {
            Console.WriteLine(".....");
            Console.WriteLine("Rolling");
            Random r = new Random();
            var result = r.Next(1, numOfSides + 1);
            Console.WriteLine($"You rolled {result}");
            totalRolled += result;
        }
        
        // Output the total and prompt to roll again or quit. Reset the total..

        public void RollTotal()
        {
            Console.WriteLine($"Total sum rolled is {totalRolled}");
            Console.WriteLine(" ");
            Console.WriteLine("Enter 1 to re-roll or 2 to quit.");
            var answer = InputMethod();

            switch (answer)
            {
                case 0:
                RollTotal();
                break; 
            
                case 1:
                totalRolled = 0;
                GetDice();
                break;           
            
                case 2:
                totalRolled = 0;
                Environment.Exit(0);
                break;
            
                default:
                Environment.Exit(0);
                break;
            }
        }

        //Convert the input to an integer if valid and return the value. Else return 0.

        public int InputMethod()
        {
            var input = Console.ReadLine();
            if(!Int32.TryParse(input, out int convertedStringToInt))

            {
                Console.WriteLine("You need to enter a valid number!");
                return 0;
            }
            
            else 
            
            {
                return Convert.ToInt32(input);
            }

        }

    }
}

Python Visual Studio Code – Stack Overflow en español

tengo un problemas…cuando quiero ejecutar algo no me deja y me saca todo malo, aparte me pide una extensión a Python y no me arregla nada eso, necesito resolver ese programa hasta he intentado descargar de nuevo e instalar los paquetes que me pide

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123