python socket

another quick howto, shoot-then-ask type.

i needed to send automagic answers using a telnet connection to my VoD server in order to achieve a little less shocking home Vod experience for news users, beta testers, friends.

The code can by optimized, and needs handling error exceptions.

By some obscure reason, indentation is not working. I;m sorry for this.


import sys
from telnetlib import Telnet
from time import sleep

############################
## INSTALL this in your PC #
############################

#set up your own data, see the setupify.sh script
#for additional info
serverHost = '192.168.0.13'
serverPort = 4212 #you shouldn't need the change this
serverPassword = 'videolan' + '\r\n'
serverDown = 'shutdown' + '\r\n'
serverLoad = 'load /home/<your_user>/vod-setup' + '\r\n'
data = True #don't you dare...

vlc = Telnet( serverHost, serverPort )
sleep(3) #some sleeps are made only for waisting your time
print vlc.read_very_eager()
sleep(1) #some sleeps are made to wait for the server (fine tuning)
print vlc.read_very_eager()
vlc.write(serverPassword)
sleep(1)
print vlc.read_very_eager()
print "type x to exit, l to load setup file"
while data != "x":
    data=raw_input('send to vlc: ')
    if data == 'x':
        try:
            vlc.write(serverDown)
            sleep(2)
            print vlc.read_very_eager()
            exit()
        except EOFError:
            print "connection to VoD server closed by user\nBye!"
    elif data == 'l':
        vlc.write(serverLoad)
    else:
        instruction= data + "\r\n"
        vlc.write(instruction)
        sleep(1)
        print vlc.read_very_eager()

the OSes

why pay for something that is too complicated and will finally not work?
why buying French cars?
why buying Chinese tools? (In previous both cases I’m talking ’bout the cheap ones)
why hiring Chilean workers?
None of this will work, and it is usually a little bit more expensive that it was calculated.

Then, that’s when you decide to go for the big American expensive, energy eager, top hardware, obsolete technology muscle car that will run flawlessly for 30 years unless you forgot fueling it (every Wednesday).
Why buying an American OS that is crap? And expensive! and that will run flawless until you turn on your computer.
For almost the same money you can by a true OS that is as sexy as an OS can be, and it works, and it’s American too.
If all of this is too expensive, instead installing pirate Windows copies, tell you geek friends to install Linux (there is an aberration called Ubuntu (Ooh-boohn- tooh) that works out of the box, you can even choose you desktop environment painlessly.
so, why?
because everybody else does?

#!/bin/bash

I love the quick and dirty concept when you apply it over solid foundations.
This brings me to the magic world of bash scripts.

Just to warm up things, to break the ice and offer you a coffee,
here’s one of my favorite one:


for i in $( ls *.{mp3,avi,mov,flv,ogg})
do echo "media file: $i"
done

This will show al the mp3, avi, mov, flv, ogg files in the current directory

the p.bass

Music that’s not relevant, old Brit bands that no one listens to. Canadian bands that were not a commercial success. Talented and misunderstood musics, particularly the discrete ones, playing the discrete instrument, the underlying force under the volcano. This is my tribute to all bassist that made it.

vert_p-bass

images in a report

Today I found (for the second time in my life) a LaTeX package that allows to handle images in common formats as jpg or png. I’m talking about graphicx.

The prepare a delicious salad, do the following:

  • Start using you favorite TeX editor (Texmaker, Kile, vi)
  • Choose you favorite packages
  • Add \usepackage[pdftex]{graphicx}

Then once all is mixed thoroughly :

  • \includegraphics[scale=0.5]{image.png}

Of course, it is up to you to set the image name and scale. This package has lots of option which you will find if you google.

Here’s the code, you need an image named LaTeX_logo.png or adapt the code.

\documentclass[12pt]{report}
\usepackage[pdftex]{graphicx}
\title{\LaTeX}
\date{}

\begin{document}

\maketitle{}

\LaTeX can be easily used to insert images and to manage size, rotation, effects.

\begin{itemize}

\item image \includegraphics[scale=0.3]{LaTeX_logo.png}
\item small image \includegraphics[scale=0.1]{LaTeX_logo.png}
\item rotated image \includegraphics[angle=45, scale=0.1]{LaTeX_logo.png}
\item effect \reflectbox{\includegraphics[scale=1, scale=0.1]{LaTeX_logo.png}}

\end{itemize}
\end{document}

Here you can donwload the pdf generated basic.pdf

fin swimming

since October I’ve been swimming using fins. Same pool, same people, but now I’m focusing in underwater techniques, apnea and the use of a pair of fins. I would really like if some physics genius ever falls on this site a corrects me, but if I can go THAT faster underwater, this means that my muscles are using much more energy than when I swim without fins.

fin/aleta
fin/aleta

apache2 password protected directories

.htaccess example file:


AuthType Basic
AuthName "password required"
AuthUserFile /home/tatico/magicword
Require user files
AuthType Basic
AuthName "password required"
AuthUserFile /home/user/magic_word
Require user files

then, a little leap back in time and you will create the magic_word file

htpasswd -c /home/user/magic_word files
where the arguments are the path and the user “files”

have a nice day 😀

arduino

I consider myself a fan of the arduino board. I’ve been playing around for about a year and I have found only satisfaction from this very serious toy.

Now I’m working with PWM, to goal is to control the acceleration of a RC car, to avoid rear wheel spinning when accelerating.

I will post the PWM code soon (which is -obviously- copy/pasted from the excellent arduino docs) and the electronics needed.

upgrading wordpress

i went to /usr/share/

wget http://wordpress.org/latest.tar.gz

mv wordpress wordpress-old

tar -zxvf latest.tar.gz

then I went to ride my favorite browser, and run the setup

at last I copied from wp-contents/themes/ my favorite theme to the fresh install

😉

this is just a draft of my work