javascript – how I can add new key value pairs and how to loop it to get each values?

In my react app I have a array state

state={
    relationData: ()
}

I want to push data that has a key-value pair

Example(expected array)

( {name:"Amit",id:1}, {name:"Pankaj",id:2}, {name:"Sumit",id:3} )

Above structure, I want after push data So how I can push this name and id?

Also, I want to loop this array such as I can print the name and its id. How I can do these two tasks?

safari – AppleScript: “Repeat” Loop Only Works With Variable

Very curious as to why this works (the context is an open and activated/frontmost Safari window displaying the “Customize Toolbar” sheet):

tell application "System Events"
    tell process "Safari"
        set entireContents to entire contents of sheet 1 of front window
        repeat with x in entireContents
            if class of x is image and description of x contains "My Extension" then
                set targetExtIconPos to position of image 1 of x
            else if class of x is image and description of x is "default set of toolbar items" then
                set defaultToolbarPos to position of x
            end if
        end repeat
    end tell
end tel

but changing repeat with x in entireContents to repeat with x in entire contents of sheet 1 of front window throws an error (and does so even if parenthesis are utilized as in repeat with x in (entire contents of sheet 1 of front window))?

The error I get is: execution error: System Events got an error: Can’t make item 1 of entire contents of sheet 1 of window 1 of process "Safari" into type specifier. (-1700)

This caused alot of headache before I randomly found it would work if I just assigned it to a var first…

Also is there a way to achieve what I am attempting here without using a loop at all? I feel like there is a way, but the syntax is just awfully hard and complex to figure out and nail down.

Loop through items created in a custom post type

I have custom post type.

How it is possible to loop through the page created in this custom post type please ?

Thanks.

javascript – Loop infinito ao fazer verificação

Estou fazendo um exercicio, onde uma função recebe um valor e busca dentro de um array, somando os valores encontrado neste array ate igualar ao valor recebido, retornando depois a quantidade de valores que foi do array para a soma. O exercicio não precisa ser resolvido, eu so gostaria de entender, o por que meu for entrou em loop infinito ao fazer a logica para somar esses valores. Agradeço desde já.

const notasReais = ( valor ) => {

    let notasReais = (1, 5, 10, 50, 100)
    let arrayNotas = notasReais.reverse()
    
    let calculoNotas = 0
    let qntNotas = ()
    
    while (calculoNotas < valor) 
    {
    
        for (let i=0; i < arrayNotas.length; i++) 
        {   
            if(arrayNotas(i) < valor && (calculoNotas + arrayNotas(i)) < valor )
            {
                calculoNotas += arrayNotas(i)
                break
            }
        }
        
    }
    
    return console.log(calculoNotas)
}

notasReais(25)

c – Como eu crio um loop que permita cancelar a ordem anterior quando passar de um certo valor?

Boa noite. A seguinte linguagem é MQL5. Estou a criar um robô para o MetaTrader 5. Eu criei depois de muitas horas o código que aparecer a seguir. Eu na altura fiz os comentários em inglês tal e qual como no tutorial pois o vídeo estava em inglês. O meu objetivo é fazer com que uma ordem BUY seja criada sempre que o valor de RSI(Relative Strenght Index) passe a ser maior que 70, e mal passe a ser menor que 70, que crie uma ordem SELL, deletando a ordem anterior. Como a estratégia vai sempre responder aos valores de RSI, ela não precisa de Stop Loss ou Take Profit. Tem algumas coisas que não sei o que fazem ou se realmente são necessárias. Eu gostava de saber o que fiz errado.
Obrigado a quem poder ajudar.

//+------------------------------------------------------------------+
//|                                                     RSIrobot.mq5 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <ExpertExpert.mqh>
//--- available signals
#include <ExpertSignalSignalRSI.mqh>
//--- available trailing
#include <ExpertTrailingTrailingNone.mqh>
//--- available money management
#include <ExpertMoneyMoneyFixedLot.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string             Expert_Title         ="RSIrobot";  // Document name
ulong                    Expert_MagicNumber   =18801;       //
bool                     Expert_EveryTick     =false;       //
//--- inputs for main signal
input int                Signal_ThresholdOpen =10;          // Signal threshold value to open    (0...100)
input int                Signal_ThresholdClose=10;          // Signal threshold value to close (0...100)
input double             Signal_PriceLevel    =0.0;         // Price level to execute a deal
input double             Signal_StopLevel     =50.0;        // Stop Loss level (in points)
input double             Signal_TakeLevel     =50.0;        // Take Profit level (in points)
input int                Signal_Expiration    =4;           // Expiration of pending orders (in bars)
input int                Signal_RSI_PeriodRSI =14;          // Relative Strength Index(14,...) M1     Period of calculation
input ENUM_APPLIED_PRICE Signal_RSI_Applied   =PRICE_CLOSE; // Relative Strength Index(14,...) M1 Prices series
input double             Signal_RSI_Weight    =1.0;         // Relative Strength Index(14,...) M1   Weight (0...1.0)
//--- inputs for money
input double             Money_FixLot_Percent =100.0;       // Percent
input double             Money_FixLot_Lots    =0.05;        // Fixed volume
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
if(!ExtExpert.Init(Symbol(),PERIOD_M1,Expert_EveryTick,Expert_MagicNumber))
  {
   //--- failed
   printf(__FUNCTION__+": error initializing expert");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- Creating signal
CExpertSignal *signal=new CExpertSignal;
if(signal==NULL)
  {
   //--- failed
   printf(__FUNCTION__+": error creating signal");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//---
ExtExpert.InitSignal(signal);
signal.ThresholdOpen(Signal_ThresholdOpen);
signal.ThresholdClose(Signal_ThresholdClose);
signal.PriceLevel(Signal_PriceLevel);
signal.StopLevel(Signal_StopLevel);
signal.TakeLevel(Signal_TakeLevel);
signal.Expiration(Signal_Expiration);
//--- Creating filter CSignalRSI
CSignalRSI *filter0=new CSignalRSI;
if(filter0==NULL)
  {
   //--- failed
   printf(__FUNCTION__+": error creating filter0");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
signal.AddFilter(filter0);
//--- Set filter parameters
filter0.Period(PERIOD_M1);
filter0.PeriodRSI(Signal_RSI_PeriodRSI);
filter0.Applied(Signal_RSI_Applied);
filter0.Weight(Signal_RSI_Weight);
//--- Creation of trailing object
CTrailingNone *trailing=new CTrailingNone;
if(trailing==NULL)
  {
   //--- failed
   printf(__FUNCTION__+": error creating trailing");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- Add trailing to expert (will be deleted automatically))
if(!ExtExpert.InitTrailing(trailing))
  {
   //--- failed
   printf(__FUNCTION__+": error initializing trailing");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
 //--- Set trailing parameters
 //--- Creation of money object
CMoneyFixedLot *money=new CMoneyFixedLot;
if(money==NULL)
  {
   //--- failed
   printf(__FUNCTION__+": error creating money");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- Add money to expert (will be deleted automatically))
if(!ExtExpert.InitMoney(money))
  {
   //--- failed
   printf(__FUNCTION__+": error initializing money");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- Set money parameters
money.Percent(Money_FixLot_Percent);
money.Lots(Money_FixLot_Lots);
//--- Check all trading objects parameters
if(!ExtExpert.ValidationSettings())
  {
   //--- failed
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- Tuning of all necessary indicators
if(!ExtExpert.InitIndicators())
  {
   //--- failed
   printf(__FUNCTION__+": error initializing indicators");
   ExtExpert.Deinit();
   return(INIT_FAILED);
  }
//--- ok
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
 {
  ExtExpert.OnTrade();
 }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
  ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+

SAMSUNG a10s boot loop after TWRP flash

I have bought a SAMSUNG A10s phone and tried to install TWRP according to this instruction. I was able to unlock the bootloader and enter the ‘Downloading’ mode. I used a Debian computer and the Heimdall tool to flash this TWRP image into the recovery partition (which replaced the existing recovery.img, I took no backup – daft, I know).

Caused by the unlocked bootloader I got a warning with every startup. The usual key-combination for the bootloader menu did not work. So, after a few boot procedures, I tried the offered option to lock the bootloader and perform a factory reset.

Unfortunately, this brought me to bootloop. I was only able to enter the ‘Downloading’-mode again. Now, the bootloader is locked again but the images are invalid. I get this error message:

<!>
Partition recovery
Reason recovery: Eroor verifying vbmeta image: invalid vbmetaheader
SAMSUNG recovery, A107FXXU7BTL1, 36415554R
SAMSUNG vbmeta, A107FXXU7BTL1, 36415554R

Quitting this ‘Downloading’ mode brings me back to the loop which reaches the SAMSUNG logo before it boots angain.

Can anyone explain this situation? Has anyone an idea for a solution? Using Heimdall, I can still read the PIT. So, maybe I can also flash any images. I am very glad for help!

vba – automatic refresh of slicer and pivot charts how to write a loop

this is my first post here 🙂
Maybe some details at the beginning.
I have three pivot charts based on pivot tables. I have some slicers to these charts as well.
I can choose no. of week at slicer so I can see data exactly for that week on chart.
For example, today is 7th week of 2021. Filter is built like 2020_54, 2021_01, 2021_02…

And my goal is to find a way to automatic refresh of slicer so when the user open the file he will see data on charts just for specific date range. Without clicking anything on slicers manually. “Date from” should be always 2021_01 (from first week of the year). “Date to” should be actual number of week.

And I wrote today some vba code. I don’t have much experience in that stuff. Let’s take a look.

Sub subrefreshpivots()

Dim endDate as date

Dim nrtyg as string

‘refresh “date to” (there is =TODAY() function in cell named “endDate” in “shtDane” sheet)

With shtDane

Range(“endDate”).Select

Calculate

End With

‘ value assignment from “endDate” cell to variable called endDate

shtDane.Range(“endDate”).value = endDate

‘which no. of week we have right now

nrtyg = Application.WorksheetFunction.WeekNum(endDate) – 1

With shtDane

With Activesheet.PivotTables(“mypivottable”).PivotFields(“planned week”)

if nrtyg = 1 then .PivotItems(“1”).Visible = True

if nrtyg = 2 then .PivotItems(“1”).Visible = True and .PivotItems(“2”).Visible = True

end with

end with

end sub

My question is how to write some sort of loop just to not repeat this if – then statement and that the code will be clean. I cannot use macro recorder to record a loop.
And my second request. I would like to end macro as soon as possible when the condition is TRUE so the macro doesn’t need to check other if – then statements after TRUE condition.

Thanks for your help.

plugin development – Is there a way to loop through a shortcode datasource to create a table?

is there a way to loop through a shortcode data source created in a custom plugin like followed within a 3d party frontend design plugin?

function bs_test_fnc(){
        $aData = array(
            array('a','b','c'),
            array('a','b','c'),
            array('a','b','c'),
        );
        return $aData;
    }
add_shortcode('bs_resource_table_datasource_test','bs_test_fnc');

Explaination:

The data tables in my plugin are not custom post types though I was wondering if I could somehow generate a propper dynamic table content with this data using some of the design plugins. But these pro plugin versions all cost a lot of money and they seem not to be able to attach to shortcodes in the way I was thinking this might work.

So how do you do this?
Do you force all your plugin data into custom post types in order to have it accessible to other plugins? Or is there another way?

I have of course created plain HTML tables and displayed my data through shortcodes to test backend functionality but this seems more like a misuse of PHP since I normally use templating engine frameworks (with other CMS). On top of that, this would probably be really hard to design and display properly like this. Especially not quick or repeatable and I am trying out WordPress to be able to do quick and pretty.

I’d appreciate it if you could explain or link to me a proper use case, how one would do this “templating” like in a template engine with custom WordPress plugins either in cooperation with 3d party plugins or use of a templating engine or other WordPress tools.

The taxonomies make this really hard to search for and identify the proper way to do this with WordPress.

boot loop – Nexus 7 2013 – stuck at android is starting optimizing apps. trying adb to get the data

I have a 2013 model Nexus 7.
It is running 6.0.1, unmodified with locked bootloader. USB debugging is on.

Battery drained to 0. Charged then the device is stuck on boot loop .. android is optimizing app X of x.
I don’t wanna lose the data so I’ve avoided hard reset.

  • I’ve wiped cache more than once.

  • I tried ADB Commands .. and while on the android is starting I can list the device and I can list the directoies ..

  • Tried adb pull /
    and it return this message.

    c:Adb>adb pull /

    • daemon not running; starting now at tcp:5037
    • daemon started successfully adb: warning: stat failed for path /proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/self/task/1208/root/proc/222/task/1208/fd/15:
      Protocol not available

Tried shell to see if I can list folders and

Adb shell ls /sdcard/sdcard
it returns the same message.

c:Adb>adb shell ls /mnt

asec

expand

media_rw

obb

runtime

sdcard *******************

secure

user

c:Adb>adb shell ls /mnt/sdcard/
/mnt/sdcard/: No such file or directory

Is there any way that I can retrieve the data before hard resetting .. through adb or custom recovery .. or whatever.

How to loop through individual sheets [closed]

We are trying to display our sheets on a television in our shop. Each workbook contains separate sheets for each machine. We want the display to automatically rotate through the sheets every 15-20 seconds. Is this possible?