Programación

Preguntas y respuestas para programadores profesionales y entusiastas.

4
BigDecimal es igual a () versus compareTo ()
Considere la clase de prueba simple: import java.math.BigDecimal; /** * @author The Elite Gentleman * */ public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub BigDecimal x = new BigDecimal("1"); BigDecimal y = new BigDecimal("1.00"); System.out.println(x.equals(y)); System.out.println(x.compareTo(y) == 0 …


11
¿Necesita el texto / javascript especificado en sus etiquetas <script>?
Leí en alguna parte que ya no necesitas cosas como cosas type="text/javascript"raras CDATAy &lt;!--cosas en tus etiquetas de script. Entonces, en lugar de: &lt;script type="text/javascript"&gt; //&lt;![CDATA[ &lt;!-- //your script here --&gt; //]]&gt; &lt;/script&gt; Simplemente harías: &lt;script&gt; //your script here &lt;/script&gt; Sin embargo, no recuerdo dónde leí esto. Creo que fue …
157 javascript  html 


6
pythonw.exe o python.exe?
Larga historia corta: pythonw.exeno hace nada, no python.exeacepta nada (¿cuál debo usar?) test.py: print "a" Ventana CMD: C:\path&gt;pythonw.exe test.py &lt;BLANK LINE&gt; C:\path&gt; C:\path&gt;python.exe test.py File "C:\path\test.py", line 7 print "a" ^ SyntaxError: invalid syntax C:\path&gt; Por favor dime que estoy haciendo terriblemente mal.
157 python  python-3.x 

29
¿Cómo puedo convertir mi token de dispositivo (NSData) en un NSString?
Estoy implementando notificaciones push. Me gustaría guardar mi token APNS como una cadena. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken { NSString *tokenString = [NSString stringWithUTF8String:[newDeviceToken bytes]]; //[[NSString alloc]initWithData:newDeviceToken encoding:NSUTF8StringEncoding]; NSLog(@"%@", tokenString); NSLog(@"%@", newDeviceToken); } La primera línea de código imprime nulo. el segundo imprime la ficha. ¿Cómo puedo obtener mi newDeviceToken …

5
XPath: obtener el nodo primario del nodo secundario
Necesito obtener el nodo primario para el nodo secundario title 50 Por el momento solo estoy usando //*[title="50"] ¿Cómo podría obtener su padre? El resultado debe ser el storenodo. &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;d:data xmlns:d="defiant-namespace" d:mi="23"&gt; &lt;store d:mi="22"&gt; &lt;book price="12.99" d:price="Number" d:mi="4"&gt; &lt;title d:constr="String" d:mi="1"&gt;Sword of Honour&lt;/title&gt; &lt;category d:constr="String" d:mi="2"&gt;fiction&lt;/category&gt; &lt;author …
157 xml  xpath 



6
¿Diferencia entre $ (esto) y event.target?
Soy nuevo en jQuery, y estaba haciendo paneles con pestañas, siguiendo el tutorial en JavaScript y jQuery: The Missing Manual , existe esa primera línea cuando el autor hace esto: var target = $(this); Pero traté de hacerlo de esa manera var target = evt.target; y recibí ese error: Uncaught …

9
¿Cómo verificar si un objeto es un objeto generador en Python?
En python, ¿cómo verifico si un objeto es un objeto generador? Intentando esto &gt;&gt;&gt; type(myobject, generator) da el error Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; NameError: name 'generator' is not defined (Sé que puedo verificar si el objeto tiene un nextmétodo para que sea un …
157 python  generator 

25
¿Cómo agregar un salto de línea en un Android TextView?
Estoy tratando de agregar un salto de línea en TextView. Intenté sugerido \ n pero eso no hace nada. Así es como configuro mis textos. TextView txtSubTitle = (TextView)findViewById(r.id.txtSubTitle); txtSubTitle.setText(Html.fromHtml(getResources().getString(R.string.sample_string))); Esta es mi cadena: &lt;string name="sample_string"&gt;some test line 1 \n some test line 2&lt;/string&gt; Debería mostrarse así: some test line …

21
¿Cómo reindexar una matriz en PHP?
Tengo la siguiente matriz, que me gustaría reindexar para que las teclas se inviertan (idealmente comenzando en 1): Matriz actual ( editar: la matriz en realidad se ve así): Array ( [2] =&gt; Object ( [title] =&gt; Section [linked] =&gt; 1 ) [1] =&gt; Object ( [title] =&gt; Sub-Section [linked] …
157 php  arrays  indexing 

11
redirección de http a https apache
Entorno Centos con apache Intentando configurar la redirección automática de http a https From manage.mydomain.com --- To ---&gt; https://manage.mydomain.com Intenté agregar lo siguiente a mi httpd.conf pero no funcionó RewriteEngine on ReWriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] ¿Algunas ideas?
157 linux  apache  webserver 


Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.