Comic for Cracked

I'm ul'ing this just to have a place to host the image :)



Once something awesome happened to me, I was downloading an album by torrent and I started listening to it at 50% of the total download. It was just l0L, because torrents download in "random" parts I listened to random parts of random length of random files non-stopping, and I loved it.

So I came up with this:

let R=$RANDOM%12000+1; let T=$RANDOM%2000+100; find "$1" -name "*mp3" -type f -print0 | xargs -0 mpg123 -C -Z -k $R -n $T

This one liner generates a random number between 1 and 12001 to use as the frame from which to start playing the other random number (between 100 and 2100) of frames from a random file in the directory specified by $1 (I use it in a script, to one-line it put the directory name directly there).

I love this shit, mainly because I listen to all kinds of shit: dnb, trance, brakcore, house, techno, minimal, alt-rock, psychedelic, goa, chillout, ambient, 8bit and noise; and randomixing between this stuff creates a fucking awesome effect.



I always hated flash, from the beginning, when it was just in some random adds.

But lately my computer has been kinda slow cause of a lot of programs that are now always open (nicotine+, transmisison, jdownloader) since I bought myself a Seagate 1TB hard disk, and when watching youtube form firefox it got reeeaaaallyyyyy slow, so I started to use ffplay from bash to play the flvs firefox downloads from youtube and places in /tmp/Flash*, but firefox alone used a lot of CPU and RAM.

So today I invented this:

wget -O - "$(youtube-dl -g $@)" | ffplay -

This simple looking commands uses youtube-dl script from Ubuntu repos to get the real URL of the youtube video, pass it to wget who downloads it and streams the flv to ffplay, who plays the video taking almost no CPU or RAM and even not writing the hard disk.

I putted it in a bash script (I know a function would have worked too) and now just typing a single command I get a youtube video in a small window with mplayer-alike control bindings.


Changing default window manager in GNOME

I hate GNOME, really, I can't stand it. But my GeForce2 MX400 doesn't stand KDE4, and she has the last word.

I discovered a few days ago that she likes Compiz, so I set it up for her. After it was al OK I wanted GNOME to know that the default window manager has changed, but the GNOME's System→Preferences→Appearance→Visual Effects tab is full of shit, and it doesn't do the right thing, so I googled a little, with no results.

So I decided to find out for my self, and after a lot of "find" and "grep" and "vim" I tried gconf-editor. I hate the gconf stuff, it doesn't makes any sense, it's like the windows registry but partially, I don't get it. But there it was, not in:
(possibly the most logical place), but in:

There it was, "widnowmanager". Just changed it and now GNOME doesn't starts metacity, but compiz instead.


Some really usefull Bash keyboard shortucts.

I have a lot of RSS feeds, and at least once a month I recive an "Usefull bash tips" news, but they are always the same !

Here are some of the best ones that I really use every time I write in Bash, they are like reflexes now xP.

A = Alt
C = Ctrl

C-w : cut backwards until a blank space, and put that in the buffer.
A-backspace : cut backwards until a word delimiter character (usually ",./?%&#:_=+@~"), and put that in the buffer.
A-d : the same but cut forwards.
C-y : paste buffer.
C-7 : undo (really, bash has undo and I never seen this anywhere).
C-left-arrow : jump backwards by word delimiters.
C-right-arrow : try to guess (this ones also work in graphical environments).
A-. : previous argument (the last command's rightmost blank-delimited characters)

This one is so useful I'll leave an example of use:
$ ls -sh Apps/Torrents/pr0n.avi
1.2GB pr0n.avi
$ rm (A-.)

that will insert "Apps/Torrents/pr0n.avi" and when entering will try to remove it, hopefully pr0n.avi is read-write protected ...


Highlight text from a command's stdout

It happened to me many times. For example when reading the output of tcpdum and wanting to look at an especific IP but without cutting the context I used to do "| grep --color=auto -C 10 IP".
Or when reading the output of strace and looking for a written file the context is important, so I came up with this:

highlight (){
    if [ -n "$1" ] ; then
        sed "s/$1/\x1b[32;1m&\x1b[1;0m/g" /dev/stdin
        echo "ERROR: What words to highlight?"


Just write it in your .basrc.

For example:
cat .xsession-errors | highlight gnome-panel
Will highlight only "gnome-panel" in green, leaving the output intact.

Some Vista fun...



This is a personal proyect I did like a month ago and never realized how good it was.

Here is the Window class, and here is the actuall program.

It is a Shoutcast playlist downloader, it connects to the Shoutcast server and downloads the Top500 radios, and when double-clicking it opens them in mocp (the greatest music player). To make it open them in another player changing the variables WON'T work, they are just decorative xP.


Zomb pelo blog.


Aca esta el blog de mi amigo hacker de hardware.
Me cago la entrada que iba a hacer sobre el PIC, sacamos las fotos y en vez de pasarmelas me las anti-hurtó (el celular es de él).


Feria 2008: Shooter/Mover mouse con la mano.

Para la feria de ciencias d la EET nº9 de Lanus del 2008 yo,pereira y britez teniamos algo en la mente: Un jueguito donde le disparas a unos logos de WindowsXP con una pistola de jugete a un monitor/pantalla de proyector.

El proyector teniamos (prestaba profesor), la pistola de juegete y la webcam las aporte yo.

La idea constaba de poner un led infrarojo arriba del monitor y una webcam atada a la pistola y hackeada para que no filtre los rayos infrarojos, pero filtrando todos los demas con el material de los diskettes (la cosa gris/negra/marron) y que mande una foto a una PC que detectaria la posicion del punto mas brillante (led infrarojo) y calcularia la posicion XY donde se esta apuntando.

El programa era una mezcla rara de C con opencv (libreria analizadora de imagenes) y bash.


#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>

int main(int argc, char *argv[])
  IplImage* img = 0;
  int height,width,step,channels;
  uchar *data;
  int i,j,k;

    printf("Usage: main <image-file-name>\n\7");

  // load an image  
    printf("Could not load image file: %s\n",argv[1]);

  // get the image data
  height    = img->height;
  width     = img->width;
  step      = img->widthStep;
  channels  = img->nChannels;
  data      = (uchar *)img->imageData;
  printf("Processing a %dx%d image with %d channels\n",height,width,channels);

  // create a window
  //cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
  //cvMoveWindow("mainWin", 100, 100);

  // invert the image
  //for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
  //  data[i*step+j*channels+k]=255-data[i*step+j*channels+k];

  //IplImage* img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1);
  for (int x=0;x<width;x+=10) {
  for (int y=0;y<height;y+=10){
    CvScalar s;
    s=cvGet2D(img,y,x); // get the (i,j) pixel value
    printf("%f %i %i\n",s.val[0],x,y);

  // show the image
  //cvShowImage("mainWin", img );

  // wait for a key

  // release the image
  cvReleaseImage(&img );
  return 0;



XY=($(./laopncv tmp.jpg | sort -r -n | head -n 1 | awk '{printf("%i %i",$2*3.41,$3*3.41)}'))
echo "mousemove ${XY[0]} ${XY[1]}" | xte


El C esta practicamente robado de los ejemplos que vienen con la libreria, lo que hace es agarrar una foto y detectar el punto mas "brillante" (creo, yo en realidad fui cambiando el 0 en s.val: printf("%f %i %i\n",s.val[0],x,y);) hasta que me dio mas o menos lo que esperaba)

La documentacion daba asco, lo que encontramos era poco y dificil de entender, casi sin ejemplos simples.

La cosa esta andaba bastante bien, pero algo fallab enormemente: para adquirir la foto probamos cientos de comandos, tecnicas y programas, y todos tardaban mas de 1 segundo (lo que es excesivo siendo un jugeito de disparar que tenga un lag de mas de 1 segundo).

Capaz era el driver, capaz era la webcam, capaz mi kernel, nadie supo; pero el proyecto quedo ahi, ademas nadie tenia ganas de ensamblarlo(pereira = C, britez = PHP, alvare = Python, nadie sabia ni queria).

No solo eso sino que ademas si la persona era mas baja o se paraba mas cerca y al costado ya el mouse se movia para cualquier lado.

Bueno eso quedo en la nada, hace unos dias britez me viene mostrando progresos con una libreria llamada "touchlib" que encima es multitouch, con una caja y un vidrio (absurdamente simple comparado con nuestro pandemonium).

Dejo el codigo ahi, si cualquiera quiero robarlo, invitado sea.