Calculator using AJAX with JQuery
Download here: Calculator AJAX
First, start listener and the database.
# lsnrctl start
# sqlplus / as sysdba
SQL> startup
After that, we will execute the following command to delete the actual (if you have) repository:
# emca -deconfig dbcontrol db -repos drop
Many times I have seen the need to replace text with VIM. Here I leave the way to do.
First, we open the file to edit:
vim file
We press ESC and insert colon “:”. After that, we insert the instruction:
:1,$ s/search_text/replacement_text/g
The characters 1,$ indicate that should search from the first to the last line of the file. After, just replace “search_text” and “replacement_text” for that we need.
Connection to MySQL using PDO library.
CREATE TABLE `paciente` (
`paciente_rut` varchar(12) NOT NULL,
`paciente_nombre` varchar(100) NOT NULL,
`paciente_apellidop` varchar(100) NOT NULL,
`paciente_apellidom` varchar(100) default NULL,
`paciente_fono` varchar(50) default NULL,
`paciente_direccion` varchar(255) NOT NULL,
PRIMARY KEY (`paciente_rut`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `paciente` VALUES ('11111111-1', 'Pedro', 'Fuentes', 'García', NULL, 'Santiago');
INSERT INTO `paciente` VALUES ('22222222-2', 'Juan', 'Santana', 'Bustos', NULL, 'Santiago');
INSERT INTO `paciente` VALUES ('33333333-3', 'Carolina', 'Soto', 'Barra', NULL, 'Santiago');
Method to crypt with SHA1
///
/// Crypt the string with SHA1
///
public static string EncriptarSHA1(string sCadena)
{
System.Security.Cryptography.SHA1 sha1 = System.Security.Cryptography.SHA1Managed.Create();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] stream = null;
StringBuilder codificada = new StringBuilder();
stream = sha1.ComputeHash(encoding.GetBytes(sCadena));
for (int i = 0; i < stream.Length; i++) codificada.AppendFormat("{0:x2}", stream[i]);
return codificada.ToString();
}
Using SPL to work with an array.
/* Arreglo */
$personas = array("Carlos", "Carolina", "José",
"Manuel", "Sandra");
try
{
/* Creamos el objeto SPL */
$arrayObjSPL = new ArrayObject($personas);
/* Modificamos el elemento 4 */
$arrayObjSPL->offsetSet(4, "Claudia");
/* Eliminamos el elemento 2 */
$arrayObjSPL->offsetUnset(2);
/* Iteramos sobre el arreglo con el objeto SPL */
for($iterator = $arrayObjSPL->getIterator(); $iterator->valid(); $iterator->next())
{
/* Mostramos el elemento */
echo $iterator->key() . " -> " . $iterator->current() . "
";
}
}
catch (Exception $e)
{
echo $e->getMessage();
}
Visual Basic IsNumeric method for C#.
/// Check if obj is numeric
public static bool IsNumeric(object obj)
{
double retNum;
bool isNum = Double.TryParse(Convert.ToString(obj),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInfo,
out retNum);
return isNum;
}
This tutorial was created for the instalation of OpenLdap in Linux RedHat.
For make the instalation of the server we execute:
yum install openldap-servers.i386
With this function you can send mails using mailx command.
#!/bin/sh
send_email()
{
#
# Proceso de parámetros
#
DIRECCION="$1"
ASUNTO=""
MENSAJE=""
if [ $# -ge 2 ]; then
if [ "$2" != "-" ]; then
ASUNTO="$2"
fi
fi
if [ $# -ge 3 ]; then
if [ "$3" != "-" ]; then
MENSAJE="$3"
fi
fi
ADJUNTO=""
if [ $# -ge 4 ]; then
if [ "$4" != "-" ]; then
ADJUNTO="$4"
fi
fi
#
# Envío del email
#
( echo "$MENSAJE";
if [ "$ADJUNTO" != "" ]; then
archivo=`echo $ADJUNTO|cut -d'~' -f1`
nombre=`echo $ADJUNTO|cut -d'~' -f2`
if [[ "$archivo" == "$nombre" || "$nombre" == "" ]]; then
nombre=`basename $archivo`
fi
if [ -f "$archivo" ]; then
uuencode "$archivo" "$nombre";
fi
fi;
) | mailx -s "$ASUNTO" "$DIRECCION"
}
send_email "yourmail@yourdomain.com" "Subject" "Message body" "attachment.txt"
Welcome!
In this blog I will share with you my experiences on different tools that I have worked, as well as developments and personal studies.
All content is free to access and you can be used without restrictions. Check the Terms of Use
Regards
Juan Garcés Bustamante