Esta funcion nos convierte el objeto de tipo Date a tipo String. Espero les haya resultado de utilidad!
seen from Kazakhstan

seen from Malaysia
seen from United States
seen from United Kingdom
seen from Kazakhstan

seen from Malaysia

seen from Malaysia

seen from Malaysia
seen from Kazakhstan

seen from United Kingdom

seen from United Kingdom

seen from Malaysia

seen from United States
seen from China

seen from China

seen from Malaysia
seen from China

seen from Malaysia

seen from Indonesia
seen from Malaysia
Esta funcion nos convierte el objeto de tipo Date a tipo String. Espero les haya resultado de utilidad!
Serializar y deserializar un objeto almacenado en un fichero en Java
Clase Persona
public class Persona implements java.io.Serializable { String nombre; public Persona(String parametro) { nombre = parametro; } @Override public String toString() { return "Nombre: " + nombre; } }
Serializar
import java.io.*; public class Serializar { public static void main(String[] args) { try { FileOutputStream fos = new…
View On WordPress
Mostrar un mensaje si se ha ejecutado correctamente un script de PowerShell desde C#
Mostrar un mensaje si se ha ejecutado correctamente un script de PowerShell desde C#
using System; using System.Collections.ObjectModel; using System.Management.Automation; // Windows PowerShell namespace. namespace PowerSh { class PowerSh { static void Main(string[] args) { using (PowerShell PowerShellInstance = PowerShell.Create()) { // use "AddScript" to add the contents of a script file to the end of the execution pipeline. // use "AddCommand" to add individual…
View On WordPress
Listar el nombre los días de la semana en PowerShell
Listar el nombre los días de la semana en PowerShell
#Opción 1 (New-Object System.Globalization.DateTimeFormatInfo).DayNames #Opción 2 1..7 | % {(Get-Date).AddDays($_).ToString("dddd")}
View On WordPress
Function toString in JavaScript
All objects in JavaScript have a default toString property function that is called whenever an object is converted to a String. Since objects are functions that means they have them too. Specifically, Function.toString prints out the contents of the function. This can be very useful for quickly seeing what a function does that you did not create:
var libraryObject = { libraryFunction: function() { console.log('Calling a libary function'); } }; console.log(libraryObject.libraryFunction + ''); // Same as console.log(libraryObject.libraryFunction.toString()); // function () { // console.log('Calling a libary function'); // }
But keep in mind it does not show the internals of any native function:
console.log('test'.toLowerCase + ''); // function toLowerCase() { [native code] }
This is because the native code is usually implemented in a language other than JavaScript (usally C++) for performance reasons.
This tactic can actually be taken further. Firstly, since functions are objects, they can be instantiated just like any other object. So if you want to quickly see what would happen if the function did something slightly different you can regenerate that function that you did not create with new code:
library.aFunction(); // Calling a library function var newFunctionality = library.aFunction.toString().replace('console.log', 'return'); newFunctionality = 'return (' + newFunctionality + ')();'; library.aFunction = new Function(newFunctionality); console.log(library.aFunction()); // Calling a library function
Keep in mind the last argument of new Function takes a function body not a full function, so the old function was just wrapped to make it self executable and returned. Alternatively, the toStringed function could have the function syntax removed, but that is platform independent.
It is great that JS gives you this flexibility, but this kind of thing usually makes code very hard to follow. So it is best to only use it while doing anything non permanent like debugging.
Github Location: https://github.com/Jacob-Friesen/obscurejs/blob/master/2016/functionToString.js
Solution: Why is a round-trip conversion via a string not safe for a double? #programming #dev #answer
Solution: Why is a round-trip conversion via a string not safe for a double? #programming #dev #answer
Why is a round-trip conversion via a string not safe for a double?
Recently I have had to serialize a double into text, and then get it back. The value seems to not be equivalent:
double d1 = 0.84551240822557006; string s = d1.ToString("R"); double d2 = double.Parse(s); bool s1 = d1 == d2; // -> s1 is False
But according to MSDN: Standard Numeric Format Strings, the “R” option is supposed to…
View On WordPress
How to: Java: How to get the unique ID of an object which overrides hashCode()?
How to: Java: How to get the unique ID of an object which overrides hashCode()?
Java: How to get the unique ID of an object which overrides hashCode()?
When a class in Java doesn’t override hashCode(), printing an instance of this class gives a nice unique number.
The Javadoc of Object says about hashCode():
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects.
But when the class overrides hashC…
View On WordPress
How to: What is the Objective-C equivalent for "toString()", for use with NSLog?
How to: What is the Objective-C equivalent for "toString()", for use with NSLog?
What is the Objective-C equivalent for "toString()", for use with NSLog?
Is there a method that I can override in my custom classes so that when
NSLog(@"%@", myObject)
is called, it will print the fields (or whatever I deem important) of my object? I guess I’m looking for the Objective-C equivalent of Java’s toString().
Answer: What is the Objective-C equivalent for "toString()", for use with…
View On WordPress