Sábado, 26 de febrero de 2011
Por alguna razón, este articulo viejo ha tenido algo de tráfico en los últimos días. Me dí cuenta que la idea de usar Java y JNI nunca se materializó, sólo dí unas pistas.
Una forma de hacer esto es llamando a la librería ‘magic’. Magic viene prácticamente en cualquier sistema operativo que se parezca a UNIX que se respete, como BSD, OSX y por supuesto Linux.
Si usted llama a la página man (man 3 libmagic) allí encontrará suficiente información. Por ejemplo, aquí les muestro un pequeño programa que hice en C el cual detecta el tipo de archivo que usted le pase por la línea de comandos:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| #include
#include
/*
* Program that shows how to use the magic library to figure out the type of a file
* @author Jose V Nunez (josevnz@kodegeek.com)
* License: BSD
*/
int main(int argc, char ** argv) {
if (argc == 1) {
printf("[ERROR]: Please provide the file name to check and try again!\n");
return 1;
}
// See manpage libmagic for details on what this flags mean
int flags = MAGIC_SYMLINK|MAGIC_COMPRESS|MAGIC_CONTINUE|MAGIC_PRESERVE_ATIME|MAGIC_ERROR;
magic_t cookie = magic_open(flags);
if (cookie == NULL) {
printf("There was a problem opening the magic library!\n");
return 1;
}
int status = magic_load(cookie, NULL);
if (status != 0) {
printf("Unable to load magic default database!, %s\n", magic_error(cookie));
magic_close(cookie);
return 1;
}
const char * file_details = magic_file(cookie, argv[1]);
printf("Type for file: %s is %s\n", argv[1], file_details);
magic_close(cookie);
return 0;
} |
Para compilarlo les dejo un archivo Makefile:
1
2
3
| CPPFLAGS += -O2 -L/Users/Shared/lib -I/Users/Shared/include -lmagic
all: magic.c
$(CC) $(CPPFLAGS) magic.c -o magic |
Y finalmente como se corre:
1
2
3
4
5
| auyan:c josevnz$ make
cc -O2 -L/Users/Shared/lib -I/Users/Shared/include -lmagic magic.c -o magic
auyan:c josevnz$ ./magic /Users/josevnz/CTX.DAT
Mime type for file: /Users/josevnz/CTX.DAT is Java serialization data, version 5
auyan:c josevnz$ |
En la siguiente entrada las prometo como hacer esto desde Java (pista, vamos a utilizar JNI).
–José
c, java, mime magic libmagic jni java, opensource, programación
c#, file, java, jni, libmagic, mime, mime type
Viernes, 25 de febrero de 2011
Otra forma de entrar al blog, ahora desde Facebook.
Rieguen la voz
internet, kodegeek
Domingo, 6 de febrero de 2011

Facebook, who is not talking something about the famous social website? With the population of a small country and even a movie with several nominations to the Oscar, you have to wonder if is not a good idea to at least to understand how deep is the interaction between their users and the marketers.
So, why I’m doing a review of a book obviously targeted to marketers and Facebook? There are several answers:
- It pays off to understand how users interact with the site and how this information is being used by marketers to contact you. That way you can protect yourself and be more selective to what you publish on the side
-
You are writing a social application and you want it to be popular. Some times developers are disconnected with the user needs and this book, believe it or not, can help to fill some gaps
But let’s focus about the book and what you will find inside (follow this link for the full table of contents).
The good:
The book is well organized, easy to read and with self contained chapters (so it can be later used as a reference material, skipping to the topics you want to re-check). There is a intuitive progression of what is Facebook, what are the main features that can be used to promote your content and finally how you can track your effort progress, all without leaving Facebook. Worth mention is than the authors promote ‘non-spamming’ marketing, respecting the users and instead trusting on your skills to promote your brand on the site (Like Seth Goding on his famous book).
The bad:
The authors mention the FML (Facebook markup language), applications that use the Facebook graph API and yet they don’t provide a single link on how to code those features; Many marketers (believe it or not) are hands-on with coding, and even if they are not they want to know more before hiring a programmer to do the implementation for them.
Conclusion:
It is an easy to read and well organized book. Also its small size makes it ideal to keep around the office bookshelf. Be aware than it is not a developer book, but developers still can learn one thing or two by reading it.
Kodegeek stars: 3 of 5.
internet, movies
facebook, marketing, social, web
Jueves, 3 de febrero de 2011

No hace falta tener super poderes para ser un héroe
Una omisión imperdonable en mi blog. Tengo el ejemplar #1 de Spider Girl en mi casa desde hace un mes al menos y no había escrito nada de ella. El concepto es original, una heroína sin super poderes pero que entrena duro para estar en forma, Hispana, y con una página de Twitter en donde la puedes seguir.
Estoy encantado con el concepto y espero ver más de esta heroína en el futuro.
comics
araña, comic, spider girl, twitter
Martes, 1 de febrero de 2011

El primero escrito del 2011. ¡Y nada mejor para romper el hielo que hablar de cómics!
La muerte de los super heroes es un asunto cíclico en el mundo de los cómics; En años recientes Superman, Batman, Capitan America, Colosus entre otros han muerto para luego revivir en toda su gloria. Y ahora en el 2011 le toca el turno a uno de los caracteres de los 4 fantásticos.
#587
No quiero revelar nada en el blog, pero antes de romper el plástico de mi historieta me atrevo a pensar que Sue Richards es la victima. ¿Usted quien cree que sea?
comics, kodegeek
4 fantasticos, comics, death, fantastic 4, Fantastic 4 #587, heroes, super heroes
Comentarios recientes