Archive

Archive for July, 2013

Bebiko Junior competition (bebiklub.pl)

16/07/2013 Leave a comment

Friend of mine participate in competition on bebiklub.pl – just a simple vote system. Unfortunately I can’t see on which place she is, there is no such a functionality, so I need to implement it by myself. As usual I choice php for that:

<?php
for($z=0;$z<=2960;$z=$z+10){
$url='https://www.bebiklub.pl/home/nowe-bebiko-junior/odpowiedzi-konkursowe/?start='.$z;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$in = curl_exec($ch);
curl_close($ch);

preg_match_all('/data-votes="(.*)" data-name="(.*)" data-id/i', $in, $out);
$k=count($out[1]);
for($i=0;$i<=$k-1;$i++){
        echo $out[2][$i].';';
        echo $out[1][$i]."\n";
}
}
?>

It will output a list of nicknames and votes in format:
nick;number_of_votes
Afterwards that output can be imported to excel and sorted.

Btw. Don’t forget to vote!

Advertisements
Categories: Bash

Backup remote server using tar and ssh

13/07/2013 1 comment
ssh user@server "sudo tar cvzp - / --same-owner --exclude=/proc/* --exclude=/media/* --exclude=/dev/* --exclude=/mnt/* --exclude=/sys/* --exclude=/tmp/* --ignore-failed-read" > backup.tgz

user should have sudo rights without password on remote machine.

Categories: Linux, Useful commands