I’m a developer, trying to land a job at an exchange. What type of software would an exchange need? Want to build something to use as a resume

I think there are few values that every exchange is looking for.

  • ability to work with multiple coins (exchanges = shitcoin casinos)
  • ability to generate the addresses and manage them securely on-scale within organization
  • knowledge of API interfaces

Regarding second point (as it’s a bitcoin-related board) I’d advise looking at few projects that you can work on yourself, copying the ideas:

Although it relates to bigger exchanges only, as smaller ones use external order books and usually work only on the frontend.

Is this the return type covariance issue PHP faced when type declarations launched, violation of Liskov principle, or flaw in my pattern?

I’ve been using a somewhat odd yet effective pattern for a current use case. The one issue is that I’m getting an undefined method notice on a method that is unique to the subclass. The method of course works fine but the notice leads me to believe that either my architecture is shotty or something else is going on.

I don’t believe this violates Liskov Principle as the subclass satisfies all contracts with identical signatures, put simply, it could replace any other subclass and work reliably.

Is this an instance of the variance issue PHP has stated when releasing type declarations, a violation of Liskov principle, or do I need to clean up my architecture?

Quick code example and brief explanation.

interface Quiz
{
    public function generate() : void;
}

class LessonQuiz implements Quiz
{
    public function generate() : void
    {
        //stuff here
    }

    public function lessonId() : int 
    {
        //stuff here
    }
}

class QuizClient //Determines/returns instantiated quiz subclass & other permission stuff.
{
    public static function create(string $case) : Quiz
    {
        switch($case){
            case('lesson'): return new LessonQuiz;
            //more logic     
        }
    }
}

/** In another class that builds a lesson template.
* ... 
*/
$quiz = QuizClient::create('lesson');
$lessonId = $quiz->lessonId(); //undefined method.

I have a client that determines and returns a subclass object of an interface. The return type is set to the interface as I need to have some instance of that interface returned.

All subclasses satisfy the interface contracts with identical signatures. However, the subclass specific method is undefined. I don’t understand why this is incorrect. Class ‘LessonQuiz’ is an instance of ‘QuizFactory’ but also ‘LessonQuiz’.

This does work but the fact that it reports method undefined makes me suspicious about my architecture.

Would really appreciate any help.

c++ – How to define values dependant on the derived type?

My base class must provide an interface to get a value that is dependent solely on the type of the derived class. I can think of two ways of implementing this:

Solution A, virtual functions:

class Base
{
public:
    virtual ~Base() = default;

    virtual int get_plain_value() const = 0;
};

class A final: public Base
{
public:
    int get_plain_value() const override
    {
        return 42;
    }
};

class B final: public Base
{
public:
    int get_plain_value() const override
    {
        return 35;
    }
};

Solution B, variable on base class:

class Base
{
public:
    virtual ~Base() = 0;

    int get_plain_value() const
    {
        return plain_value;
    }

protected:
    int plain_value;
};

Base::~Base() {}


class A final: public Base
{
public:
    A()
    {
        plain_value = 42;
    }
};

class B final: public Base
{
public:
    B()
    {
        plain_value = 35;
    }
};

Solution A is more robust (i.e. base class can not “forget” to set the value), and uses less memory (I have one new entry in vtable, which is per class, instead of one new variable per object).

But solution B is faster and much simpler from compiler’s perspective, so much that get_plain_value() is most likely inlined, and the value is simply read directly from the object memory, avoiding a function call entirely.

Is there a third option with benefits from both approaches? What is the recommended solution in these cases?

theming – Naming convention for field type templates?

The naming convention for fields is documented here, Twig Template naming conventions

  • field–node–(field-name)–(content-type).html.twig
  • field–node–(field-name).html.twig
  • field–node–(content-type).html.twig
  • field–(field-name).html.twig
  • field–(field-type).html.twig field.html.twig

But field--text-with-summary.html.twig is one of those that is harder/trickier to figure out from just looking at the Field Type.

enter image description here


To make Drupal life easy for this, you can enable Twig Debug. See Locating Template Files with Debugging

Now when you inspect element with browser, you can see which template file is being used (the one with the “x”) and what other available template file names (the ones with “*”) you could use.

enter image description here

theming – How can I specify how to display a new Paragraph type with images using HTML?

I want to create a “figure” Paragraphs type, which contains an image field and a caption field. How (from start to finish) do I specify in HTML/twig how to render this new Paragraphs type?

As an example, how would I specify that the output would look like the following code?

<figure>
  <img src="https://drupal.stackexchange.com/image">
  <figcaption>caption</figcaption>
</figure>

woocommerce – Using custom post type to feed a dropdown (Woo order-id into wpforms)

Using the plugin wpForms, I can auto-populate a dropdown with Custom Post Types (they call it “Dynamic Post Type Source”). Say I wanted to use this functionality to auto-populate a dropdown with order-ids from WooCommerce, so a logged-in-user can choose between the users orders.

I’ve written the code for getting a logged-in-user order-id’s, so how would I make a CPT that would not really create new posts, but instead be populated with a logged-in-users order-ids at run time (while the user is at a page with the form dropdown on it)?

Already asked wpForms for support, they did not want to help.

Code for getting the User Order-ids:

function woo_get_orderids_per_user( $content) {

$userID = get_current_user_id();

if( $userID > 0 ) {

        $orders= wc_get_orders(array(
            'customer_id' => $userID,
            'return' => 'ids',
        )); 

        foreach ($orders as $oids) {

            $order = wc_get_order( $oids );
            $items = $order->get_items();

            foreach ( $items as $item ) {
                $product = wc_get_product( $item('product_id') );
                $productname = $product->get_name();
                echo('<br> Product name: ');
                print_r($productname . ' (ordrenummer: ' . $oids . ')');
            }
        }

$content = str_replace( '{woo_orderid}', $productname . ' (Ordre ID: ' . $oids . ')', $content );

return $content;
}

else {
    return;
}

}

Asymptotic of divide-and-conquer type recurrence with non-constant weight repartition between subproblems and lower order fudge terms

While trying to analyse the runtime of an algorithm, I arrive to a recurrence of the following type :

$$begin{cases}
T(n) = Theta(1), & text{for small enough $n$;}\
T(n) leq T(a_n n + h(n)) + T((1-a_n)n+h(n)) + f(n), & text{for larger $n$.}
end{cases}$$

Where:

  • $a_n$ is unknown and can depend on $n$ but is bounded by two constants $0<c_1leq a_n leq c_2 < 1$.
  • $h(n)$ is some “fudge term” which is negligeable compared to $n$ (say $O(n^epsilon)$ for $0leq epsilon < 1$).

If $a_n$ was a constant, then I could use the Akra-Bazzi method to get a result. On the other hand, if the fudge term didn’t exist, then some type of recursion-tree analysis would be straight-forward.

To make things a bit more concrete, here is the recurrence I want to get the asymptotic growth of:

$$begin{cases}
T(n) = 1, & text{for n = 1;}\
T(n) leq T(a_n n + sqrt n) + T((1-a_n)n+sqrt n) + n, & text{for $n geq 2$}
end{cases}$$

Where $frac{1}{4} leq a_n leq frac{3}{4}$ for all $ngeq 1$.

I tried various guesses on upper bounds or transformations. Everything tells me this should work out to $O(nlog(n))$ and I can argue informaly that it does (although I might be wrong). But I can only prove $O(n^{1+epsilon})$ (for any $epsilon>0$), and this feels like something that some generalization of the Master theorem à la Akra-Bazzi should be able to take care of.

Any suggestions on how to tackle this type of recurrence?

mysql – Is it true that ORM allows for changing the type of SQL that you use easily?

Being able to change the actual database is not an intrinsic property of ORM, but many (most?) ORM libraries do provide that ability.

The main goal of an ORM is to bridge the gap between the RDBM world of tables, keys and queries and the OO world of objects, inheritance and associations/aggregations/compositions. They are intended to make your life easier when accessing a database from an OO context and/or mindset.

Custom Post Type / Taxonomy not displaying archive

I am trying to use the Atreas Theme: https://wordpress.org/themes/antreas/

This is the site I am working on: https://sandbox.paediatricphysiotherapyassociates.com/

All I want is an archive page for my Team Members to display them all in one spot.
I tried adding:
'has_archive' => true'
to the plugin php files directly “cpost-team.php” but I can’t for the life of me find the url for the archive page for Team Members. Either that or I’m missing something else. This is the direct code for this “Custom Posts” (aka Team Members) plugin:

<?php

//Define team post type
add_action( 'init', 'cpo_cpost_team' );
function cpo_cpost_team() {
   $show_ui = false;
   if ( defined( 'CPOTHEME_USE_TEAM' ) || cpo_get_option( 'display_team' ) ) {
       $show_ui = true;
   }
   $labels = array(
       'name'               => __( 'Team Members', 'cpo-companion' ),
       'singular_name'      => __( 'Team Member', 'cpo-companion' ),
       'add_new'            => __( 'Add Team Member', 'cpo-companion' ),
       'add_new_item'       => __( 'Add New Team Member', 'cpo-companion' ),
       'edit_item'          => __( 'Edit Team Member', 'cpo-companion' ),
       'new_item'           => __( 'New Team Member', 'cpo-companion' ),
       'view_item'          => __( 'View Team Member', 'cpo-companion' ),
       'search_items'       => __( 'Search Team Members', 'cpo-companion' ),
       'not_found'          => __( 'No team members found.', 'cpo-companion' ),
       'not_found_in_trash' => __( 'No team members found in the trash.', 'cpo-companion' ),
       'parent_item_colon'  => '',
   );

   $member_slug = cpo_get_option( 'slug_team_member' );
   if ( '' == $member_slug ) {
       $member_slug = 'cpo_team';
   }

   $fields = array(
       'labels'              => $labels,
       'public'              => true,
       'publicly_queryable'  => true,
       'exclude_from_search' => true,
       'show_ui'             => $show_ui,
       'query_var'           => true,
       'rewrite'             => array( 'slug' => apply_filters( 'cpotheme_slug_team_member', $member_slug ) ),
       'capability_type'     => 'page',
       'hierarchical'        => false,
       'menu_icon'           => 'dashicons-universal-access',
       'menu_position'       => null,
       'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ),
   );

   register_post_type( 'cpo_team', $fields );

}


//Define admin columns in team post type
add_filter( 'manage_edit-cpo_team_columns', 'cpo_cpost_team_columns' );
if ( ! function_exists( 'cpo_cpost_team_columns' ) ) {
   function cpo_cpost_team_columns( $columns ) {
       $columns = array(
           'cb'             => '<input type="checkbox" />',
           'ctct-image'     => __( 'Image', 'cpo-companion' ),
           'title'          => __( 'Title', 'cpo-companion' ),
           'ctct-team-cats' => __( 'Groups', 'cpo-companion' ),
           'date'           => __( 'Date', 'cpo-companion' ),
           'author'         => __( 'Author', 'cpo-companion' ),
       );
       return $columns;
   }
}

//Define team category taxonomy
add_action( 'init', 'cpo_tax_teamcategory' );
if ( ! function_exists( 'cpo_tax_teamcategory' ) ) {
   function cpo_tax_teamcategory() {
       $labels = array(
           'name'               => __( 'Member Groups', 'cpo-companion' ),
           'singular_name'      => __( 'Member Group', 'cpo-companion' ),
           'add_new'            => __( 'New Member Group', 'cpo-companion' ),
           'add_new_item'       => __( 'Add Member Group', 'cpo-companion' ),
           'edit_item'          => __( 'Edit Member Group', 'cpo-companion' ),
           'new_item'           => __( 'New Member Group', 'cpo-companion' ),
           'view_item'          => __( 'View Member Group', 'cpo-companion' ),
           'search_items'       => __( 'Search Member Groups', 'cpo-companion' ),
           'not_found'          => __( 'No member groups were found.', 'cpo-companion' ),
           'not_found_in_trash' => __( 'No member groups were found in the trash.', 'cpo-companion' ),
           'parent_item_colon'  => '',
       );

       $slug = cpo_get_option( 'slug_team_category' );
       if ( '' == $slug ) {
           $slug = 'team-group';
       }
       $fields = array(
           'labels'            => $labels,
           'public'            => true,
           'show_ui'           => true,
           'show_in_nav_menus' => true,
           'show_tagcloud'     => false,
           'rewrite'           => array( 'slug' => apply_filters( 'cpotheme_slug_team_category', $slug ) ),
           'hierarchical'      => true,
       );

       register_taxonomy( 'cpo_team_category', 'cpo_team', $fields );
   }
}

Also based on the code what should the url outcome be? I assumed it should be on: https://sandbox.paediatricphysiotherapyassociates.com/cpo_team/

Additionally my custom taxonomy for team members (groups) is not displaying posts that fall under the given group: https://sandbox.paediatricphysiotherapyassociates.com/?cpo_team_category=ba
enter image description here

Sorry I’m not great with php. Thank you in advance!!

sharepoint online – Unable to filter the items based on the content type inside my content search web part

I have a content search web part inside our sharepoint online site collection, and i want to show items which are under certain content type, but when i use the following to get the items which are linked to a content type named “OrderManagmentSales”, as follow:-

enter image description here

i got all the items and not only the ones associated with the “OrderManagementSales” content type, any idea why this is not working? seems the content search web part ignore the ContentType:"OrderManagementSales" inside the query..

Thanks