'programação' Category
-
ago092010
IP representation
Yesterday I came across with an interesting contruction for IP address. Suppose that you want store the address ‘192.168.10.33′ no matter the dot.
192<<24|168<<16|10<<8|33
That produces
3232238113 (0xc0a80a21)
To return is just get the address in hex format and split in 4 sections. Means that: c0 (192) a8 (168) 0a (10) 21 (33). An example using Python generators to [...] -
abr192010
Meu editor de texto: Vim
O vim é a um bom tempo meu principal editor para a programação. Além de utilizá-lo para todas as operações “básicas” de um editor de texto, vou apresentar rapidamente algumas coisas que fazem ele tão útil para mim.
1) Integração com o ctags Ctrl+] e Ctrl+t
Muito útil para projetos com vários arquivos onde é preciso navegar pela [...] -
mar312010
ack
Junto com o vim/ctags o ack é ferramenta que mais utilizo ultimamente. É um jeito rápido e eficiente para fazer buscas em arquivos texto. Para quem usa o grep -r vai achar útil.
http://betterthangrep.com/ -
mar272010
Download photos from Flickr!
I think that one problem regarding creating a script to download photos form Flickr is getting copyrighted material. Suppose that you want all photos from Itajubá city. You can use Flickr API or an YQL request, as follows:
select * from flickr.photos.search where text=”itajubá”
My first try to get license information was showing the pertinent part of [...] -
fev282010
Simple C macro for debugging
A little trick if you use printf to debug information in your code and don’t like to comment/uncomment.
#include <stdio.h>
#define dprintf if (debug) printf
const char debug = 1; /* or 0 if you want disable debug */
int main(int argc, char *argv[] ) {
dprintf ("debug message");
return [...] -
fev232010
Uploads de fotos no Flickr! usando API e Python
A API (Interface de Programação de Aplicativo) do Flickr! é bem documetada e rapidamente você pode fazer bastante coisa. Se você desejar usar a linguagem Python como método de acesso, em linhas gerais você precisa.
Criar uma chave na API do Flickr!
Download do binding para acesso a API (flickrapi)Nas distribuições Linux, um dos jeitos de instalar [...]
-
fev132010
Twitter @hashunifei
Sempre tive curiosidade de fazer um agregador para o Twitter, ou seja, criar um usuário que fizesse o retwitt de todos os termos que aparecem sobre determinada palavra. Para fazer um teste resolvi criar um usuário chamado @hashunifei que irá agregar o que pessoal escrever sobre a UNIFEI (Universidade Federal de Itajubá) incluindo o nome antigo [...]
-
jan282010
Byte Order
In the book about Linux Kernel Programming the author Robert Love demonstrated a trick to check your hardware endianness.
int x = 1;
if (*(char *)&x == 1)
/* little endian */
else
/* big endian */Using GCC you can use -mbig-endian or -mlittle-endian to generate appropriate endianess. Remember to check man pages section on your architecture (i.e: i386 and [...]