C++ multi line string input

Im trying to make a multi line editable input,
best try so far was cin.get(), but I need a string as a deliminator.
Technically Im trying to make a tui textbox but without cursed library.
Any ideas?

How to pass query string containing variable names into mysql stored procedure

I have this procedure into which I need to pass variable parameters. Problem is this: once inside the procedure, the IN parameter needs to pick up already created variables in order to create the final query.

DELIMITER $$
DROP PROCEDURE IF EXISTS MY_PROCEDURE $$
CREATE PROCEDURE MY_PROCEDURE (
    IN sql_string TEXT
)
BEGIN
    SET @q1 := "SELECT * FROM table1";
    SET @q2 := "SELECT * FROM table2";
    
    -- capturing the string of the query from input
    SET @sql = sql_string;
    PREPARE stmt FROM @sql;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt; 
    
END$$
DELIMITER ;

-- calling the procedure
call MY_PROCEDURE('CONCAT(@q1, " WHERE id1 < 10")');
call MY_PROCEDURE('CONCAT(@q1, " WHERE id1 < 10", " UNION ", @q2, " WHERE id2 < 10")');

No matter what I’ve tried, supplying the @ variable with the IN string results in a syntax error.

I have considered that having 2 groups of PREPARE might do the trick:
First PREPARE converts the IN string to actual query by expanding variables, only return the string (Is this even possible???);
Second PREPARE then runs the query on the expanded string.

Phew!!! Any help?

assembly – Printing a decimal number as a string

I’ve written a short script to print a number to a string. This actually was very difficult for me to do — I’m not sure if this is actually a tricky task or just because I’m so new to asm I was having a hard time. Here it is:

SYS_EXIT    = 60
SYS_WRITE   = 1
SYS_STDOUT  = 1

.section .rodata
number: .long   774728

.text
.globl _start
_start:

    
    # set up stack, align on 16 for syscalls
    push %rbp
    mov %rsp, %rbp
    push number
    sub $16, %rsp

    # r12 will store the size of the string to print
    xor %r12d, %r12d

    # on the stack we will store:
    # rbp-16 (properly sorted number to print)
    # rbp-8  (number that remains)
    # rbp-4  (current right-most digit, ie,remainder)

  loop:

    # if the number is zero, jump to print it
    cmpl $0, -8(%rbp)
    je print
    inc %r12d # increment the size of the string to print

    # Divide by ten
    # - %rdx will give us the remainder (right-most digit)
    # - %rax will give us the new number (for our next iteration of the loop
    xor %edx,       %edx
    movl -8(%rbp),  %eax
    mov $10,        %ebx
    div %ebx

    movl %eax,  -8(%rbp)

    # (a) add 48, because ASCII is number + 48, for example ord('7') ==> 55
    addl $48,   %edx
    # (b) move the asci number to rbp-8-len (to print in reverse)
    # store offset (8+len) in %r13
    mov $-8,        %r13
    sub %r12,       %r13
    movb %dl,       (%rbp, %r13)

    jmp loop

    
  print:
    # print(%edi:stdout(int), %esi:mem_of_string(* void), %edx:len_of_string(int))
    # (b) How to print the digit to asci (probably fixed offset for 0-9)
    # Our output has length %r12 and starts at rbp-8-len
    # Which, conveniently enough, is (%rbp, %r13)!
    mov $SYS_STDOUT,    %edi
    lea (%rbp, %r13),   %rsi    # remember, this is an 8-byte MEMORY ADDRESS (pointer), not a number
    mov %r12d,          %edx
    mov $SYS_WRITE,     %eax
    syscall
    
  exit:
    add $8, %rsp    # <-- can also do an empty pop, such as pop %rcx
    mov             %rbp, %rsp
    pop             %rbp
    mov $0,         %rdi
    mov $SYS_EXIT,  %eax
    syscall

And running it:

13_strings$ as file.s -o file.o && ld file.o -o file && ./file
# 774728

Thank you for taking the time to review. Any feedback would be greatly appreciated!

How to traverse the order relationship between string elements in linear time

I have a string and I want to get the order relationship between string elements in linear time. For example, a string "abcacbad", their order relationship is:

ab, ac, ad, bc, ba, bd, ca, cb, cd

string – interface de um programa RPC em RPCL que contenha dois procedimentos

Preciso de uma ajuda com essa questão…

Escreva uma interface de um programa RPC em RPCL que contenha dois procedimentos:

1 – procedimento que tenha como parâmetro um string e devolva um inteiro para consulta de código de um produto pela sua descrição;
2 – procedimento de tenha como parâmetro um inteiro que representa o código de um produto e que devolva seu preço como valor float.

Nginx – How to add a Map Variable to a String

I have below configuration in my nginx.conf, however, for some reason, it doesn’t recognise the $site_name as a variable

map $host $site_name {
  default example.com;
}
error_log  /var/www/vhosts/{$site_name}/httpdocs/var/logs/nginx/error.log error;

The error I get is

nginx: (emerg) open() "/var/www/"$site_name"/httpdocs/var/logs/nginx/error.log" failed (2: No such...irectory)

sharepoint server – Where to store connection string for WCF service that uses EF

I have a WCF service deployed to ISAPI that uses EntityFramework, however, I cannot find where and how can I store the connection string so it can be automatically retrieved when the DBContext is initialized in the application constructor of entity framework initialization, specifically, base(“name=ConnectionStringName”).

PS: The deployed WCF project doesn’t have a web.config

Regards

javascript – Regular expression to get a string between two strings where the last string can also be ‘end of string’

URLSearchParams would make things significantly easier:

const query1 = '?someBoolean=false&q=&location=&testParam=dummy_value&testParam2=dummy_value2&requiredParam=requiredValue';
const query2 = '?someBoolean=false&q=&location=&testParam=dummy_value&testParam2=dummy_value2&requiredParam=requiredValue&someMoreParam=dummy_value2';

const params1 = new URLSearchParams(query1);
const params2 = new URLSearchParams(query2);

console.log(`For Query1: result = ${params1.get('requiredParam')}`);
console.log(`For Query2: result = ${params2.get('requiredParam')}`);

It’s supported natively in the vast majority of browsers, but not all. For the rest, here’s a polyfill. It’s better not to re-invent the wheel when you don’t need to, and it’s good when you’re able to use a standard API (with examples and documentation and Stack Overflow answers about it, etc).

As a side note – when using regular expressions, I’d recommend using capture groups only when necessary. If all you need to do is group some tokens together logically (like for a | alternation), non-capturing groups should be preferred. That is, if URLSearchParams didn’t exist, better to do (?:&|$) than (&|$). Reserve capturing groups for when you need to save and use the captured result somewhere – otherwise, non-capturing groups are more appropriate, less expensive, and require less cognitive overhead.

javascript – Como converter uma string separada em vírgula e letra “e” no final para um array a partir dos números existes?

Como poderia extrair de uma string assim:

var texto = '4°, 5° e 6° ano';

Um resultado assim:

var array = (
   4,
   5,
   6 
);

Ou ainda melhor desta maneira:

var array = (
   '4° ano',
   '5° ano',
   '6° ano'
);

Eu tentei fazendo isso, mas não deu muito certo:

 $scope.filterRecomendations = function(recomend) {
   var list = recomend.split(' e ');
   var collection = ();
   for(var i in list) {
      list(i).split(', ')
      collection.push(list(i));
   }
    collection.flat(Infinity); 
    return collection;
 };

Imprimiu uma coisa esquisita tipo isso no ng-repeat:

(("4º")("5º")("6º ano"))

Exemplo quando tem apenas uma turma:

inserir a descrição da imagem aqui

WPML custom string translation get outside of container

I am trying to add a custom string to translate in wpml, but when I use the _e(…) the content jumps outside of container

if I use like this:

echo '<h1>' . $month . ' ' . $day . '</h1>';

the html is ok:

<h1>September 29</h1>

but if I use with translation like this:

echo '<h1>' . _e($month, 'simultan') . ' ' . $day . '</h1>';

the translated string jumps out of h1:

Septembrie<h1>29</h1>