text:
Q: how to add "/*! */ " in object key while splitting string? I am splitting my string and convert it into javascript obj . but my key miss this character /*! */ .
here is my string and splitter function

const a = "/*! ###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### *//*! MISC + SASS */a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}/*! GENERIC - BGIMG */.bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}/*! CG2111 - test */span{color:red}/*! CG2112 - test */span{color:red}/*! INFO */#id{content:'1.1.1'}";

const result = {},
  temp = a.split(/\/\*\!\s*(.*?)\s*\*\//).slice(1);
while (temp.length) result[temp.shift()] = temp.shift();

console.log(result);

My output
{"###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ######################################################":"","MISC + SASS":"a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}","GENERIC - BGIMG":".bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}","CG2111 - test":"span{color:red}","CG2112 - test":"span{color:red}","INFO":"#id{content:'1.1.1'}"}

Expected ouput
 {
  "/*! ###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### */": "",
  "/*! MISC + SASS */": "a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}",
  "/*! GENERIC - BGIMG */": ".bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}",
  "/*! CG2111 - test */": "span{color:red}",
  "/*! CG2112 - test */": "span{color:red}",
  "/*! INFO */": "#id{content:'1.1.1'}"
}

A: All your matches start with /*! followed by a space, so match those characters up until lookahead matches the same /*! or the end of the string.

const a = "/*! ###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### *//*! MISC + SASS */a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}/*! GENERIC - BGIMG */.bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}/*! CG2111 - test */span{color:red}/*! CG2112 - test */span{color:red}/*! INFO */#id{content:'1.1.1'}";

const result = Object.fromEntries(
  [...a.matchAll(/(\/\*! .*?\*\/)(.*?)(?=\/\*! |$)/g)]
    .map(([, key, value]) => [key, value])
);
console.log(result);

*

*\/\*! - match a literal /, followed by a literal *, followed by *

*  - match a literal space

*.*? - match as few characters as possible up until

*(?=\/\*! |$) lookahead matches

*

*\/\*! - the same beginning characters, or

*$ - the end of the string

A: ES6 answer:

const a = "/*! ###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### *//*! MISC + SASS */a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}/*! GENERIC - BGIMG */.bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}/*! CG2111 - test */span{color:red}/*! CG2112 - test */span{color:red}/*! INFO */#id{content:'1.1.1'}";

const map = a.split('/*!').slice(1) // break into each item per key-value pair
  .map(str => str.split('*/')) // separate key and value
  .map(([key, value]) => [`/*!${key}*/`, value]) // add back delimiters
  .reduce((map, [key, value]) => ({...map, [key]: value}), {}); // merge into a map

console.log(map);

Output:
{
  "/*! ###################################################### # Test.cs #  RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### */": "",
  "/*! MISC + SASS */": "a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}",
  "/*! GENERIC - BGIMG */": ".bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}",
  "/*! CG2111 - test */": "span{color:red}",
  "/*! CG2112 - test */": "span{color:red}",
  "/*! INFO */": "#id{content:'1.1.1'}"
}


text:
Q: How do I fetch data in React.Component class through Context API? How do I fetch data coming from another component using Context API, and the component which accepts the data should be a React.Component (NOT in a function component).
I want to get data which resides in Context. Provider as a component.
I googled on how to use React Context API, and all the answers are based on using functional component, NOT React. Component.
Since I do not know how to fetch data from other components using Context API, so I tried PubSub-JS, but now I want to use Context API.
I have a component using Context API, and I want to get data from below component.
import React, {Component} from "react";
import axios from "axios";

const VideoInformationContext = React.createContext();

class VideoContext extends Component{

    constructor(props){
        super(props);
        this.state = {
            videoIdx: props.videoIdx
            videoList:null,
            theme:null
        }
    }

    componentDidMount(){
        this.loadResource();
    }

    loadResource(){
        axios({
            url:`<TEST SERVER>?videoIdx=${this.state.videoIdx}`,
            method:"get"
        }).then(response => {
            this.setState({
                videoList:response.data.videosAndTheme.videoList,
                theme:response.data.videosAndTheme.theme
            });
        });
    }

    render(){
        return (
            <VideoInformationContext.Provider value={this.state}>
                {this.props.children}
            </VideoInformationContext.Provider>
        );
    }
}

export const VideoinformationConsumer = VideoInformationContext.Consumer;
export default VideoContext;

So my question is that I want to get data in ComponentDidMount() method in React. Component fetching from the above component.

A: In the consumer component you can set the context using static contextType = MyContext;  so your provider component would look something like the following:
import React, {Component} from "react";
import axios from "axios";

export const VideoInformationContext = React.createContext();

class VideoContext extends Component{

    constructor(props){
        super(props);
        this.state = {
            videoIdx: props.videoIdx
            videoList:null,
            theme:null
        }
    }

    componentDidMount(){
        this.loadResource();
    }

    loadResource(){
        axios({
            url:`<TEST SERVER>?videoIdx=${this.state.videoIdx}`,
            method:"get"
        }).then(response => {
            this.setState({
                videoList:response.data.videosAndTheme.videoList,
                theme:response.data.videosAndTheme.theme
            });
        });
    }

    render(){
        return (
            <VideoInformationContext.Provider value={this.state}>
                {this.props.children}
            </VideoInformationContext.Provider>
        );
    }
}

export default VideoContext;

And your consumer component would look something like the following:
import React, { Component } from 'react';
import { VideoInformationContext } from '--the location of your provider component--';

class MyConsumerComponent extends Component {
  static contextType = VideoInformationContext;

  componentDidMount(){
    // you can use it here like this
    const videoList = this.context.videoList;
  }
  render() {
    //or you can use it here like this
    return <p>{this.context.videoIdx}</p>;
  }
}

export default MyConsumerComponent;

So in your provider component export the created context like I did above and then in your consumer component import the context from wherever you set the context and then set the static contextType in your class and then you can access it anywhere in your component and in the render with this.context.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why is my output signal aliased when my sampling rate is decently above the Nyquist theorem? I'm really confused on what's happening here.
I have my ADC sampling at 44.410kHz and any frequency above 11Khz it would alias the output signal.
The max target frequency is 20kHz for clarification.
What I have checked so far is:

*

*if the ADC is actually sampling at 44.410kHz. Checked & good.

*if the DAC is bottle necking in any sort of way. I found this. STM32L43KC

*Checked my scope sampling rate. Used a trigger to get the most out of the sampling. Still the samething.

Mentioned in the datasheet on page 128:
\$t_{SAMP} typical = 2us\$ which should be good as the DAC is outputting at 44.410kHz which is 22us.
So I dont understand as to why my DAC is behaving like this.
Notes:
If you are curious as how I checked if the ADC is good, is two ways.

*

*In programming personally checked the register values

*Sampling at 44.410kHz, 4 samples in should finish around ~90us. Checked with scope and confirmed.

Pictures:

Code:
#include "main.h"
#include <stdint.h>

void init_Interrupt(void);
void init_Clock(void);
void init_Interrupt(void);
void init_DAC(void);
void init_ADC(void);
void init_GPIO_Test(void);
void init_Debug(void);
void print_ADC(short);
void init_Timer(void);

char buffer[20] = "ADC Value:     \n\r";

typedef struct PLL{
    uint8_t PLLN;
    uint8_t PLLR;
    uint8_t PLLM;
    uint8_t PLLSAI1N;
    uint8_t PLLSAI1R;
} PLL;

PLL find_PLL(uint32_t, uint32_t);
PLL CFGR;

uint8_t escape = 0;
uint8_t half_transfer_complete = 0;
uint8_t transfer_complete = 0;
uint32_t PLLN_MAX = 86;
uint32_t PLLSAI1N_MAX = 86;
uint32_t PLLR_MAX = 8;
uint32_t PLLSAI1R_MAX = 8;
uint32_t PLLM_MAX = 8;
uint32_t CPU_Speed = 80000000;
uint32_t ADC_Speed = 29000000;
uint16_t ADC_Value[8]; //  Hold 8 Samples

void DMA2_Channel3_IRQHandler(void){

    if (((DMA2->ISR) & (DMA_ISR_HTIF3)) != 0){
        half_transfer_complete = 1;
        DMA2->IFCR |= DMA_IFCR_CHTIF3;
    } else if (((DMA2->ISR) & (DMA_ISR_TCIF3)) != 0){
        transfer_complete = 1;
        DMA2->IFCR |= DMA_IFCR_CTCIF3;
    }
}

int main(void) {

  init_Clock();
  //init_Debug();
  init_ADC();
  init_DAC();
  init_GPIO_Test();
  init_Interrupt();
  init_Timer();

    while (1) {

            if (half_transfer_complete == 1){
                TIM6 ->CR1 |= TIM_CR1_CEN;
                GPIOA->BSRR |= GPIO_BSRR_BS0;

                half_transfer_complete = 0;
            }

            if (transfer_complete == 1){
                GPIOA->BSRR |= GPIO_BSRR_BR0;

                transfer_complete = 0;
            }
    };
}

PLL find_PLL(uint32_t CPU_Speed, uint32_t ADC_Speed) {

    PLL settings;

     for (int PLLN = 8; PLLN <= PLLN_MAX; PLLN ++){
        if (escape == 1){
            break;
        }
         for (int PLLM = 1; PLLM <= PLLM_MAX; PLLM ++){
             if (escape == 1){
                 break;
             }
            for (int PLLR = 2; PLLR <= PLLR_MAX ; PLLR +=2){
                if ((((4000000/PLLM) * PLLN) >= 64000000) & (((4000000/PLLM) * PLLN) <= 344000000)){
                    if (((4000000/PLLM) >= 4000000) & ((4000000/PLLM) <= 16000000)) {
                        if (((((4000000/PLLM)*PLLN)/PLLR) >= 8000000) & ((((4000000/PLLM)*PLLN)/PLLR) <= 80000000)){
                           uint32_t PLL_CALC = (((4000000/PLLM)*PLLN)/PLLR);
                            if (PLL_CALC == CPU_Speed){
                              settings.PLLM = PLLM;
                              settings.PLLR = PLLR;
                              settings.PLLN = PLLN;
                              escape = 1;
                              break;
                            }
                        }
                    }
                }

                }
            }
        }

        escape = 0;

        for (int PLLSAI1N = 8; PLLSAI1N <= PLLSAI1N_MAX; PLLSAI1N ++){
            if (escape == 1){
                 break;
        }
            for (int PLLSAI1R = 2; PLLSAI1R <= PLLSAI1R_MAX; PLLSAI1R += 2){
                if ((((4000000/settings.PLLM) * PLLSAI1N) >= 64000000) & (((4000000/settings.PLLM) * PLLSAI1N) <= 344000000)){
                   if (((((4000000/settings.PLLM)*PLLSAI1N)/PLLSAI1R) >= 8000000) & ((((4000000/settings.PLLM)*PLLSAI1N)/PLLSAI1R) <= 80000000)){
                       uint32_t PLLSAI1_CALC = (((4000000/settings.PLLM)*PLLSAI1N)/PLLSAI1R);
                       if (PLLSAI1_CALC == ADC_Speed){
                        settings.PLLSAI1R = PLLSAI1R;
                        settings.PLLSAI1N = PLLSAI1N;
                        escape = 1;
                        break;
                    }
                   }

                }
            }
          }
                return settings;
        }

void init_ADC(){

        //Pin - A6

        RCC   -> AHB2ENR |= RCC_AHB2ENR_GPIOAEN | RCC_AHB2ENR_ADCEN;
        RCC   -> AHB1ENR |= RCC_AHB1ENR_DMA2EN;
        RCC   -> CCIPR   |= RCC_CCIPR_ADCSEL_1;

        GPIOA -> MODER &= ~GPIO_MODER_MODE7;
        GPIOA -> MODER |=  GPIO_MODER_MODE7_Analog; //PIN A6

        // |------------------- ADC VALUE ----------------------|
        // 16-bit @ Sampling ~44.410kHZ
        //Holding 8 samples at a time
        // 16-bit = 2 byte * 8 =  16 bytes
        DMA2_Channel3 -> CCR |= (DMA_CCR_PSIZE_16_Bit) |
                              (DMA_CCR_MSIZE_16_Bit)   |
                              (DMA_CCR_MINC)           |
                              (DMA_CCR_CIRC)           |
                              (DMA_CCR_TCIE)           |
                              (DMA_CCR_HTIE)           |
                              (DMA_CCR_PL_Very_High);
        DMA2_CSELR    -> CSELR &= ~DMA_CSELR_C3S;
        DMA2_Channel3 -> CNDTR |= 0x08;
        DMA2_Channel3 -> CMAR = (uint32_t)ADC_Value; //Memory Address
        DMA2_Channel3 -> CPAR = (uint32_t)&ADC1->DR; //Peripheral Addres
        DMA2_Channel3 -> CCR |= DMA_CCR_EN;

        ADC1 -> CR &= ~ADC_CR_DEEPPWD;
        ADC1 -> CR |= ADC_CR_ADVREGEN;
        ADC1 -> CR &= ~ADC_CR_ADCALDIF;
        ADC1 -> CR |= ADC_CR_ADCAL;
        while((ADC1->CR & ADC_CR_ADCAL) != 0) //Wait for Calibration to be done
        ;

        ADC1 -> CFGR  |= ADC_CFGR_CONT | ADC_CFGR_DMACFG;
        ADC1 -> CFGR  &= ~ADC_CFGR_ALIGN_RIGHT | ADC_CFGR_RES_12_Bit;
        ADC1 -> SMPR2 |= ADC_SMPR2_SMP12_640_ADC_CYCLES;
        ADC1 -> SQR1  |= ADC_SQR1_SQ1_12;

        ADC1 -> ISR |= ADC_ISR_ADRDY;
        ADC1 -> CR  |= ADC_CR_ADEN; //Enable: ADC

        while((ADC1->ISR & ADC_ISR_ADRDY) == 0) //Wait for the ADC to be ready
        ;

        ADC1 -> ISR  |= ADC_ISR_ADRDY; //Clear the ARDYFlAG
        ADC1 -> CR   |= ADC_CR_ADSTART; //Start the ADC
        ADC1 -> CFGR |= ADC_CFGR_DMAEN;

}

void init_Clock() {

    CFGR = find_PLL(CPU_Speed, ADC_Speed);

        // |----------------------------------- WAIT STATE: 0 -----------------------------------|
        if (CPU_Speed <= 16000000) {

            FLASH -> ACR &= ~FLASH_ACR_LATENCY_Msk;
            FLASH -> ACR |= FLASH_ACR_LATENCY_0WS;

            if ((FLASH -> ACR & FLASH_ACR_LATENCY_0WS) != FLASH_ACR_LATENCY_0WS){
                //ERROR: System didn't change wait states properly
            } else{
                //Success
            }

        // |----------------------------------- WAIT STATE: 1 -----------------------------------|
        } else if (CPU_Speed <= 32000000){

            FLASH -> ACR &= ~FLASH_ACR_LATENCY_Msk;
            FLASH -> ACR |= FLASH_ACR_LATENCY_1WS;

            if ((FLASH -> ACR & FLASH_ACR_LATENCY_1WS) != FLASH_ACR_LATENCY_1WS){
                //ERROR: System didn't change wait states properly
            } else{
                //Success
        }

        // |----------------------------------- WAIT STATE: 2 -----------------------------------|
        } else if (CPU_Speed <= 48000000){

            FLASH -> ACR &= ~FLASH_ACR_LATENCY_Msk;
            FLASH -> ACR |= FLASH_ACR_LATENCY_2WS;

            if ((FLASH -> ACR & FLASH_ACR_LATENCY_2WS) != FLASH_ACR_LATENCY_2WS){
                //ERROR: System didn't change wait states properly
            } else{
                //Success
            }

        // |----------------------------------- WAIT STATE: 3 -----------------------------------|
        } else if (CPU_Speed <= 64000000){

            FLASH -> ACR &= ~FLASH_ACR_LATENCY_Msk;
            FLASH -> ACR |= FLASH_ACR_LATENCY_3WS;

            if ((FLASH -> ACR & FLASH_ACR_LATENCY_3WS) != FLASH_ACR_LATENCY_3WS){
                //ERROR: System didn't change wait states properly
            } else{
                //Success
            }

        // |----------------------------------- WAIT STATE: 4 -----------------------------------|
        } else if (CPU_Speed <= 80000000){

            FLASH -> ACR &= ~FLASH_ACR_LATENCY_Msk;
            FLASH -> ACR |= FLASH_ACR_LATENCY_4WS;

            if ((FLASH -> ACR & FLASH_ACR_LATENCY_4WS) != FLASH_ACR_LATENCY_4WS){
                //ERROR: System didn't change wait states properly
            } else{
                //Success
            }

        } else{
            //Error: Clock Speed too high
        }

        RCC -> CFGR |= RCC_CFGR_SW_PLL;
        PWR -> CR1  &= ~PWR_CR1_VOS_Msk;
        PWR -> CR1  |= PWR_CR1_VOS_0;
        RCC -> CR   |= RCC_CR_MSIRGSEL | RCC_CR_MSIRANGE_6;

        // |----------------------------------- PLLCFGR: R -----------------------------------|
        if (CFGR.PLLR == 2){
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLR_Msk;
            RCC -> PLLCFGR |= RCC_PLLCFGR_PLLR_2;
        } else if (CFGR.PLLR == 4){
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLR_Msk;
            RCC -> PLLCFGR |= RCC_PLLCFGR_PLLR_4;
        } else if (CFGR.PLLR == 6){
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLR_Msk;
            RCC -> PLLCFGR |= RCC_PLLCFGR_PLLR_6;
        } else if (CFGR.PLLR == 8){
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLR_Msk;
            RCC -> PLLCFGR |= RCC_PLLCFGR_PLLR_8;
        }

        // |----------------------------------- PLLCFGR: M -----------------------------------|
        if (CFGR.PLLM == 1){
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLM_Msk;
        } else {
            RCC -> PLLCFGR &= ~RCC_PLLCFGR_PLLM_Msk;
            RCC -> PLLCFGR |= (CFGR.PLLM-1) << RCC_PLLCFGR_PLLM_Pos;
        }

        // |----------------------------------- PLLCFGR: N -----------------------------------|
        RCC -> PLLCFGR &= ~(RCC_PLLCFGR_PLLN_Msk);
        RCC -> PLLCFGR |= ((CFGR.PLLN) << RCC_PLLCFGR_PLLN_Pos) | (RCC_PLLCFGR_PLLREN) | (RCC_PLLCFGR_PLLSRC_MSI);

        // |----------------------------------- PLLSAI1CFGR: R -----------------------------------|
        if (CFGR.PLLSAI1R == 2){
            RCC -> PLLSAI1CFGR &= ~RCC_PLLSAI1CFGR_PLLSAI1R_Msk;
            RCC -> PLLSAI1CFGR |= RCC_PLLSAI1CFGR_PLLSAI1R_2;
        } else if (CFGR.PLLSAI1R == 4){
            RCC -> PLLSAI1CFGR &= ~RCC_PLLSAI1CFGR_PLLSAI1R_Msk;
            RCC -> PLLSAI1CFGR |= RCC_PLLSAI1CFGR_PLLSAI1R_4;
        } else if (CFGR.PLLSAI1R == 6){
            RCC -> PLLSAI1CFGR &= ~RCC_PLLSAI1CFGR_PLLSAI1R_Msk;
            RCC -> PLLSAI1CFGR |= RCC_PLLSAI1CFGR_PLLSAI1R_6;
        } else if (CFGR.PLLSAI1R == 8){
            RCC->PLLSAI1CFGR &= ~RCC_PLLSAI1CFGR_PLLSAI1R_Msk;
            RCC->PLLSAI1CFGR |= RCC_PLLSAI1CFGR_PLLSAI1R_8;
        }

        // |----------------------------------- PLLSAI1CFGR: N -----------------------------------|
        RCC -> PLLSAI1CFGR &= ~(RCC_PLLSAI1CFGR_PLLSAI1N_Msk);
        RCC -> PLLSAI1CFGR |= RCC_PLLSAI1CFGR_PLLSAI1REN | (CFGR.PLLSAI1N << RCC_PLLSAI1CFGR_PLLSAI1N_Pos);

        RCC -> CR |= RCC_CR_PLLON;
        while ((RCC->CR & RCC_CR_PLLRDY) == 0)
        ;
        RCC -> CR |= RCC_CR_PLLSAI1ON;
        while ((RCC -> CR & RCC_CR_PLLSAI1RDY) == 0)
        ;
        if ((RCC -> CFGR & RCC_CFGR_SWS_PLL) != RCC_CFGR_SWS_PLL ) {
            //Error: Clock Didn't switch
        }
}

void init_DAC(){

    //Pin A3
    RCC   -> APB1ENR1 |= RCC_APB1ENR1_DAC1EN;
    RCC   -> AHB2ENR  |= RCC_AHB2ENR_GPIOAEN;
    GPIOA -> MODER    &= ~GPIO_MODER_MODE4;
    GPIOA -> MODER    |= GPIO_MODER_MODE4_Analog;
    DAC1  -> CR       |= DAC_CR_EN1;
}

void init_Interrupt(){

    NVIC_EnableIRQ(DMA2_Channel3_IRQn);
    NVIC_SetPriority(DMA2_Channel3_IRQn,0);
}

void init_GPIO_Test(){

    RCC   -> AHB2ENR |= RCC_AHB2ENR_GPIOAEN;
    GPIOA -> MODER &= ~GPIO_MODER_MODE0;
    GPIOA -> MODER |= GPIO_MODER_MODE0_Gen_Purpose;
}

void print_ADC(short adcValue){

    short counter = 0;

    while (adcValue > 0){
        buffer[14-counter] = (adcValue % 10) + '0';
        adcValue = adcValue / 10;
        counter++;
    }

    if (counter == 0){

        buffer[14] = adcValue + '0';
        buffer[13] = ' ';
        buffer[12] = ' ';
        buffer[11] = ' ';

    } else if (counter == 1){
         buffer[13] = ' ';
         buffer[12] = ' ';
         buffer[11] = ' ';

    } else if (counter == 2){
         buffer[12] = ' ';
         buffer[11] = ' ';

    } else if (counter == 3){
         buffer[11] = ' ';
  }

    counter = 0;
}

void init_Debug(){

    RCC -> APB1ENR1 |= RCC_APB1ENR1_USART2EN;
    RCC -> AHB1ENR  |= RCC_AHB1ENR_DMA1EN;
    RCC -> AHB2ENR  |= RCC_AHB2ENR_GPIOAEN;
    RCC -> CCIPR    |= RCC_CCIPR_USART2SEL_System_Clock;

    GPIOA -> MODER  &= ~GPIO_MODER_MODE2;
    GPIOA -> MODER  |= GPIO_MODER_MODE2_Alt_Function;
    GPIOA -> AFR[0] |= GPIO_AFRL_AFSEL2_USART2;

    DMA1_Channel7 -> CCR  |= DMA_CCR_PL_High     |
                             DMA_CCR_MSIZE_8_Bit |
                             DMA_CCR_PSIZE_8_Bit |
                             DMA_CCR_MINC        |
                             DMA_CCR_CIRC        |
                             DMA_CCR_DIR;
    DMA1_CSELR    -> CSELR |= DMA_CSELR_C7S_USART2;
    DMA1_Channel7 -> CNDTR  = 0x14; // 20
    DMA1_Channel7 -> CMAR   = (uint32_t)buffer;
    DMA1_Channel7 -> CPAR   = (uint32_t)&USART2 -> TDR;
    DMA1_Channel7 -> CCR  |= DMA_CCR_EN;

    USART2 -> CR1 &= ~USART_CR1_M1 | ~USART_CR1_OVER16;
    USART2 -> CR1 |= USART_CR1_TE;
    USART2 -> CR3 |= USART_CR3_DMAT;
    USART2 -> BRR = 0x208D;
    USART2 -> CR1 |= USART_CR1_UE;
}

void init_Timer(){

    RCC -> AHB1ENR  |= RCC_AHB1ENR_DMA1EN;
    RCC -> APB1ENR1 |= RCC_APB1ENR1_TIM6EN;

    DMA1_Channel3 -> CCR |= DMA_CCR_PL_Very_High |
                            DMA_CCR_MSIZE_16_Bit |
                            DMA_CCR_PSIZE_16_Bit |
                            DMA_CCR_MINC         |
                            DMA_CCR_CIRC         |
                            DMA_CCR_DIR;
    DMA1_Channel3 -> CNDTR  = 0x08;
    DMA1_Channel3 -> CPAR   = (uint32_t)&DAC1->DHR12R1;
    DMA1_Channel3 -> CMAR   = (uint32_t)ADC_Value;
    DMA1_CSELR    -> CSELR |= DMA_CSELR_C3S_TIM_6_UP;
    DMA1_Channel3 -> CCR   |= DMA_CCR_EN;

    TIM6 -> DIER |= TIM_DIER_UDE;
    TIM6 -> ARR   = 0x708;
    TIM6 -> PSC   = 0x0;

}

EDIT: Added a FFT using the 13kHz signal.
EDIT 2: Added a new 13kHz picture but changing the scope's sampling rate to 50kSa/s from the previous higher sampling rate.

A: In a word - filtering.
In 2 words - brickwall filter.
brhans is on to something when he answered,

When you only sample 3 or 4 points for every cycle of the sine wave,
you're never going to be able to just push those samples out of a DAC
and expect to see something resembling that original sine wave.

but he's wrong. What you're seeing is an output which has a large amount of energy above the Nyquist limit, due to the step nature of the output. You need to create a high-order lowpass filter at about 20 kHz, and feed the DAC output through that. If you've got, for instance, a 12-bit waveform and you want accuracy at the 1-bit level, you'll need a filter with a response which is down 78 db at 22 kHz. This will take your stepped output and turn it into a nice, smooth sine wave.
The same consideration, of course, applies to inputs - the Nyquist theorem applies specifically to a band-limited signal with no energy above the limit.
The filter gets its name from its response: flat over a larger frequency band, then an almost vertical falloff (in the ideal case), followed by a flat zero response range. It looks like one side of a brick wall.
Since you want a filter which has as large a useful bandwidth as possible, you'll need a high-order filter to minimize the transition bandwidth. CD players, which have to do this, take advantage of the fact that music power levels are much lower at the high end than in the 30 - 3kHz range which is where audible fundamentals occur. As a result, they use filters which are not as good as theory demands, in order to reduce costs. Nonetheless, 5th and 7th order filters are the norm.
Every CD player has such a filter on its outputs, and you need to emulate them.

A: Here's a graph I quickly threw together with Excel.

Does it look at all familiar? Maybe just a little like your last scope capture?
That's because this is what you get when you sample a 13kHz sine wave at 44.41kHz.
What you're seeing is exactly what you should expect to see. What you're definitely not seeing there is aliasing.
When you only sample 3 or 4 points for every cycle of the sine wave, you're never going to be able to just push those samples out of a DAC and expect to see something resembling that original sine wave.
You would need to feed your samples through a reconstruction filter, and you can do that in the analog domain after the DAC or in the digital domain before the DAC, or even a bit of both.

A: A signal of frequency f, sampled at rate S, will be indistinguishable from a signal of frequency S-f, or an equal mix of signals at frequencies f and S-f.  The latter will in turn be indistinguishable from a ring-modulated signal with a carrier frequency of S/2 and modulation frequency of f-S/2.  For frequencies that close to S/2, the output will "look" like a ring-modulated signal because it's visually easier to recognize a signal at frequency S/2 than any nearby frequency.
If one takes a ring-modulated signal whose carrier frequency is C, and whose modulation frequency is M, and filters out all content whose frequency is above C, the result will be a signal at frequency C-M.  Plugging in S/2 for C and f-S/2 for M, one will end up with a signal at frequency (S/2)-(f-S/2), i.e. the original signal f.

A: Yes, you are seeing aliasing, though some folks would insist on a different word for what is mathematically the same thing, 'imaging'
It occurs around every harmonic of the sampling frequency. For instance, with a 13 kHz tone, and 44 kHz sampling frequency (rounded for mathematical simplicity), the output consists of 13 k, 44 ± 13 k = 31 k and 57 k, 2*44 ± 13 k = 75 k and 101 k, etc for all integer multiples of the sampling frequency.
The 'sample-and-hold' action of a DAC, that turns dirac delta impulses into square edge pulses, forms an inherent anti-alias filter, see zero order hold. For extreme oversampling, fs > 100*fsig, this is usually sufficient for an oscilloscope picture.
As soon as the signal frequency approaches any practical fraction of Nyquist, the aliasing becomes apparent. Just as you would never normally use an ADC without a preceding anti-alias filter, you would never normally use a DAC without a following anti-alias (often called reconstruction) filter.
There is a difference in the process of ADC and DAC that complicates the terminology. When doing ADC without an anti-alias filter, the alias frequencies can fall in-band, in the frequency range of the wanted signal, and are impossible to remove with subsequent filtering. When doing DAC with ideal signals, all the aliases fall out of band, at high frequencies, and are easily removed with a reconstruction filter. As these are easy to remove, some people insist they are called 'images', to distinguish them from the more pathological ADC 'aliases'. This is just terminology. The mathematics is identical for both of them.


text:
Q: Properties of orthogonal vectors. I am trying to find all unit vectors orthogonal to $\vec{v}=\langle{3,4,0}\rangle$.

So, in this pursuit, I considered the possibility of a property of vectors:
For a given non-zero vector $\vec{v}=\langle{a,b,c}\rangle$ there exists an orthogonal vector $\vec{u}=-\langle{\frac{1}{a}, \frac{1}{b}, \frac{1}{c}}\rangle$.

Is this true? I think I may be able to use this conclusion to aid in my prime objective.

A: No, your assertion is not true: $\left<\vec{v},\vec{u}\right>$ is the sum of the products of their entries, i.e., $a\cdot(-1/a)+b\cdot(-1/b)+c\cdot(-1/c)=-3\neq 0$.
Trivially, the vector $\left<0,0,1\right>$ is orthogonal to your vector. A second vector can be found via using the cross product $\left<3,4,0\right>\times\left<0,0,1\right>$ and normalization. For references, see also this and this post.
Note that the two vectors you thus got span a two-dimensional space. Every vector in this two-dimensional space is orthogonal to your vector.


text:
Q: Having trouble right-aligning pyramid for Mario problem set I am currently doing the Mario problem (less comfortable) for Week 1 of CS50. So far, I can print the hashes of the pyramid, but I am having trouble right-justifying it with the spaces. Would someone be able to pinpoint where I am going wrong? Thank you so much in advance.
#include <cs50.h>
#include <stdio.h>

int main(void)
{
int hashes;
int space;
int height;

do
{
    height = get_int("height: ");
}
while (height < 0 || height > 5);
{
    for (int i = 0; i <= height; i++)
    {
        for (space = (height - 1); space <= 0; space++)
        {
            printf(" ");
        }

        for (hashes = 1; hashes <= i; hashes++)
        {
            printf("#");
        }
        printf("\n");

    }

  }

}

A: As Antti said, in your 'spaces' loop, height - 1 on the first iteration of i (so where i = 0), will never be < or = to 0 (unless height is set to 1).
How many spaces should you print before the # on the first line if your height is set to 5? Is it 4?
So if on the first line int Space = 0, height = 5, what loop code would achieve a result of 4? But consider on the next iteration of Space if int Space = 1, Height = 5 what loop code could achieve a result of 3?
 for (space = 0; "this needs to to = 4" ; space++)
        {
            printf(" ");
        }

 for (space = 1; "this needs to to = 3" ; space++)
        {
            printf(" ");
        }

The value of 'spaces' changes on every iteration, could you use this?


text:
Q: can not insertSubView below another subView, ios I am implementing my own sliding view controller and the structure looks like below
ContainerViewController
   |
   |______FrontViewController
   |
   |______UIRearNavigationController (whose root is rearViewController1)
   |
   |______RearViewController2

Following are the methods to addSubViews
-(void)setupFrontViewController{
    [self.view addSubview:self.frontController.view];
}

-(void)setupRearViewController1 {
    self.rearNavigationController = [[UINavigationController alloc] initWithRootViewController:self.mainMenuViewController];
    [self.view insertSubview:self.rearNavigationController.view belowSubview:self.inboxCubeController.view];

    [self setupRearViewController2];
}
-(void)setupRearViewController2{
    [self.view insertSubview:self.rearViewController2.view belowSubview:self.rearNavigationController.view];
}

When sliding frontViewController, I am seeing rearViewController1 underneath.However, if I slide rearViewController1, I would like to see rearViewController2. However, rearViewController2 is not shown at all (instead of it, I am seeing a white blank view controller )
Question : what have I missed in the middle and can we insert a sub-view below another ? sub-view
Please advice me on this issue. All comments are welcomed.


text:
Q: UIViewController xib file containing a collectionview with a custom cell I have a xib file containing an UIViewController called FullScreenGalleryVC. It contains a UICollectionView that contains a custom UICollectionViewCell, which identifier is fullscreen_cell.
When I want to create a new FullScreenGalleryVC, I call FullscreenGalleryVC.display(from: self).
Here's the func:
class func display(from sourcevc:UIViewController){
    let vc=UINib(nibName: "FullscreenGalleryVC", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as! FullscreenGalleryVC
    sourcevc.present(vc, animated: true, completion: nil)
}

I get this error:

could not dequeue a view of kind: UICollectionElementKindCell with
  identifier fullscreen_cell - must register a nib or a class for the
  identifier or connect a prototype cell in a storyboard

It works fine if I put the custom cell in another xib file and call register(nibClass, forCellWithReuseIdentifier: cellId).
It works fine if I don't put this FullScreenGalleryVC class in a separate xib file (and keep it in my main storyboard).

But I use this class from both the app and an action extension so that's why I'd like to use a common file instead of duplicating everything. Is there a way to do that or do I imperatively have to put the custom cell in a different xib file to make it work?

A: If you a xib file for FullScreenGalleryVC controller then you should use register(nibClass, forCellWithReuseIdentifier: cellId) to tell the collection view how to create a new cell of the given type.
let cellNib = UINib(nibName: "FullScreenGalleryCell", bundle: .main)
collectionView.register(cellNib, forCellWithReuseIdentifier: "fullscreen_cell")

If you use a storyboard, then it's already known to the collection view with the specified cellId.
In my opinion, you can use a storyboard for FullScreenGalleryVC and reuse the same for other classes.
Present a viewController from a specific storyboard like,
let storyboard = UIStoryboard(name: "YourStoryboardName", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "storyboardId")
self.present(controller, animated: true, completion: nil)


text:
Q: Is indistinguishable probabilities still indistinguishable even if randomness is allowed? We say that a function $f:\mathbb N\to\mathbb R$ is negligible if for all positive integer $k$, there is $N\in\mathbb N$ such that for all $n\geq N$,
\begin{equation}
    |f(n)| < \frac{1}{n^k}\text{.}
\end{equation}
Let $X$ and $Y$ be measurable spaces. For each $n\in\mathbb N$, let $P_n$ and $Q_n$ be probabilities on $X$, and let $R_n$ be a probability on $Y$. Assume that for all measurable set $E\subseteq X$, the function
\begin{equation}
    n\mapsto |P_n(E) - Q_n(E)|
\end{equation}
is negligible. Then is it true that for all measurable set $F\subseteq X\times Y$, the function
\begin{equation}
    n\mapsto |(P_n\times R_n)(F) - (Q_n\times R_n)(F)|
\end{equation}
is negligible?
Here is my attempt. Let $\mathcal B$ be the collection of all measurable subset of $X\times Y$ making $n\mapsto |(P_n\times R_n)(F)-(Q_n\times R_n)(F)|$ negligible. I proved that $\mathcal B$ contains all finite disjoint union of measurable rectangles. Now, by the monotone class theorem, it suffices to prove that $\mathcal B$ is a monotone class. But I could not prove this.


text:
Q: Compiler error when using the new @bind:after feature in Blazor .NET7 Been looking at the new binding features introduced for Blazor in .NET7. This Microsoft article explains how to use @bind:after (see the paragraph starting "To execute asynchronous logic after binding...")
I copied the code almost verbatim, replacing the call to SearchService with a Console.WriteLine...
<input @bind="searchText" @bind:after="PerformSearch" />

@code {
  private string? searchText;

  private async Task PerformSearch() =>
    Console.WriteLine($"Search: {searchText}");
}

However, this gives a compiler error... "Argument 3: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback' to 'System.Action<string?>'"
This is in a brand new Blazor server project targeting .NET7 in VS Community 2022.
Anyone any idea why I'm getting this error, and how I use this new feature?

A: It's a known issue that should get fixed soon.
See this github issue for details.


text:
Q: pandas index rename using dictionary Is there a version of this but using a dictionary instead of a list? Following the example in the link what I want to do is idx.rename({'kind':'species'}).
If it matters, this is how my data frame looks like:
                                                            k_CFD (%)  k_CFD (%) error
run_name                                           CFD
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      68.529412         9.576598
                                                   MCP-PMT  72.058824        21.711526
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      77.647059        14.783042
                                                   MCP-PMT  64.411765        20.477804
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      73.235294         6.840427
                                                   MCP-PMT  74.117647        14.379625
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      50.294118         9.369614
                                                   MCP-PMT  64.117647        15.786002
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      56.176471        11.285471
                                                   MCP-PMT  46.764706        15.709597
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      62.058824        16.288946
                                                   MCP-PMT  68.823529        18.383904
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      78.235294         8.693637
                                                   MCP-PMT  65.294118        18.947342
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      85.588235         7.463518
                                                   MCP-PMT  81.470588        14.591893
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      30.882353         5.703612
                                                   MCP-PMT  48.529412        15.595717
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      62.647059        12.137801
                                                   MCP-PMT  56.470588        19.829936
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      71.764706        11.926692
                                                   MCP-PMT  63.823529        22.158480
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      87.058824         4.624973
                                                   MCP-PMT  71.764706        22.626157
20230104124758_TI107_HDO6034-MS_WithInterpolati... DUT      75.588235         7.859052
                                                   MCP-PMT  72.058824        14.094790

Note that I want a solution independent of the ordering of the columns in the index, that's why I want to use a dictionary and not a list. I want to rename the index column 'CFD' to something else, independently of its position.

A: Use DataFrame.rename_axis:
df = pd.DataFrame(columns=['a'], index=pd.MultiIndex.from_product([['MALE','FEMALE'],
                              ['NAME','AGE']],
                             names=['kind','new']))

print (df)
               a
kind   new
MALE   NAME  NaN
       AGE   NaN
FEMALE NAME  NaN
       AGE   NaN

df = df.rename_axis(index={'kind':'species'})
print (df)
                a
species new
MALE    NAME  NaN
        AGE   NaN
FEMALE  NAME  NaN
        AGE   NaN

A: You approach should work, make sure to assign the output or use inplace=True:
df.index = df.index.rename({'kind': 'species'})

Example input:
           0
kind type
1    A     0
2    B     1

Output:
              0
species type
1       A     0
2       B     1


text:
Q: resize "shrink" an .img file from the command line Shrink an .img file from the command line
I need to be able to shrink the .img for use on other drives.  I can do this using gparted, but do not always have a GUI, so I want to translate the gparted step below into parted
to be verbose, here is my whole proceedure using gparted
insert sd card
$ lsblk

copy image
$ sudo dd bs=4M if=/dev/mmcblk0 of=rp4-ubuntu-server-22.04-fresh.img status=progress oflag=sync

create a loopback device
$ sudo losetup -f
$ sudo losetup /dev/loop0 /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img
$ sudo partprobe /dev/loop0

resize the partition (This is where I need help!)
$ sudo gparted /dev/loop0

resize --> drag to desired size --> apply --> exit gparted
done with the loopback device
$ sudo losetup -d /dev/loop0

find last sector
$ fdisk -l /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img

   Disk /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img: 59.63 GiB, 64021856256 bytes,
125042688 sectors
   Units: sectors of 1 * 512 = 512 bytes
   Sector size (logical/physical): 512 bytes / 512 bytes
   I/O size (minimum/optimal): 512 bytes / 512 bytes
   Disklabel type: dos
   Disk identifier: 0x1b140081

   Device                                           Boot  Start     End Sectors  Size Id Type
   /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img1 *      2048  526335  524288  256M
c W95 FAT32
   /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img2      526336 7739391 7213056  3.4G 83 Linux

resize the .img
$ sudo truncate --size=$[(7739391+1)*512] /home/phil/dl/rp4-ubuntu-server-22.04-fresh.img

Can you show me how to accomplish the gparted step using cli parted?


text:
Q: Update ObservableCollection UI I have a ObservableCollection binding in xaml and I can't update UI when I use "Add" element, the element is added to the list but doesn't appear on UI.
If I do new ObservableCollection with the elements the UI is updated, but I want to use Add and update the view.
public ObservableCollection<ResourcePreviewViewViewModel> AttatchResource
    {
        get { return attatchResource; }
        set
        {
            attatchResource = value;
            OnPropertyChanged("AttatchResource");
        }
    }

I added a event to when collection is changed:
public void ContentCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        OnPropertyChanged("AttatchResource");
    }

To add the elements to list:
AttatchResource.Add(new ResourcePreviewViewViewModel());

My UI binding:
<suave:DynamicStackLayout ItemsSource="{Binding AttatchResource}"
                          HorizontalOptions="Fill"
                          Orientation="Horizontal">
<suave:DynamicStackLayout.ItemTemplate>
    <DataTemplate>
      <localcontrol:ResourcePreviewView />
    </DataTemplate>
</suave:DynamicStackLayout.ItemTemplate>

I don't know what to try more, what can I do to update the UI ?


text:
Q: replace element in 1d numpy array with numpy array Say I have a numpy array x = np.array([0, 1, 2]), is there a built-in function in python so that I convert element to corresponding array?
e.g.
I want to convert 0 in x to [1, 0, 0], 1 to [0, 1, 0], 2 to [0, 0, 1], and the expected output is np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]).
I tried x[x == 0] = np.array([1, 0, 0]) but it doesn't work.

A: Demo:
In [38]: from sklearn.preprocessing import OneHotEncoder

In [39]: ohe = OneHotEncoder()

# modern versions of SKLearn methods don't like 1D arrays
# they expect 2D arrays, so let's make it happy ;-)
In [40]: res = ohe.fit_transform(x[:, None])

In [41]: res.A
Out[41]:
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])

In [42]: res
Out[42]:
<3x3 sparse matrix of type '<class 'numpy.float64'>'
        with 3 stored elements in Compressed Sparse Row format>


text:
Q: Why all the records are not being copied from CSV to SQL table in a SSIS package I am trying to copy data from a flat file to a SQL table using SSIS.
I have a Data Flow Task where I have created a Flat File Source pointing to the csv file and an OLE DB Destination pointing to the table I want the data in.
The problem I am facing is when I run the package, I get only 2621 rows copied to the SQL destination table, where I have about 1,70,000 records in the csv. Not sure why this is happening.
Thanks in advance.

A: This could be a number of things. This is what comes to mind:

*

*The connection string to your flat file is overwritten by a variable expression or a package configuration. Check SSIS -> Package configurations or the Expressions properties on your connection manager.

*The DataRowsToSkip property on your flat file connection manager is set to a value.

*The meta data definition of your flat file is incorrectly configured in your connection manager. See properties such as Format, Row delimiter, Column delimiter, etc. Use the preview function to see the output.

*The error output on your flat file source is set to Ignore failure, meaning that lines which SSIS cannot process (due to, e.g., incompatible data types) are ignored without warning.


text:
Q: Finding the equivalence class of a relation |a| = |b| For the following relation $R$ on the set $X$ determine whether it is $(i)$ reflexive, $(ii)$ symmetric and $(iii)$ transitive. Give proofs or counter examples. In the case where $R$ is an equivalence relation, describe the equivalence classes of $R$.
$X=\mathbb C,\; a\;R\;b\iff |a|=|b|$
$(i)$ The relation is reflexive since $|a|=|a|$ is true
$(ii)$ The relation is symmetric as if $|a|=|b|$ then $|b|=|a|$
$(iii)$ The relation is transitive if $|a|=|b|$ and $|b|=|c|$ then it follows that $|a|=|c|$
And this is as far as I get. I am struggling when it comes to identifying an equivalence class for this relation. I honestly don't even think I'd know where to begin for this. A nudge in the right direction would be greatly appreciated.

A: If I've understood correctly, you need to characterize the equivalence classes for the above equivalence relation on the set $X=\mathbb{C}$.
The definition of complex absolute value is very geometric. Given some complex number $a+bi$, $\lvert a+bi\rvert=\sqrt{a^2+b^2}$. It follows from here that an equivalence class on $\mathbb{C}$ with the relation of absolute value is actually a circle of radius corresponding to the absolute value of elements in the class, centered at the origin.
So, multiple different classes form a collection of concentric circles about the origin. Can you see why?

A: What number(s) is $-3 + 4i$ equivalent to? What number(s) is $4.68$ equivalent to? What number(s) is $0$ equivalent to?

A: Hint:
You can find the answer if you think to complex number $a$ in polar form $a=|a| e^{i\theta}$. than you have an equivalence class for any value of $|a| \in \mathbb{R}$.


text:
Q: PayPal Adaptive Payments: two payments from one sender in two browser tabs I use PayPal Adaptive Payments (parallel) on my website and I've encountered a strange problem with two payments in two different browser tabs from the same sender. The similar question was asked before, but nobody answered there.
The scenario which reproduces the problem

*

*The user opens the first browser tab of the website and starts a payment process to the first seller.

*PayPal's lightbox with Login button appears.

*The user opens the second browser tab of the website and starts a payment process to the second seller.

*Again, PyaPal's lightbox with Login button appears.

*The user returns to the first browser tab and login to PayPal.

*After login to PayPal in the first browser tab the user sees payment details to the second seller.

*After login to PayPal in the second browser tab the user sees payment details to the second seller.
It seems that PayPal Adaptive Payments support only one transaction from one sender.
How it works
The website works with Ruby on Rails and I use paypal_adaptive gem for payments with PayPal. The payment flow is quite simple:

*

*The user clicks on Buy button on the website. The client makes AJAX request which handled by payment controller in Ruby on Rails.

*In the controller the app makes Pay request to PayPal API using paypal_adaptive gem and receives a PayKey (see the code below).

*The server responds to the client with the PayKey and the client uses it in PayPal form to start payment process through PayPal's lightbox (see the code below).

That's it. After that I do not control anything (the payment process goes through PayPal's external webpage).
Additional notes

*

*I'm sure that the data for Pay request is different on the server side in the test scenario listed above.

*I've tried different PayPal's dialog options besides PayPal's lightbox: mini-browser and popup. These options doesn't affect on this bug and it is still reproducable.

The client code
<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>

<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" class="paypal-hidden-form" target="PPDGFrame">
  <button id="paypal-submit"></button>
  <input id="type" type="hidden" name="expType" value="light">
  <!-- Insert PayKey here and click on the form's submit button using jQuery after server's response. -->
  <input id="paypal-key" type="hidden" name="paykey" value="">
</form>

<!-- Paypal -->
<script type="text/javascript" charset="utf-8">
    var dgFlow = new PAYPAL.apps.DGFlow({ trigger: "paypal-submit", expType: "light" });
    function MyEmbeddedFlow(embeddedFlow) {
        this.embeddedPPObj = embeddedFlow;
        this.paymentSuccess = function(paymentStatus) {
            this.embeddedPPObj.closeFlow();
            // More UI code here...
        };
        this.paymentCanceled = function() {
            this.embeddedPPObj.closeFlow();
            // More UI code here...
        };
    }
    var myEmbeddedPaymentFlow = new MyEmbeddedFlow(dgFlow);
</script>

The server code
# Make a Pay request to PayPal API.
paypal_payment_thread = Thread.new do
  # Some preparation code goes here...

  pay_request = PaypalAdaptive::Request.new
  process_guid = SecureRandom.uuid

  # Construct Pay API request data.
  data = {
    :returnUrl => "#{PAYPAL_RETURN_URL}?process_guid=#{process_guid}",
    :cancelUrl => "#{PAYPAL_CANCEL_URL}?process_guid=#{process_guid}",
    :requestEnvelope => {
      :errorLanguage => "en_US"
    },
    :currencyCode => "USD",
    :receiverList => {
      :receiver => [{
        # seller_paypal value is different for two payments.
        # But in fact we do the last payment for both payments.
        :email => seller_paypal,
        :amount => ORDER_SELLER_AMOUNT,
        :paymentType => "DIGITALGOODS"
      }, {
        :email => PAYPAL_MARKETPLACE_EMAIL,
        :amount => ORDER_MARKETPLACE_AMOUNT,
        :paymentType => "DIGITALGOODS"
      }]
    },
    :actionType => "PAY",
    :ipnNotificationUrl => PAYPAL_NOTIFY_URL,
    :reverseAllParallelPaymentsOnError => "true",
    :trackingId => process_guid
  }

  # Make a Pay API request.
  pay_response = pay_request.pay(data)

  if pay_response.success?
    # Everything is ok. Update database here...
  else
    raise Exceptions::PaypalPaymentError
  end
end

I've removed some unimportant code just to be clear, how it really works.
Thanks in advance for the help!

A: Looks like it is by design. I've tried the same test here on the website of one of PayPal's employees and it is reproducible there.
PayPal's support answered me that the problem in using Lightbox. However I've tried Mini-Browser and Popup options as I described in my post without no effect.
Also, PayPal's support answered me that this is by design and adviced me to contact with Technical Support. Maybe it will be useful for someone else.

Hi Michael,   Thanks, yes I was able to reproduce it as well. However
  it's important to understand that PayPal is not made for handling 2
  payment flows at the same time.   If you want to get further on that,
  you can contact our Technical Support : https://ppmts.custhelp.com/
  They have other tools to debug and may be able to give you a better
  understanding of the technical problem.

Finally I've blocked simultaneous payments using a special flag in HTML5 Local Storage and dgFlow.isOpen() method of PAYPAL.apps.DGFlow object to detect PayPal window. On window close I reset this flag using onunload and onbeforeunload events of window.
I close this question. Thanks.


text:
Q: How to use switch statement within a reduce method? I want to resolve a problem (from https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register/).
I ended up with a switch statement within a reduce method but it doesn't work like I explain it in the code.
I just want to know why that doesn't work, not if there are other better ways to resolve this entire problem.
function checkCashRegister(price, cash, cid) {
// price refer to a purchase price, cash to the money given by a client, cid to the cash-in-drawer.

// With the method below, I want to convert the cid nested array into a single value in dollar.
  let register = cid.reduce( (sum, curr) => {
    switch (curr[0]) {
      case "PENNY" :
        sum += curr[1] * 0.01;
        break;
      // I would continue with case "NICKEL" etc. but the switch statement doesn't work.
      default: console.log("Unexpected currency unit");
    }
    },0)

    console.log(register);
}

checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

I expect the output 0.0101 but the actual output of "console.log(register)" is:
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit
    Unexpected currency unit

A: Array.reduce requires you to return a value. Your switch statment is fine. I added return sum; to the end of your reduce function.
function checkCashRegister(price, cash, cid) {
// price refer to a purchase price, cash to the money given by a client, cid to the cash-in-drawer.

// With the method below, I want to convert the cid nested array into a single value in dollar.
  let register = cid.reduce( (sum, curr) => {
    switch (curr[0]) {
      case "PENNY" :
        sum += curr[1] * 0.01;
        break;
      // I would continue with case "NICKEL" etc. but the switch statement doesn't work.
      default: console.log("Unexpected currency unit");
    }
    return sum;
  },0)

  console.log(register);
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
You do have some work to do in order to answer the question you linked, but I'm sure you'll get there. Good luck.


text:
Q: ORA-00934: group function is not allowed here I have written a stored procedure that I was expecting to add two count values into a collection, with the below code:
PROCEDURE generate(code_in in VARCHAR2
                 , value_1 out NUMBER
                 , value_2 out NUMBER) is
BEGIN
    SELECT
        COUNT(CASE WHEN type = 'A' THEN 1 ELSE NULL END) INTO value_1
        , COUNT(CASE WHEN type IN ('B','D') THEN 1 ELSE NULL END) INTO value_2
    FROM table
    WHERE code = code_in;
END generate;

But when running the code I get the following error:

ORA-00934: group function is not allowed here

If I remove the second COUNT the stored procedure compiles just fine, but when I add this second line I get the error.
Can anyone help explain why this is happening? Please note that my experience with Oracle is minimal.

A: into is a single clause that may receive multiple variables, not a clause you append to each select item:
PROCEDURE generate(code_in in VARCHAR2
                 , value_1 out NUMBER
                 , value_2 out NUMBER) is
BEGIN
    SELECT
        COUNT(CASE WHEN type = 'A' THEN 1 ELSE NULL END),
        COUNT(CASE WHEN type IN ('B','D') THEN 1 ELSE NULL END)
    INTO value_1, value_2 -- into clause with both variables
    FROM table
    WHERE code = code_in;
END generate;


text:
Q: Twitter-Bootstrap drop down log in closes when text areas are clicked Hi I'm designing a website with JQuery for the first time. I am using Twitter-Bootstrap for a dropdown login box and I can't get the JQuery script right to make the box stay open when you click on the text area. I've tried everything and I am familiar with java script. I placed the following:

at the top of the header as well as before the closing body bracket, and the following in front of the closing body tag as well...

here is the HTML

Phone: 703-518-4325

Email: info@urbanare.com

Log in

                            <form action="[YOUR ACTION]" method="post" accept-charset="UTF-8">
                            email: <input id="user_username" style="margin-bottom: 15px;" type="text" name="email" size="30" />
                            password: <input id="user_password" style="margin-bottom: 15px;" type="password" name="password" size="30" />
                            <input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="user[remember_me]" value="1" />
                             Remember me

                            <input class="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In" />
                            </form>

 Register

and the CSS
#top-bar {
  width: 100%;
  min-height: 35px;
  max-height: 35px;
  font-size: 13px;
  line-height: 35px;
  background-color: #f1f3f6;
  position: relative;
  z-index: 1020;
}

#top-buttons{
line-height:10px !important;
}

#top-bar a {
  color: #74777c;
}

#top-bar a:hover,
#top-bar a:focus {
  color: #f58220;
  text-decoration: none;
}

#dashboard-top-bar {
  width: 100%;
  min-height: 45px;
  font-size: 13px;
  line-height: 35px;
  background-color: #f1f3f6;
  position: relative;
  z-index: 1020;
}

#dashboard-top-bar a {
  color: #74777c;
}

#dashboard-top-bar a:hover,
#dashboard-top-bar a:focus {
  color: #f58220;
  text-decoration: none;
}
#top-info,
#top-buttons {
  display: inline-block;
  list-style: none;
  margin: 0;
  padding: 0;
}
#top-info,
#top-buttons li {
 display: inline-block;
  margin-left: 25px;
}

#top-buttons {
  float: right;
}

#top-buttons .divider {
  position: relative;
  border-left: 1px solid #74777c;
  width: 1px;
  height: 22px;
  overflow: hidden;
  margin-bottom: -6px;
 }

A: You don't need any jquery to do this. include bootstrap.js and bootstrap.css then
 Try this code.
Ex:- JS FIDDLE

Phone: 703-518-4325

Email: info@urbanare.com

                         Log in

                        <form action="[YOUR ACTION]" method="post" accept-charset="UTF-8">
                            email: <input id="user_username" style="margin-bottom: 15px;" type="text" name="email" size="30" />
                            password: <input id="user_password" style="margin-bottom: 15px;" type="password" name="password" size="30" />
                            <input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="user[remember_me]" value="1" />
                             Remember me
                            <input class="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In" />
                        </form>

 Register


text:
Q: Why does Passport retry the authentication when it fails to connect? I have a Node.js & Express app, using Passport and passport-ldapauth for LDAP authentication.
Everything works OK... unless it fails connecting to the LDAP server (it may be offline, or the IP address be wrong, etc.). In that case, passport.authenticate is somehow executed twice (I just can't figure out why), and as a result, I get Error: Can't set headers after they are sent.
These are the relevant parts of my server.js and routes.js:
// Import modules
var express      = require('express');
var session      = require('express-session');
var passport     = require('passport');
var passportLdap = require('passport-ldapauth');

// Configure Express, session suppport, and Passport
var app = express();
app.use(session({ resave: false, saveUninitialized: false, secret: 'foo' }));
passport.use('ldap', new passportLdap({server: { /* LDAP settings */ }}));
app.use(passport.initialize());
app.use(passport.session());

// Routings
app.get('/login', function(req, res) { res.render('loginForm.ejs'); });
app.post('/login', function(req, res) {
    passport.authenticate('ldap', {session: true}, function(err, user, info) {
        if (err || !user) {
            console.log(err ? 'ERROR' : 'CREDENTIALS');
            res.status(403).render('loginForm.ejs', {message: err || 'Wrong credentials!'});
        } else {
            console.log('SUCCESS');
            res.redirect('/home');
        }
    })(req, res);
});

If the authentication is successful, the console only shows SUCCESS.
If the user enters either a wrong username or password, it shows CREDENTIALS, and the login form is loaded again, displaying the "Wrong credentials!" message. No errors appear on the console.
However, if the LDAP server is down, I get ERROR twice on the console. (Why?!) Then obviously, as it's doing a second res.render with the same response object, I get the Can't set headers after they are sent error. And since it's the second attempt that fails, the user still gets the form login with the proper error message (which was rendered on the first attempt).
If I change my if (err) block to do next(err) instead of res.render()... I don't get the headers problem, but still, the exception with the LDAP (for example "Error: getaddrinfo ENOTFOUND") is shown twice on the console, as if Passport was retrying after the first attempt.
Also, I have noticed there is a handleErrorsAsFailures option in ldapauth. If I enable it, then it shows CREDENTIALS twice on the console for connection problems, and only once if I actually input wrong credentials.
What could be causing this issue?

A: As a (hopefully temporal?) workaround, I've changed my code to this:
if (err || !user) {
    if (!res.headersSent) { // <---------- CHECK TO PREVENT THE ISSUE ---------
        console.log(err ? 'ERROR' : 'CREDENTIALS');
        res.status(403).render('loginForm.ejs', {message: err || 'Wrong credentials!'});
    }
} else // ...

Which prevents the second render attempt, and avoids the Can't set headers after they are sent error.
I still have no clue of what's causing this behaviour or how to fix it, though...

A: My workaround was to wrap all the code in the route with an if-else statement:
    if(res.headersSent) {
       return;
    } else {
      *//the rest of the code goes here*
    }


text:
Q: Applied PDE's book suggestion I am searching for a book on applied PDEs which do not focus on how to solve them, but instead different areas where they appear and what can we do with them. Maybe a book in which each chapter shows applications of pdes in areas like economics, finance, physics, biology, social sciences, etc... .I also would be nice if it contains some numerical ways to use them. Can you suggest one book like that to me?

A: It depends on which level you are aiming for. For undergraduate level, the book "Partial Differential Equations An Introduction" by Walter A. Strauss is decent (but it does not contain too much material on numerical PDE methods). For graduate level PDE, the classical book "Partial Equation Equations" by L.C.Evans seems quite popular.


text:
Q: Invoke Mac Kernel Panic? So i am lookin for some source code to crash the mac kernel. I found crashme for debain linux but that does not work for the mac kernel. So i was wondering if anyone knows where i can find a command-line utility or some source code to invoke the mac kernel panic? This would be a huge help, thanks.

A: I recently updated crashme to work on Mac OS X Lion. You will need to download the source code from http://crashme.codeplex.com/ and compile it using Xcode command line tools. More details are in a answer to question 5085136. But note that crashme hasn't found any immediate kernel panics on the Mac yet. However, after running crashme on the native MacBook Pro, and running it in VirtualBox VM's on the same machine, one in an x86 PC-BSD and another in an x64 Centos, my Lion Kernel became unhappy enough that it threw a kernel panic a few minutes later as I was editing a file using the native Emacs. So crashme may have stumbled upon a kernel bug.

A: Apple has a tech note about how to do this.
The short way to do it is with this command, sudo dtrace -w -n "BEGIN{ panic();}", run from the terminal.
Update 2020: As noted by Wei Shen in the comments, you'll need to disable SIP to make this work in modern versons of macOS.

A: Go in terminal and type "killall kernel_task" it should force the computer into a panic without downloading any software. Just make sure you have everything saved before you try :D

A: although this requires a password it works every time
sudo halt


text:
Q: O formulário não envia dados ao banco Criei um formulário de cadastro de tópicos de discussão.
Tópicos de discussão estão linkados a uma categoria através de chave estrangeira.
Então, se clico em uma categoria aparece uma listagem de tópicos. O que quero é poder cadastrar um tópico ligado a uma categoria com um formulário na mesma página.
O problema ocorre quando submeto os dados que cadastro no formulário. Eles não são inseridos no banco.
Abaixo está o código:
<?php

include_once('conexao/conexao.php');

    if(($_SERVER["REQUEST_METHOD"] == "POST") and ($_POST["inserir"])){

        $titulo = $_POST['titulo'];
        $conteudo = $_POST['conteudo'];
        $data_criacao = date("Y/m/d h:i:s");
        $filtro_topico = $_GET['ID'];

        $stmt = $conecta->prepare("INSERT INTO discussao (titulo, conteudo, id_situacao, id_topico, id_usuario) VALUES ('$titulo', '$conteudo',  1, '$filtro_topico', 3)");
        $stmt->execute();
        header('location: index.php');
}
 ?>
<!DOCTYPE html>

    <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
            <link rel="stylesheet" href="css/style.css">

     <?php
                include('templates/header.html.php');
        ?>
                <?php

                ?>

                        Novo Tópico

                        <form class="form_discussion" action="<?php echo($_SERVER["PHP_SELF"]);?>" method="post" style="margin-top: 0px; margin-left: 260px;">

Criar Tópico de Discussão

                            Título:
                                <input type="text" name="titulo">

                            Conteúdo:

                                <textarea name="conteudo"></textarea>

                            <input type="submit" value="Criar" name="inserir">
                            <input type="submit" value="Visualizar">
                            <input type="submit" value="Limpar">
                        </form>

                    <?php
                        $filtro_pagina = $_GET["ID"];
                        $query_topico = "SELECT titulo FROM topico WHERE id = " .$filtro_pagina;
                        $rs_topico = $conecta->query($query_topico);
                        while($lista_topico = $rs_topico->fetch_array()){

                    ?>

Tópicos de <?php echo $lista_topico['titulo']; ?>

                    <?php
                        }
                        $filtro_topico = $lista_topico['id'];
                        $query_discussao = "SELECT DISTINCT discussao.id AS id, discussao.titulo AS titulo FROM discussao, topico WHERE discussao.id_topico = " .$filtro_pagina;
                        $rs_discussao = $conecta->query($query_discussao) or trigger_error($conecta->error."[$query_discussao]");
                        while($lista_discussao = $rs_discussao->fetch_assoc()){
                    ?>

<a href="discussao-respostas.php?ID=<?=$lista_discussao['id'];?>"><?php echo $lista_discussao['titulo']; ?>

34 respostas

PDO MVC

12:34

por Web-user

                    <?php

                        }
                    ?>

            <?php
                include('templates/footer.html.php');
         ?>

Os erros constam na figura abaixo:

Não identifica o ID, que é o id da categoria que linkei para cadastrar um tópico.
O ID não é tratado pelo formulário. Ele é a chave primária da categoria, como a da figura abaixo:

Ele consta na url:
http://localhost/forum-ti-oficial-1/lista-discussao.php?ID=1

A: O erro é bem descritivo, a variável $_GET['ID'] não está definida.
Solução:
if(isset($_GET['ID']))
    $filtro_topico = $_GET['ID'];
else
    $filtro_topico = ID_PADRAO;//ID_PADRAO =  valor padrao

Além disto, a função prepare não está retornando um objeto, verifique se o erro é causado pelo problema descrito acima, se não for, verifique dentro do seu arquivo de conexão com o banco.


text:
Q: AS3 - At exactly 23 empty alpha channels, images below stop drawing I noticed, while trying to draw large numbers of circles, that occasionally, there would be some kind of visual bug where some circles wouldn't draw properly. Well, I narrowed it down, and have noticed that if there is 23 or more objects with 00 for an alpha value on the same spot, then the objects below don't draw. It appears to be on a pixel-by-pixel basis, since parts of the image still draw.
Originally, this problem was noticed with a class that inherited Sprite. It was confirmed to also be a problem with Sprites, and now Bitmaps, too. If anyone can find a lower-level class than Bitmap which doesn't have this problem, please speak up so we can try to find the origin of the problem.
I prepared a small test class that demonstrates what I mean. You can change the integer value at line 20 in order to see the three tests I came up with to clearly show the problem.
Is there any kind of workaround, or is this just a limit that I have to work with? Has anyone experienced this before? Is it possible I'm doing something wrong, despite the bare-bones implementation?
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.Bitmap;
    import flash.display.BitmapData;

    public class Main extends Sprite
    {
        public function Main():void
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            Test(3);
        }

        private function Test(testInt:int):void {
            if(testInt==1){
                addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000)));
                for (var i:int = 0; i < 22; i++) {
                    addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000)));
                }
            }
            if(testInt==2){
                addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000)));
                for (var j:int = 0; j < 23; j++) {
                    addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000)));
                }
            }
            if(testInt==3){
                addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000)));
                for (var k:int = 0; k < 22; k++) {
                    addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000)));
                }
                var M:Bitmap = new Bitmap(new BitmapData(100, 100, true, 0x00000000));
                M.x += 50;
                M.y += 50;
                addChild(M);
            }
        }
    }
}

A: Im not sure why u add Bitmap's as childs. I think u should Draw all "shapes" on a single BitmapData, using draw(). You can simply draw shapes, and then draw them to BitmapData. I can be more specific if u need more explanation.

A: set bmp.cacheAsBitmap= ture to each Bitmap

A: Aside from drawing to a single BitmapData, an additional method to attempt might be to place your Bitmaps into a single Sprite. Set cacheAsBitmap=true for your Sprite container.


text:
Q: MVC4 : export qrcode image to excel sheet I want to export excel sheet with qr-code images in my table.  The qrcode saved with its serial number and i generate it with google apis.  I do it in controller that return MvcHtmlString and i use it in my view like @Html.QRCode(item.SerialNumber, 80, 0)
and it works in my view well.
my Controller
  public static MvcHtmlString QRCode(this HtmlHelper htmlHelper, string data, int size = 80, int margin = 4, QRCodeErrorCorrectionLevel errorCorrectionLevel = QRCodeErrorCorrectionLevel.Low, object htmlAttributes = null)
{
    if (data == null)
        throw new ArgumentNullException("data");
    if (size < 1)
        throw new ArgumentOutOfRangeException("size", size, "Must be greater than zero.");
    if (margin < 0)
        throw new ArgumentOutOfRangeException("margin", margin, "Must be greater than or equal to zero.");
    if (!Enum.IsDefined(typeof(QRCodeErrorCorrectionLevel), errorCorrectionLevel))
        throw new InvalidEnumArgumentException("errorCorrectionLevel", (int)errorCorrectionLevel, typeof(QRCodeErrorCorrectionLevel));

    var url = string.Format("http://chart.apis.google.com/chart?cht=qr&chld={2}|{3}&chs={0}x{0}&chl={1}", size, HttpUtility.UrlEncode(data), errorCorrectionLevel.ToString()[0], margin);

    var tag = new TagBuilder("img");
    if (htmlAttributes != null)
        tag.MergeAttributes(new RouteValueDictionary(htmlAttributes));
    tag.Attributes.Add("src", url);
    tag.Attributes.Add("width", size.ToString());
    tag.Attributes.Add("height", size.ToString());

    return new MvcHtmlString(tag.ToString(TagRenderMode.SelfClosing));
}

To export excel sheet i do the following :

*

*create a grid

*give it the Data Source of the desired data .

the qrcode data that i give to the grid view is
data.QRcode = atm.SerialNumber;
it actually get the string of qrcode how to get its qrcode image of its code like in my view that i use
@Html.QRCode(item.SerialNumber, 80, 0)
Note : i need any solution that can get the qrcode image and other data external to print it.
Update : I reached to the source of the image then if any solution for how to display image in excel sheet according to the source of the image .
detailed steps :
1- get the link of the image like with google apis
System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();

            image.ImageUrl = url;
            image.Width = 80;
            image.Height = 80;
            atm2.QRcode = image;

but this column doesn't appear in the exported excel sheet
Thanks for any help .


text:
Q: Change fragment by button click I have to create a sort of view that consist in few fragment that were selected by a "next button". I have a fragment called FragmentSearch that contain a button, when I click the button, I want to go to the next fragment, the FragmentBoxOffice but I don't know how I can do this.
I tried to do with inflater.inflate in the setOnClickListener of the button but this seems not working. Also I tried to create all the things in a single fragment, using the setVisibity to do a sort of change of the view, but also this not working.
public class FragmentSearch extends Fragment implements SortListener{

...
@Override
public View onCreateView(  LayoutInflater inflater,   ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(fragment_search, container, false);

    Button but =(Button) view.findViewById(R.id.button);

    but.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        myView = inflater.inflate(fragment_box_office, container, false);

        }
    });
    return inflater.inflate(R.layout.fragment_search, container, false);
}

The XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/search"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.altervista.ilpixelmatto.superfilm.Fragment.FragmentSearch">

<RelativeLayout
    android:id="@+id/frame1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="visible">

<TextView
        android:id="@+id/text11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="frame1"
        android:paddingLeft="50dp"
        android:textColor="@color/Black" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:layout_gravity="center_horizontal" />

    <Button
        android:id="@+id/button"
        android:layout_below="@id/text11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="frame1" />
</RelativeLayout>

<!-- TODO: Update blank fragment layout -->

</LinearLayout>

How to do this?

A: The only proper way to show a fragment is using FragmentManager and FragmentTransaction. Replace your onClick() with:
public void onClick(View v) {
    FragmentManager fm = getFragmentManager();
    FragmentBoxOffice f = (FragmentBoxOffice) fm.findFragmentByTag(FragmentBoxOffice.TAG);
    if (f == null) {
      f = new FragmentBoxOffice();
      fm.beginTransaction()
        .replace(R.id.fragment_container, f, FragmentBoxOffice.TAG)
        //.addToBackStack(null);  // uncomment this line if you want to be able to return to the prev. fragment with "back" button
        .commit();
    }
}

Then in your activity layout you need a placeholder ViewGroup called fragment_container that will be a parent for the fragment layout:

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />

Both fragments should have their own layouts which are placed into the fragment_container in the activity layout.


text: Q: What do you call when you clasp your hands to propel someone up a wall? I'm sure it had a name. It's when you clasp your hands (palms up) so the other person can stand on them and go up a wall (or a tree). Any suggestions?


text:
Q: Image captions in Yii framework How can I get this in Yii framework using Chtml::link

Movie 1

When I did this,
<?php $imghtml=CHtml::image('../../images/1.jpg');
echo CHtml::link($imghtml, array('moviepage/index'),array('class'=>'search-movie', 'title'=>'Movie 1'));?>

I only got

A: You need to include the markup for the caption when you generate the link:
<?php
    $imghtml=CHtml::image('../../images/1.jpg');
    $caption = CHtml::tag('p', array(), 'Movie 1');
    echo CHtml::link("{$imghtml}{$caption}", array('moviepage/index'), array('class'=>'search-movie', 'title'=>'Movie 1'));
?>

A: Like so:
<?php $imghtml=CHtml::image('../../images/1.jpg');
echo CHtml::link("$imghtml
Move 1
", array('moviepage/index'),array('class'=>'search-movie', 'title'=>'Movie 1'));?>


text:
Q: Measuring load - %CPU in top is different than %us When I run TOP on a remote server, I see a very small system utilization (3.8%us).
However, for the actual process I am seeing 29.6% of the CPU.
Since this server has 8 CPU cores, is the %CPU the utilization of only 1 CPU, while the us up top is over the 8 CPUs?
When I divide 29.6 by 8, I get 3.7 which looks to validate my guess.
So questions:

*

*The low utilization I am seeing is actually over 8 CPUs while the %CPU is for the CPU the process is using?

*What happens for processes that are utilizing more than one CPU?

*Does tomcat use more than one CPU if required? Or will tomcat crash if the load is increased but we will never be informed of high load

Top Output
    top - 12:17:40 up 9 days, 21:51,  2 users,  load average: 0.32, 0.28, 0.27
    Tasks: 201 total,   2 running, 199 sleeping,   0 stopped,   0 zombie
    Cpu(s):  3.8%us,  0.1%sy,  0.0%ni, 96.1%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:  16229072k total,  5617572k used, 10611500k free,   156480k buffers
    Swap:  8388588k total,        0k used,  8388588k free,  2632452k cached

      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    32676 tomcat    20   0 12.4g 2.3g  10m S 29.6 14.6   2530:56 java

I have checked sources such as http://www.kernelhardware.org/linux-top-command/ , but not one of them makes the distinction between %us and %CPU .
Only some ambiguous information such as: %CPU – Percentage of CPU used

A: The CPU percentages shown in top are for all CPUs combined. To see per-CPU statistics, press 1 while top is running.
The percentages in the process list, on the other hand, are a percentage of a single CPU core, and thus may exceed 100%.


text:
Q: react native server response data format Among the data coming from the server as a response, the time comes as follows: Dec 1, 2021 12:07:32 PM
I want to use the above format as 'YYYY-MM-DD HH:mm:ss'. How should I convert it?
new Date('Dec 1, 2021 12:07:32 PM') =>  Date { NaN }
moment('Dec 1, 2021 12:07:32 PM').format('YYYY-MM-DD HH:mm:ss') => Invalid date

A: please do:
let date = new Date(dateServer)
date = moment(date).format("YYYY-MM-DD HH:mm:ss");
console.log(date);


text:
Q: Torch filter multidimensional tensor by start and end values I have a list of sentences and I am looking to extract contents between two items.
If the start or end item does not exist, I want it to return a row with padding only.
I already have the sentences tokenized and padded with 0 to a fixed length.
I figured a way to do this using for loops, but it is extremely slow, so would like to
know what is the best way to solve this, probably by using tensor operations.
import torch
start_value, end_value = 4,9

data = torch.tensor([
[3,4,7,8,9,2,0,0,0,0],
[1,5,3,4,7,2,8,9,10,0],
[3,4,7,8,10,0,0,0,0,0], # does not contain end value
[3,7,5,9,2,0,0,0,0,0], # does not contain start value
])

# expected output
[
[7,8,0,0,0,0,0,0,0,0],
[7,2,8,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
]
# or
[
[0,0,7,8,0,0,0,0,0,0],
[0,0,0,0,7,2,8,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
]

The current solution that I have, which uses a for loop. It does not produce a symmetric array like I want in the expected output.
def _get_part_from_tokens(
    self,
    data: torch.Tensor,
    s_id: int,
    e_id: int,
) -> list[str]:
    input_ids = []
    for row in data:
        try:
            s_index = (row == s_id).nonzero(as_tuple=True)[0][0]
            e_index = (row == e_id).nonzero(as_tuple=True)[0][0]
        except IndexError:
            input_ids.append(torch.tensor([]))
            continue
        if s_index is None or e_index is None or s_index > e_index:
            input_ids.append(torch.tensor([]))
            continue
        ind = torch.arange(s_index + 1, e_index)
        input_ids.append(row.index_select(0, ind))
    return input_ids

A: A possible loop-free approach is this:
import torch

# using the provided sample data
start_value, end_value = 4,9
data = torch.tensor([
    [3,4,7,8,9,2,0,0,0,0],
    [1,5,3,4,7,2,8,9,10,0],
    [3,4,7,8,10,0,0,0,0,0], # does not contain end value
    [3,7,5,9,2,0,0,0,0,0], # does not contain start value
    [3,7,5,8,2,0,0,0,0,0], # does not contain start or end value
])

First, check which rows contain only a start_value or an end_value and fill these rows with 0.
# fill 'invalid' rows with 0
starts = (data == start_value)
ends = (data == end_value)
invalid = ((starts.sum(axis=1) - ends.sum(axis=1)) != 0)
data[invalid] = 0

Then set the values up to (and including) the start_value and after (and including) the end_value to 0 in each row. This step targets mainly the 'valid' rows. Nevertheless, all other rows will (again) be overwritten with zeros.
# set values in the start and end of 'valid rows' to 0
row_length = data.shape[1]
start_idx = starts.long().argmax(axis=1)
start_mask = (start_idx[:,None] - torch.arange(row_length))>=0
data[start_mask] = 0
end_idx = row_length - ends.long().argmax(axis=1)
end_mask = (end_idx[:,None] + torch.arange(row_length))>=row_length
data[end_mask] = 0

Note: This works also, if a row contains neither a start_value nor an end_value (I added such a row to the sample data). Still, there are many more edge cases that one could think of (e.g. multiple start and end values in one row, start value after end value, ...). Not sure if they are of relevance for the specific problem.

Comparison of execution time
Using timeit and randomly generated data to compare the execution time of the different approaches suggests, that the approach without loops is considerably faster than the approach from the question. If the data is converted to numpy first and converted back to Pytorch afterwards some further (very minor) time savings are possible.

Each dot (execution time) in the plot is the minimum value of 3 trials each with 100 repetitions.

A: this is my attempt at improving @rosa b. algorithm.
Could you try this:
def function1(
    data: torch.Tensor,
    start_value: int,
    end_value: int,
):

    # fill 'invalid' rows with 0
    row_length = data.shape[1]
    starts = (data == start_value)
    ends = (data == end_value)

    invalid = ((starts.sum(axis=1) - ends.sum(axis=1)) != 0)
    data[invalid] = 0

    valid_ind = torch.where(torch.logical_not(invalid))

    # set values in the start and end of 'valid rows' to 0
    arange_arr = torch.arange(row_length)
    start_idx = starts.long()[valid_ind].argmax(axis=1)

    start_mask = (start_idx[:, None] - arange_arr) >= 0

    end_idx = row_length - ends.long()[valid_ind].argmax(axis=1)
    end_mask = (end_idx[:, None] + arange_arr) >= row_length

    mask = torch.logical_or(start_mask, end_mask)
    tmp = data[valid_ind]
    tmp.masked_fill_(mask, 0)
    data[valid_ind] = tmp

    return data

The main idea is I think the list of valid indexes is small. Therefore, we could skip many computations. I make some other minor updates so it should be slightly faster.
(Sorry I don't have enough reputation to make a comment).


text:
Q: The number of placement of $n$ pieces on the chessboard of $n\times n$, such that the piece $k$ cannot be placed in the $k$-th row nor $k$-th column Considering the chessboard of $n\times n$, we now want to put n pieces $1,2,\cdots, n$ on this chessboard, and satisfy that the piece $k$ cannot be placed in the $k$-th row nor $k$-th column, and each grid can only place one piece at most. How many kinds of placement are there?
I calculate the answer with inclusion-exclusion principle
the Mathematica code is:
glist = RecurrenceTable[{g[
       i] == (2 n - 1) g[i - 1] + (-2 i + 2) g[i - 2],
     g[2] == 4 n^2 - 4 n - 1, g[1] == 2 n - 1}, g, {i, 1, 10}] //
   FullSimplify // Expand
answer[n_] :=
 n!*Binomial[n^2, n] +
  Sum[(-1)^i*Binomial[n, i]*(g /. {g -> glist[[i]]})*
    Binomial[(n^2 - i), (n - i)]*(n - i)!, {i, 1, n}]
Table[answer[i] /. {n -> i}, {i, 1, 10}]

$$
\{0,1,52,4737,718656,162509785,51209676372,21445634148225,11519808468594976,7721569549966334481\}
$$

Someone says this question can also be solved with generating function.
$$
n ! \cdot\left[x^n\right](1+x)^{n^2} \cdot \exp \left(\frac{-2 n x}{1+x}+\frac{x}{(1+x)^2}\right)
$$
the following mma code verified the correctness of the formula.
Flatten@Table[
  i!*SeriesCoefficient[(1 + x)^{n^2}*
      Exp[-2 n*x/(1 + x) + x/((1 + x)^2)], {x, 0, i}] /. {n -> i}, {i,
    1, 10}]

The key word of this approach is probably:
the inclusion-exclusion principle, the Mobius equation/Mobius inversion of partition lattice, Weisner's method.
My question is: what are the detailed steps of this approach?


text:
Q: how to modify the response in emberjs restadatper? I am learning Ember JS. I am using a product model as :
App.Product = DS.Model.extend({
  id: DS.attr('string'),
  name: DS.attr('string'),
  code: DS.attr('string'),
  version: DS.attr('string'),
  description: DS.attr('string')
});

The response I get from the server for /products URL is as follows (array of JSON objects):
[
  {
    "name": "Product1",
    "code": "ASDF",
    "version": "1.1",
    "id": "1"
  },
  {
    "name": "Product2",
    "code": "QWER",
    "version": "2.2",
    "id": "2"
  }
]

But when I return this.store.find('product'); from model hook for App.ProductsRoute I get the Error: No model was found for '0'.
I am sure it has to do something with DS.RESTAdapter and something related to RESTSerializer and extractArray, but I am unable to figure it out. What should be the JSON Convention to follow for such response? And could I modify it in .then(onSuccess) method of this.store.find()?


text:
Q: How to get the queue size of the executor in real time Supposed i have this application.java
@SpringBootApplication
public class Application {
    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public Executor asyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(50);
        executor.setMaxPoolSize(100);
        executor.setQueueCapacity(5000);
        executor.setThreadNamePrefix("sm-async-");
        executor.setWaitForTasksToCompleteOnShutdown(true);
        executor.initialize();
        return executor;
    }
}

My goal is to create an alert if the current real time queue size of the async executor is in 80% or nearly the limit. I think we can get the value from executor.getThreadPoolExecutor().getQueue().size();. Im currently stuck on how to achieve that

A: @Controller
public class QueueMonitorController {

    @Autowired
    private Executor executor;

    @RequestMapping(value = "/queuesize", method = RequestMethod.GET)
    public int queueSize() {
        ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
        return tpe.getQueue().size();
    }
}

If you can provide the bean as a ThreadPoolExecutor, then you don't even need the cast. The internal implementation of size() in LinkedBlockingQueue (which ThreadPoolExecutor uses) is AtomicInteger.get().
So there's no need to get creative and build your own mechanisms, it's all built-in. Based on Spring 4.2, but shouldn't depend on the version too much.

So the root goal is to monitor the queue, and send an alert when queue is 80% full. This should not go into your code which is responsible for making sure that your business logic works. You shouldn't make hacks there to account for lack of resources. If the idea is that you should throttle users when the queue is packed, there are far better ways to handle those.
Since the idea is to do "light monitoring", i.e. there's no attempt to handle a case when queue is 80% full, a polling solution would be lightweight enough. Considering that the executor can be easily injected to a separate Controller, it won't even mess up your "real" code.

A: As ThreadPoolTaskExecutor does not expose any API you can get the queue used by it. However, you are free to extend  ThreadPoolTaskExecutor  and create a CustomThreadPoolTaskExecutor override the createQueue.
public class CustomThreadPoolTaskExecutor extends ThreadPoolTaskExecutor{

    private BlockingQueue<Runnable> queue;

    @Override
    protected BlockingQueue<Runnable> createQueue(int queueCapacity) {
        queue = super.createQueue(queueCapacity);
        return queue;
    }

    public BlockingQueue<Runnable> getQueue(){
      return queue;
    }
}

Now you can create asyncExecutor like below :
@Bean
public Executor asyncExecutor() {
    ThreadPoolTaskExecutor executor = new CustomThreadPoolTaskExecutor();
    //set other properties
    executor.initialize();
    return executor;
}

Your CustomThreadPoolTaskExecutor executor has public method getQueue and you can use that to get the queue.

A: I don't know from where you have got ThreadPoolTaskExecutor class type of executor. But in java you can typecast  to ThreadPoolExecutor and get queue and it's size as below:
ThreadPoolExecutor executorService =  (ThreadPoolExecutor )Executors.newCachedThreadPool();
        executorService.getQueue().size()

A: To do this in real-time as you're asking for is not so easy. You'll need to decorate the methods of BlockingQueue so that you can add code to execute immediately when the content of the queue changes.
You can then provide your queue to Spring's ThreadPoolTaskExecutor like this:
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor() {
  @Override
  protected BlockingQueue<Runnable> createQueue(int queueCapacity) {

    // create and return your instance of blocking queue here
  }
};


text:
Q: A sufficient condition for multiple differentiability of a function of several variables While working on some properties of partial derivatives and multiply differentiable functions of several variables, I came across the following Hypothesis 1:
Let $f: \mathbb{R}^n\to\mathbb{R}$, $\delta>0$, $k\in \mathbb{N}$ and for each partial derivative $D^{k-1}f:=\partial_{i_1}\ldots\partial_{i_{k-1}}f$ of $f$ of order $k-1$ one of its partials $\partial_1D^{k-1}f,\ldots,\partial_nD^{k-1}f$ exists at $\mathbb{a}\in \mathbb{R}^n$ and that the remaining $n-1$ of them exist in some neighborhood $O_\delta(\mathbb{a})$ and are continuous at $\mathbb{a}$. Then $f$ is $k$ times differentiable at $\mathbb{a}$ (i.e. $f$ is $k-1$ times differentiable in some neighborhood of $\mathbb{a}$ and all of its partials of order $k-1$ are differentiable at $\mathbb{a}$).
For $k=1$ the statement is true and can be found, for example, in T.Apostol's "Mathematical Analysis" (Th. 12.11). I wonder if anyone saw this statement somewhere for $k\geqslant 2$ or has any suggestions on its proof (or maybe a counterexample for disproof)?
First I started with the case $n=k=2$ and tried to find a counterexample (similar to one constructed in https://www.mdpi.com/2227-7390/8/11/1946/htm), namely I tried to construct a function $f(x,y)$ such that $f_{xy}$ , $f_{yx}$ exist at $(0,0)$ and $f_{xx}$, $f_{yy}$ exist in some neighborhood and are continuous at $(0,0)$, but $f$ is $\textit{not}$ twice differentiable at $(0,0)$ (i.e. there is no neighborhood of $(0,0)$ where $f$ is differentiable, because the defferentiability of $f_x$ and $f_y$ at $(0,0)$ follows from the Apostol's case $k=1$). But T.Tao pointed out that in this setting $f$ belongs to $C^1$ in some neighborhood of $(0,0)$ by Shauder estimates (see A non-differentiable function $f(x,y)$ with bounded $f_x$, $f_y$, $f_{xx}$ and $f_{yy}$), so $f$ is in fact $\textit{twice differentiable}$ at $(0,0)$! Now it seems to me that Hypothesis 1 is in fact true! In order to prove it in case $n=k=2$ there are two cases remaining: assume that $f_x$ and $f_y$ are differentiable at $\mathbb{a}$ and either

*

*$f_{xx}$ and $f_{yx}$ exist in some neighborhood and are continuous at $(0,0)$,
or

*$f_{xy}$ and $f_{yx}$ exist in $O_\delta(\mathbb{a})$ exist in some neighborhood and are continuous at $(0,0)$.

Prove that $f$ is differentiable in some neighborhood of $(0,0)$.
Shauder estimates don't work in these cases. Any suggestions?


text:
Q: Definition of certain Gateaux differentials of the norm in E. R. Lorch: "A Curvature Study of Convex Bodies in Banach Spaces" In the paper E. R. Lorch: A Curvature Study of Convex Bodies in Banach Spaces from 1953, the following assumptions and definitions are stated in section II (p. 107-108):

Let $(B, \| \cdot \|)$ be a real Banach space and $B^*$ its dual space.
Let $r > 1$ and $G(x) := \frac{1}{r} \| x \|^r$ and $\phi(\alpha, \beta) := G(x + \alpha y + \beta z)$, where $x, y, z \in B$ are fixed and $\alpha, \beta \in \mathbb{R}$.
Assuming that $\phi$ is twice continuously differentiable, the derivative of $\phi$ with respect to $\alpha$ at $\alpha = \beta = 0$ will be denoted the $G_y(x)$. [...]
It is clear that $G_x(x) = r G(x)$. [...]
The second derivatives of $\phi$ at $\alpha = \beta = 0$ will be denoted by $G_{y, y}(x)$, $G_{y, z}(x)$ and $G_{z, z}(x)$. [...] It is clear that $G_{y, z}(x) = G_{z, y}(x)$.

I am trying to understand the functions $G_y$, $G_{y, y}$, $G_{y, z}$ and $G_{z, z}$.
Firstly, we have $G \colon B \to \mathbb{R}$ and $\phi \colon \mathbb{R} \times \mathbb{R} \to \mathbb{R}$.
I would write
$$
G_y(x)
= \frac{\partial}{\partial \alpha}\bigg|_{\alpha = \beta = 0} \phi(\alpha, \beta)
= \lim_{\gamma \to 0} \frac{\phi(\gamma, 0) - \phi(0, 0)}{\gamma}
= \lim_{\gamma \to 0} \frac{G(x + \gamma y) - G(x)}{\gamma}
= \text{d}G(x; y),
$$
where the last expression is the Gateaux derivative of $G$ at $x$ in direction $y$.
This would make sense since we can then verify $G_x(x) = r G(x)$ (which is stated as "clear" above): for $x \in B$ we have
$$
G_x(x)
= \lim_{\gamma \to 0} \frac{G(x + \gamma x) - G(x)}{\gamma}
= G(x) \lim_{\gamma \to 0} \frac{(1 + \gamma)^r - 1}{\gamma}
= r G(x).
$$
Furthermore, $y \mapsto G_y(x)$ is a linear bounded map $B \to \mathbb R$, which seems to be what is stated in theorem 1 ("If $x$ is any fixed element in $B$, then $G_y(x)$ represents a bounded linear functional").

How do the corresponding expressions for $G_{y, y}(x)$, $G_{y, z}(x)$ and $G_{z, z}(x)$ look like?
In particular, are the second derivatives both taken with respect to $\alpha$ or are they mixed?

Wikipedia gives the following as one definition of the second order Gateaux derivative of $G$:
$$
D^2 G(x)\{y ,z \}
:= \lim_{\gamma \to 0} \frac{\text{d}G(x + \gamma y; z) - \text{d}G(x; z)}{\gamma}
= \frac{\partial^2}{\partial \alpha \partial \beta} \bigg|_{\alpha = \beta= 0} \phi(\alpha, \beta).
$$
Is this expression $G_{y, z}(x)$?
If so, we would presumably have
$$
G_{y, y}(x)
= \frac{\partial^2}{\partial \alpha^2} \phi(\alpha, \beta) \bigg|_{\alpha = \beta = 0}
= \frac{\partial^2}{\partial \alpha^2} G(x + \alpha y + \beta z) \bigg|_{\alpha = \beta = 0}
= \lim_{\gamma \to 0} \frac{\text{d}G(x + \gamma y; y) - \text{d}G(x; y)}{\gamma}
$$
and analogously
$$
G_{z, z}(x)
= \frac{\partial^2}{\partial \beta^2} \phi(\alpha, \beta) \bigg|_{\alpha = \beta = 0}
= \frac{\partial^2}{\partial \beta^2} G(x + \alpha y + \beta z) \bigg|_{\alpha = \beta = 0}.
$$

According to Theorem 2 in that paper, we have $G_{y, z}(x) \in B^*$ for $y \in B$ and $G_y(x) \in B^*$ for $x \in B$.
Do my above guesses about $G_{y, y}$, ... fulfill those requirements?