sábado, 30 de janeiro de 2010

Firefox Mobile 1.0

Firefox Mobile, the mobile browser developed by Mozilla based on the same engine as in the recently released Firefox 3.6, has finally hit version 1.0. The first device who became with this software is the Nokia N900.
Because their long list of features, looks the most complete mobile browser:
  • The familiar Awesome Bar;
  • Weave Sync for sharing your browser state between your PC and mobile;
  • tabbed browsing and Firefox add-ons. 
With the Nokia 900 and Firefox Mobile 1.0, even Flash content including the normal YouTube site is working, showing that a mobile browser does not have to equal a compromised Internet experience.

sexta-feira, 29 de janeiro de 2010

Convert packages files with Alien

If you have an rpm file for a package you wish to install, and if you cannot find a .deb debian package , you can use the alien package converter application.

Alien is a program that converts various package formates. Like rpm, dpkg, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien.
But attention Alien should not be used to replace important system packages. In general, if you can’t uninstall the package without breaking your system, don’t try to replace it with an alien version.

Installing Alien:
$sudo apt-get install alien 

Example, conversion of a RPM file into DEB:
$sudo alien -k name_of_rpm_file.rpm  
  • The option -k will keep the version number of RPM file.
  • You can see more option on the Alien manual.



To get an entire web site

In Linux is simple to get an entire web site without install any program:

$wget -r http://Site_that_you_want


IPTables setting up a simple Linux Firewall

So this is a simple script that you can modify and adapt at you like:

#! /bin/sh
echo "\n\nSETTING UP IPTABLES FIREWALL..."

echo "    Loading firewall server rules..."
UNIVERSE="0.0.0.0/0"

# Clear any existing rules and setting default policy to DROP

iptables -P INPUT DROP
iptables -F INPUT
iptables -P OUTPUT DROP
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD



# Flush the user chain.. if it exists
if [ "`iptables -L | grep LOG_AND_DROP`" ]; then
   iptables -F LOG_AND_DROP
fi

# Delete all User-specified chains
iptables -X

# Reset all IPTABLES counters
iptables -Z

# Creating a DROP chain
iptables -N LOG_AND_DROP
iptables -A LOG_AND_DROP -j LOG --log-prefix "atack happens------->"
iptables -A LOG_AND_DROP -j REJECT --reject-with icmp-host-unreachable

echo  "     - Loading INPUT rulesets"

#######################################################################
# INPUT: Incoming traffic from various interfaces.  All rulesets are
#        already flushed and set to a default policy of DROP.
#

# loopback interfaces are valid.
#iptables -A INPUT -i lo -s $UNIVERSE -d $UNIVERSE -j ACCEPT

# remote interface, claiming to be local machines, IP spoofing, get lost
iptables -A INPUT -s 192.168.0.0/24 -j LOG_AND_DROP
iptables -A INPUT -s 127.0.0.0/8 -j LOG_AND_DROP
iptables -A INPUT -s 200.200.200.200 -j LOG_AND_DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j LOG_AND_DROP
iptables -A INPUT  -p ip -f  -j LOG_AND_DROP
iptables -A INPUT  -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j LOG_AND_DROP
iptables -A INPUT  -m state -p icmp --state INVALID -j LOG_AND_DROP



# Allow any related traffic coming back to the MASQ server in
iptables -A INPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo  -s 200.200.200.200 -j ACCEPT
iptables -A INPUT -i lo  -s 127.0.0.1 -j ACCEPT




# Catch all rule, all other incoming is denied and logged.
iptables -A INPUT -s $UNIVERSE -d $UNIVERSE -j LOG_AND_DROP


echo  "     - Loading OUTPUT rulesets"

#######################################################################
# OUTPUT: Outgoing traffic from various interfaces.  All rulesets are
#         already flushed and set to a default policy of DROP.
#

iptables -A OUTPUT -o lo  -d 200.200.200.200 -j ACCEPT
iptables -A OUTPUT -o lo  -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT  -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state NEW -j ACCEPT


echo  "     - Loading FORWARD rulesets"

#######################################################################
# FORWARD: Enable Forwarding and thus IPMASQ
#          Allow all connections OUT and only existing/related IN

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD  -s 192.168.0.0/24 -m state --state NEW -j ACCEPT

# Catch all rule, all other forwarding is denied and logged.
iptables -A FORWARD -j LOG_AND_DROP

echo "    Firewall server rule loading complete\n\n"


Download Books from Google to see offline

First you need to put the Google Book URL in this site.(All download instructions are in that site).

After you have all jpg files corresponding to pages of the book in your Linux computer you need to convert this files to PDF. You can run this script on your directory that contains all JPG files:
#!/bin/bash
declare -a ARRAY
ARRAY=$(ls | grep .jpg | grep -v .pdf)

for i in $ARRAY; do
    mv "$i" "$i.pdf"
done
After you have all files in PDF extension you can use this command to join all PDF files:

$pdfjoin --outfile NAME.pdf *.pdf



You can install pdfjoin typing:
$sudo apt-get install pdfjoin

Enjoy ;-)

Shell Script that randomly change image on Linux Desktop

Use this script to randomly display a different image every x seconds. All the images on a given directory are chosen. An image will be chosen at random and displayed each time by the script.

Usage:
You pass to program the images directory that you wants and the interval time
$ ./change_wallpaper.sh "/home/USER_DIRECTORY/Pictures/" "60"

#código
#!/bin/bash
#Program made by
##António L. R. Mendes
function setPaper(){
    declare -a ARRAY
    PATH_IMG=$1
    TIME=$2
    ARRAY=$(ls $PATH_IMG | grep [jpg][png] | sort -R)
       
    for i in $ARRAY; do
        gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$PATH_IMG/$i"
        sleep $TIME
    done
   
    setPaper $PATH_IMG $TIME

}



#we can config:
# $1 - path to the images
# $2 - time to change
PATH_IMG=$1
TIME=$2
if [ ! -d "$PATH_IMG" ]; then
    echo "The directory $PATH_IMG is not a valid directory."
    exit
fi

if [ ! $TIME -gt 0 ]; then
    echo "The time introduced is not valid so the default value is 60 sec."
    $TIME=60
fi


echo "Program will change images in $PATH_IMG every $TIME seconds."
setPaper $PATH_IMG $TIME