python – Why does io.BytesIO add a NULL byte when deleting / deleting?

I'm trying to migrate a Python 2 project so that it is Python 3 compatible and I got hooked when it was harder than expected to replace a StringIO.StringIO with io.BytesIO. After a lot of debugging, I think the problem boils down to this difference in behavior:

Using StringIO.StringIO:

>>> sys.executable
'/Users/michael/.pyenv/versions/2.7.17/bin/python'
>>> s = StringIO.StringIO()
>>> s.truncate(0)
>>> s.write('a')
>>> s.flush()
>>> s.seek(0)
>>> s.read()
'a'
>>> s.truncate(0)
>>> s.write('a')
>>> s.flush()
>>> s.seek(0)
>>> s.read()
'a'

Using io.BytesIO:

>>> sys.executable
'/Users/michael/.pyenv/versions/2.7.17/bin/python'
>>> b = io.BytesIO()
>>> b.truncate(0)
0L
>>> b.write('a')
1L
>>> b.flush()
>>> b.seek(0)
0L
>>> b.read()
'a'
>>> b.truncate(0)
0L
>>> b.write('a')
1L
>>> b.flush()
>>> b.seek(0)
0L
>>> b.read()
'x00a'

So, you can see the second time, truncate and empty the buffer of the io.BytesIO The object gets a null byte at first, but not the StringIO.StringIO object.

In Python 3.5.8, I can not use StringIO.StringIO, but in io.BytesIO the behavior is the same (noting that I write explicitly b'a').

What are the causes of adding this zero byte when I try to continually crush a io.BytesIO for example, but not when I use StringIO.StringIO?

SharePoint 2013: Add a second domain to PP and move a user

This depends on the domain trust mode (bidirectional or unidirectional), but this topic is covered in Using the People Picker with Multiple Forests or Domains and Configuring the People Picker (SharePoint Server 2010).

Some notes on this subject:

  1. The user object must be disabled in the source or target forest. The activation in both cases is not supported and, with the User Profile Synchronization service, you can see an unexpected migration activity in SharePoint when it is enabled in both forests. .

  2. SharePoint servers can not be moved between domains / forests. You must create a new farm in the target forest and perform a database migration for service applications and content databases.

Here is the complete process:

$wa = Get-SPWebApplication https://url
$adsearchobj = New-Object Microsoft.SharePoint.Administration.SPPeoplePickerSearchActiveDirectoryDomain
$adsearchobj.DomainName = "contoso.com"
$adsearchobj.ShortDomainName = "CONTOSO" #Optional
$adsearchobj.IsForest = $true #$true for Forest, $false for Domain
$wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Add($adsearchobj)
$wa.Update()

Do this for each forest and each web application.

When you move a user object from one forest to another, look for a site collection URL in which the user object exists and run it:

$user = Get-SPUser https://siteCollUrl
Move-SPUser -Identity $user -NewAlias 'i:0#.w|newdomainusername' -IgnoreSid

You can also launch:

stsadm -o migrateuser -oldlogin 'i:0#.w|olddomainusername' -newlogin 'i:0#.w|newdomainusername' -ignoresidhistory

add value to a C array

I'm trying to add an event to the event recording screen and I do not get it. When I go to the list screen, the events are not displayed.

I declare the global array out of hand (), can anyone help me?

I do the work of this semester in C, which the teacher asked.

#include 
#include 
#include 

int opcao_menu;

int evento_id(24);
char evento_titulo(24), evento_horario(24), evento_lugares(24);

/*
===============================================================================================
INICIO
===============================================================================================
*/
int main(int argc, char *argv()) {
	
	setlocale(LC_ALL,"");
	telaMenu();
	
	return 0;
}



/*
===============================================================================================
HELPERS
===============================================================================================
*/
int menu() {
	printf("n--------------------------------------n");
	printf("-- MENU --n");
	printf("--------------------------------------n");
	printf("nn");
	printf("1 - Cadastrar peça teatral de hojen");
	printf("2 - Vender ingresson");
	printf("3 - Fechamento do caixa de hojen");
	printf("4 - Sair do sisteman");
	printf("--------------------------------------n");
	printf("nn");
	printf("Digite a opção: ");
	
	scanf("%d", &opcao_menu);
	
	return 0;
}




/*
===============================================================================================
TELAS DO SISTEMA
===============================================================================================
*/
int telaMenu() {
	menu();
	
	switch(opcao_menu){
		case 1:
			telaCadPeca();
			break;
		case 2:
			telaVendaIngresso();
			break;
		case 3:
			telaFechamentoCaixa();
			break;
		case 4:
			telaSair();
			break;
		default:
			break;	
	}
	
	opcao_menu = 0;
	
	return 0;
}

int telaCadPeca() {
	int i, id, lugares, qtd_evt, chave_evt;
	char titulo, horario, finalizar;

	printf("Nome da peça (Não utilizar acentuação): ");
	scanf("%s", &titulo);
	printf("Horário (Formato: 99:99): ");
	scanf("%s", &horario);
	printf("Quantidade de lugares: ");
	scanf("%d", &lugares);
		
	//qtd_evt = sizeof(evento_id)/sizeof(int);	
	//chave_evt = qtd_evt;
	
	for( i=0; i<24; i++ ){
		if(!evento_titulo(i)) {
			chave_evt = i;
			break;
		}
	}
		
	//evento_id() = chave_evt;
			
	evento_titulo(chave_evt) = titulo;
	evento_horario(chave_evt) = horario;
	evento_lugares(chave_evt) = lugares;
	
	printf("Evento cadastrado com sucesso! %d - %s às %s", chave_evt, titulo, horario);
		
	telaMenu();
	
	return 0;
}

int telaVendaIngresso(){
	int i, qtd_evt; 
	int id_evento, cod_evento;
	char titulo;
	
	printf("O ingresso é para qual evento? Escolha um código abaixo:n");
	
	for( i=0; i<24; i++ ){
		id_evento = evento_id(i);
		if( id_evento > 0 ) {
			printf("%d - %sn", id_evento, evento_titulo(i));
		}
			
	}
	
	printf("Digite o código do evento: ");
	scanf("%d", &cod_evento);
	
	telaMenu();
	
	return 0;
}

int telaFechamentoCaixa(){
	return 0;
}

int telaSair(){
	printf("--------------------------------------n");
	printf("Sistema fechadon");
	system("pause");
	
	return 0;
}

html – How can I add custom headers and links to my website from my website?

I am currently using a .html document that I visualize with chrome.
Currently, I code links hard but I want to be able to easily add a link and headers to the page. Below is an example of the current code I use. Thank you in advance for your help.




    Document



    

Search

Google
Bing
Duck Duck Go

Magento 2: add a custom phtml sidebar to the home page

I want to add a custom sidebar phtml file in the home page that would indicate specific categories. I could not find a specific layout or template file for the home page. ideas?

php – WooCommerce: How to add a custom type product (yith composite) to the cart

I'm building a mobile app and I need to add products with ajax queries.

My client uses a custom product type called yith-composite that converts products to parent and children (component)

Like a car (parent) and wheels (component)

My problem that adds button (ajax) and wx-ajax = add_to_cart does not work with this type of product,

Adding to the cart only works properly if I've disabled ajax and let it submit the form, then refresh it.

Once viewed, the data on the application form was as follows:

ywcp_selection(153CE4EE-C1A0-6D39-9AD5-58B51C5AB306): -1
attribute_pa_sphere: 7-50
ywcp_variation_id(153CE4EE-C1A0-6D39-9AD5-58B51C5AB306): 124138
ywcp_quantity(153CE4EE-C1A0-6D39-9AD5-58B51C5AB306): 1
ywcp_selected_product_value(153CE4EE-C1A0-6D39-9AD5-58B51C5AB306): 102523
ywcp_selection(471BAD03-9C3B-B44E-8584-348A5F33F8A6): -1
attribute_pa_sphere: 7-00
ywcp_variation_id(471BAD03-9C3B-B44E-8584-348A5F33F8A6): 110356
ywcp_quantity(471BAD03-9C3B-B44E-8584-348A5F33F8A6): 1
ywcp_selected_product_value(471BAD03-9C3B-B44E-8584-348A5F33F8A6): 102552
quantity: 1
add-to-cart: 102491

So my question is how to change the default value of wc-ajax = add_to_cart to accept this type of new data? and adding the product correctly to the basket?

magento2 – Is it possible to add a drop-down list around Text Swatch?

I'm trying to achieve something like this, I'm attaching an image so that you can understand me correctly. I have Visual Swatch for my colors and Text Swatch for the sizes of my products. I want to encapsulate the sizes of my products in a drop-down list. I found an option to edit the provider / magento / module-swatches / view / frontend / templates / product / listing / renderer.phtml but it's not just for the text nuance and it encapsulates all opt swatch.

Drop-down list of product size

How to add JS validation on the payment page with one click of order?

I need to call the checkout.js validation on order with JS instead after submitting the form.

If any of the required fields is missing, clear the PlaceOrder button.

Does anyone know how to do it? Thank you in advance.

Validate 2 combined fields in the Magento order – Add a new delivery address

On Magento payment page> Add a new delivery address.

I want to validate 30 characters maximum for both Street 1 and Street # 2 combined.

enter the description of the image here

redirects – Affiliate link redirection: can i add nofollow and noreferrer only to the affiliate link and not to the nice link?

I run a WordPress website and I normally use the Thirsty Affiliates plug-in to redirect / hide my affiliate links with a nicer link. WordPress automatically adds the noreferrer and noopener attributes to the nice link, and then I manually add nofollow to the nice link.

However, I am experimenting with a content editor (Thrive Architect) which has allowed me to easily add noopener and noreferrer to my nice link (I have found a solution of bypass but it's a pain in the back).

I was wondering if it was even necessary to add these attributes to the nice link or should I rather add it to the affiliate link?

If I leave them outside the nice link, I think I can get Thirsty Affiliates to add those attributes to the affiliate link on the redirect.

Another question: is noreferrer even worth adding if my affiliate programs do not know where the traffic is coming from? or is there a security advantage?

Thank you for any help that anyone can provide.