On a totally unrelated note…

Use arduino to check gmail !


Plop,

This is what I got :
A LED that lights up when I got unread mail in my INBOX on Gmail.

This is what you need :
- an arduino
- python 2.7.2
- python-pyserial 2.6
- something for output, a LED is good

This is how I did :

1. The arduino code :


int outPin = 9; // Output connected to digital pin 9
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port

void setup()
{
    pinMode(outPin, OUTPUT); // sets the digital pin as output
    Serial.begin(9600);
    Serial.flush();
}

void loop()
{
    // Read from serial port
    if (Serial.available())
    {
        val = Serial.read();
        Serial.println(val);
        if (val == '1') mail = HIGH;
        else if (val == '0') mail = LOW;
    }

    // Set the status of the output pin
    digitalWrite(outPin, mail);
}

2. The python code :


#!/usr/bin/python2
# Check new mail on gmail, pass it to arduino
import time, imaplib, re, serial, sys

SERIALPORT = "/dev/ttyACM0" # Change this to your serial port!

# Set up serial port
try:
    ser = serial.Serial(SERIALPORT, 9600)
except serial.SerialException:
    sys.exit()

conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
conn.login('username', 'YOURPASSWORD')
unreadCount = re.search("UNSEEN (\d+)", conn.status("INBOX", "(UNSEEN)")[1][0]).group(1)
# to avoid race
time.sleep(1)
# for debugging
#print unreadCount
# Output data to serial port
if unreadCount != '0':
    ser.write('1')
else:
    ser.write('0')
# Close serial port
ser.close()

3. Add a cronjob every minute :
$ crontab -e
*/1 * * * * python2 /path/to/script/checkmail.py >> /dev/null 2&>1

I added a resistance, otherwise it’s too much light !

ENJOY ! :D

IMDB + twitter + bash = WIN

Plop,

Il y a quelques semaines, un ami m’a donné une idée, et maintenant que je suis en vacances, j’ai pu la réaliser :D
L’idée, la voici : vu que je note sur IMDB chaque flim que je mate, pourquoi ne pas faire un fil twitter avec les notes des flims vus ?
Alors voilà, un peu de tapotage sous vim et PAF ! ça fait des chocapics \o/

C’est un script qui récupère le fichier .csv de mon compte IMDB, en extrait une ligne au hasard, et affiche le titre, le réalisateur, l’année et la note que j’ai donné.
Je tiens à préciser que je ne suis que peu objectif avec mes notes, donc merci de ne pas s’affoler si j’ai noté 8 un flim de merde.

Voici le script :

#!/bin/sh
# File : imdb-twit.sh
# URL : twitter.com/floodfr
# Author : kooothor
# Version : 0.2

# get latest file
wget "http://www.imdb.com/list/export?list_id=ratings&author_id=ur5851952" -O /tmp/imdbfull.csv -q
# remove first line
sed -i '1d' /tmp/imdbfull.csv
# extract random line
shuf -n 1 /tmp/imdbfull.csv > /tmp/imdb1line.txt

# get infos
title=`awk < /tmp/imdb1line.txt -F \" '{print $12}'`
real=`awk < /tmp/imdb1line.txt -F \" '{print $16}'`
note=`awk < /tmp/imdb1line.txt -F \" '{print $18}'`
year=`awk < /tmp/imdb1line.txt -F \" '{print $24}'`
url=`awk < /tmp/imdb1line.txt -F \" '{print $24}'`

# display and twit
echo "'$title' par $real ($year), noté $note/10. $url"|perl /home/kooothor/.scripts/ttytter.pl -script

# clean
rm /tmp/imdbfull.csv
rm /tmp/imdb1line.txt

On met tout ça en cron toutes les heures et voilà !
Sachant qu’il y a au jour d’aujourd’hui 1596 titres de films, j’me suis pas emmerdé à checker si le titre a déjà été display oopah… => osef

Follow @flood.fr

@+
~ktr

PS: ce que j’utilise pour twitter depuis la ligne de commande : ttytter

Flood.fr accessible en ipV6

L'ipV6 est déjà là !

Plop,
Flood.fr peut désormais être accedé en ipV6 \o/

L’adresse :

2a01:e0b:1:126:ca0a:a9ff:fec8:f2a1 à mettre entre []

Normalement, si vous avez pas un FAI trop pourri, vous n’avez rien à faire et vous êtes connecté en ipv6.
Checkez ici si vous êtes ipv6 capable :
http://ipv6-test.com/
Et utilisez le très bon plugin Flagfox pour voir si vous êtes connecté sur le site en ipV6.

Alors qui a gagné le jeu Minecraft ?

Plop,

Il y a quelques jours, j’ai proposé aux membres de la communauté du flood de gagner un jeu Minecraft.

Aujourd’hui, la version 1.8 du jeu est finalement sortie et il est temps de remettre son prix au gagnant.
Mais avant, il faut choisir un commentaire sur le blog au hasard !
Et pour que tout soit clair, voici le code que j’ai utilisé :

<?php
// get random emails from a blog post comments by kooothor@flood.fr
// connect to database
$con = mysql_connect("localhost","blog","correcthorsebatterystaple") or die('FUCK ' .mysql_error());
// select db
mysql_select_db("blog",$con);
// select all emails from post n°232
$sql = mysql_query("SELECT `comment_author_email`,`comment_author` FROM `wp_comments` WHERE `comment_post_ID` = 232 ") or die($sql. "\n".mysql_error());
// get the array
$row = mysql_fetch_array($sql);
// randomize
$rand = array_rand($row);
// display
echo 'Et le gagnant est : '. $row['comment_author']; ?>

Et quoi de mieux qu’une vidéo pour montrer que tout a été fait dans les règles de l’art ?
select-random-comment.avi (756 Ko)

Le gagnant est donc aZiatikaL cheers
Bravo à lui, je lui souhaite de longues heures de jeu (sur le serveur minecraft flood.fr bien sûr !).

@+
~ktr

NTFS Read Write on Snow Leopard

Hello,
You can have NTFS read write support in Snow Leopard without installing a software. The functionnality is here, but it’s hidden (fuck you Apple).
Use at your own risks :

Find out what is the UUID of the device/partition you want to mount :
$ diskutil info /Volumes/<volumename> |grep UUID
Edit the normally non-existing file /etc/fstab and add this line :
UUID=E4ADF86A-FCF9-4C88-9B55-12D2B9352015 none ntfs rw

Obviously your UUID won’t be the same.

Enjoy RW NTFS without installing anything !

@+
~ktr

Wikileaks :: désormais en miroir sur wikileaks.flood.fr

Plop,
wikileaks logo
J’ai décidé de franchir le pas et d’héberger un miroir du site Wikileaks sur un sous-domaine : wikileaks.flood.fr (quelle originalité, je sais.)

C’est une image du 29 Août 2011.
Étrangement, j’ai du rajouter moi-même le dossier “squelettes” avec les trois fichiers qu’il contient car il n’existait pas !!
L’archive peut être téléchargée ici.
Il faut le paquet p7zip-full pour l’extraire :

# aptitude install p7zip-full
# 7z x cablegate-20110829xxxxx.7z

ENJOY :D

Jeu :: Gagnez un exemplaire du jeu Minecraft !

Plop,

minecraft

A l’occasion de la sortie prochaine de la version 1.8 de Minecraft, Flood.fr offre à ses membres un exemplaire du jeu.

Pour participer, il faut :
- poster un commentaire sur ce billet.

Stoo.
Ensuite je prendrai un commentaire au hasard et PAF! ça fait des chocapics !

Minecraft est un jeu développé en Java qui peut donc tourner sous toutes les plateformes (Windows, Mac OS X, GNU/Linux, *BSD, etc…).
C’est un jeu vraiment addictif, très sympa à jouer, on peut jouer seul ou en ligne, on mine, on crafte, et on recommence. Je ne peux que recommander ce jeu !

Quelques liens relatifs au sujet :

Donc si vous voulez en gagner un, postez un commentaire avec votre email !
Le tirage au sort aura lieu le jour de la sortie de la version 1.8 (qui apporte plein de nouveautées).

@+
~ktr

Install rsslounge on your server

Plop,

Because Google can close your account/life at any moment, I decided to try and host as much service as I can on my flood.fr server. Today, I’ll show you how to install rsslounge, a free rss reader, in order to get rid of Google Reader.

The amount of profiling one can do with all my rss feeds would be great ! I want my feeds to be personnal now.

The website or readme file of rsslounge isn’t very verbose, so here is how to install it without pain on a Ubuntu server (can be installed on any GNU/Linux server, but you need to modify some commands accordingly).

# cd /var/www
# wget -O rsslounge.zip http://rsslounge.aditu.de/index/download
# unzip rsslounge.zip
# cd rsslounge
# chmod +r config data/cache data/favicons data/logs data/thumbnails public/javascript public/stylesheets
# chown -R www-data: .

Now go in your phpmyadmin and create one :

  1. Login as root
  2. Create a new database, name it rsslounge, with utf8_general_ci as encoding
  3. Now click on the database on the left, go in Privileges tab and click Add a new user
  4. Give him a name (rsslounge for instance), a complicated and long password, be sure that the radio button : Grant all privileges on database “rsslounge” is ON
  5. Click Go !

You know have a user with a password who has all privileges on a brand new SQL database.
Next, head your browser to yourdomain.com/rsslounge and install ! :D

Finally, we need a cron to update it.
$ crontab -e
Add this line to update every 30 minutes :
*/30 * * * * curl -s http://rsslounge_URL/update/silent/

Now we want to import all our GReader feeds. It’s easy.
Click here to export as an OPML file.
Now go in rsslounge, click on the top right icon that looks like gears, go to import, chose the file and that’s it ! :D

ENJOY not being tracked anymore by google on all your favorites websites !

Read emails from gmail in OpenBox menu

Hello,
I found a nice little script that works well to have gmail inside the Openbox menu ! oO
Here is what it looks like :
openbox python check gmail menu

And here is how to install it without any hassle :)
Download the tarball (GPL v2 license)
$ wget http://www.nakamura-gebiet.de/scripts/checkmail.tar.bz2
Install a needed dependency :
$ yaourt -S pyosd
Extract the tarball :
$ tar xvjf checkmail.tar.bz2
Edit the well commented configuration file :

$ $EDITOR checkmailrc
$ mv checkmailrc ~/.checkmailrc

Hey, your pass is in cleartext in here !
$ chmod 600 ~/.checkmailrc
$ mv checkmailrc.py.english ~/.scripts/checkgmail.py

Or anywhere else you would like you script to be located (author suggests ~/.config/openbox/scripts)
$ chmod +x ~/.scripts/checkmailrc.py
Now we add the line to the Openbox menu
$ $EDITOR ~/.config/openbox/menu.xml
Add this line where you want the gmail menu :
<menu id=”mails-menu” label=”Gmail” execute=”python2 ~/.scripts/checkmail.py”>
$ openbox –reconfigure

Now we need to get it updated as a cronjob :
$ crontab -e
Add this line to update every 10 minutes :
*/10 * * * * “export DISPLAY=O.0; python2 /path/to/script –refresh > /dev/null 2>&1″

Now open your openbox menu and enjoy your new quick and easy way to check your emails ! :D

Tested with openbox 3.4.11.2, python 2.7.2 on Archlinux 64bits.
(source of the script)