This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double getUnixTime() | |
{ | |
struct timespec tv; | |
if(clock_gettime(CLOCK_REALTIME, &tv) != 0) return 0; | |
return (((double) tv.tv_sec) + (double) (tv.tv_nsec / 1000000000.0)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* monitor | |
* Angel Rodolfo Pérez Canseco(ikcaro) | |
* Monitor de consumo de memoria, calculo de memoria basado en pmap | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# monitorea con top los procesos que cumplan con el patron de grep | |
top $(for i in $(ps -e | grep Db | awk {'print $1'}); do echo "-p"$i; done) | |
# ver el consumo de memoria de una lista de pids especificada por el patron de grep | |
for i in $(ps -e | grep Log| awk {'print $1'}); do echo $i; pmap -d $i | tail -n1 ; done | |
# copia un archivo estatus.txt a varias carpetas que cumplan el patro atm | |
for i in $(ls | grep atm); do cp estatus.txt $i; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* b64 | |
* Angel Rodolfo Pérez Canseco (ikcaro) | |
* Algoritmo para codificar datos en base 64 | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#define TBASE 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Weasel | |
* Angel Rodolfo Pérez Canseco(ikcaro) | |
* Algoritmo propuesto por Richard Dawkings en "El relojero ciego" | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#primero averiguamos cual es nuestro dispositivo bluetooth | |
hcitool dev | |
#lo que da como salida | |
# Devices: | |
# hci0 00:1C:26:DE:96:B6 #nombre del device y su mac | |
#ahora scaneamos en busca de dispositivos cercanos | |
hcitool -i hci0 scan | |
#esto nos dará una lista de dispositivos cercanos al nuestro | |
#con su nombre y su mac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//como revisar si un checkbox está activado en JQuery | |
//y obtener su valor | |
var v; | |
if( ( v = $("#id_del_elemento:checked").val() ) != null ){ | |
//hacer algo aquí | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#numero aleatorio | |
echo $RANDOM | |
#numero aleatorio [1-15] | |
echo $[ ($RANDOM % 15) + 1 ] | |
#numero aleatorio [15 - 25] | |
echo $[ ($RANDOM % 10) + 15 ] |