Thursday, December 20, 2012


sudo pear upgrade pear
Install PHPUnit Dependencies

Now, we can install PHPUnit and it’s dependencies through PEAR.

$ sudo pear channel-discover
$ sudo pear channel-discover
$ sudo pear channel-discover
$ sudo pear install --alldeps phpunit/PHPUnit
Make Sure It Works

After everything is complete, verify that phpunit works:

$ phpunit --version
PHPUnit 3.5.5 by Sebastian Bergmann.

Sunday, December 02, 2012

Installing VirtualBox Guest Additions on Ubuntu Server

sudo mount /dev/cdrom /media/
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
sudo /media/
sudo mount -t vboxsf ShareName /var/www/sharename

Monday, November 26, 2012

Friday, October 12, 2012

NTP Observatório Astronómico de Lisboa (oal)

sudo apt-get install ntp

And for ntpd edit /etc/ntp.conf to include additional server lines:


Monday, August 20, 2012

Mars Landing Special: Aug 5th 10PM PDT

Mars Landing Special: Aug 5th 10PM PDT:

Think space exploration ended with the space shuttle? Come with us to Mars!

On August 5th at 10 PM Pacific/1 AM Eastern, Jonathan Strickland ( and I will bring you an hour of coverage of the Curiosity Rover's crazy attempt to land on Mars via a sky crane.

We'll have reports from expert guests, like Dr. Kiki (who I hear will be inside Ames!) and the Bad Astronomer, Phil Plait. We'll hear from Steve Sell, JPL Entry/Descent/Landing team member and Sky Crane specialist, about why this whole thing isn't as crazy as it sounds, how it's going to work, and the tech they'll use to make it happen.

The Scoop

On Sunday August 5th at 1:31 AM eastern time/10:31 PM Pacific NASA expects to receive the first signals from the Mars Curiosity Rover on the surface of Mars. The Mars Science Laboratory Mission will explore terrain at the foot of a mountain of sedimentary material inside Gale crater. It's looking for evidence of microbial life.

NASA is attempting the most complex remote landing sequence ever attempted, involving a parachute and a sky crane. It takes 14 minutes for signals to travel from Mars to Earth. From the top of the atmosphere to landing, the descent will take 7 minutes. From the time the first signal arrives on Earth that descent has begun, the Curiosity Rover will have been on the surface of Mars for at least seven minutes, crashed or not.

If you haven't watched "Seven minutes of terror" yet, by all means do so. The landing logistics are insane.

One to One Million - Numberphile

Tuesday, August 14, 2012

Controlling the Web

Controlling the Web: Controlling the WebThis documentary looks at the fight for control of the web, life in the digital age and the threat to cyber freedom, asking if US authorities are increasingly trying to regulate user freedoms in the name of national and economic security. In January 2012, two controversial pieces
Watch now...

Monday, July 02, 2012

Share a folder from ubuntu server with virtualbox

 Add a existing user to existing group

# usermod -a -G vboxsf pedro
# id pedro

sudo mount -t vboxsf kits /var/www/site

Even better...

In the “Shared Folders” screen, give full access, but don’t check auto-mount
Check your uid&gid (by doing >id)
Add the following line /etc/fstab

site   /var/www/site  vboxsf  uid=1000,gid=1000,nodev,noexec,nosuid,auto,rw 0 0

Sunday, May 20, 2012

Auto login xubuntu

Autologin - Xubuntu To enable autologin in Xubuntu:
Open the file /etc/lightdm/lightdm.conf

sudo gedit /etc/lightdm/lightdm.conf

Modify the value of the string "autologin-user" with the required user name

Save the file Reboot/ restart

Friday, April 13, 2012

speed up ubuntu

sudo sublime-text /etc/fstab

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noatime,noexec,nosuid 0       0
# / was on /dev/sda6 during installation
UUID=3ae1a70e-2ac6-46c1-a135-b981eeb76221 /               ext4    errors=remount-ro,noatime 0       1
# swap was on /dev/sda5 during installation
UUID=bf903d3c-d9cf-4807-a9bd-e71c329275aa none            swap    sw              0       0

# Move /tmp to RAM
tmpfs /tmp                     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/cache             tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/run                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/lock                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/log                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/tmp                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/mail                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/log                 tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /run                     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0

tmpfs /var/spool/anacron     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/spool/cron         tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/spool/cups         tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/spool/mail         tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/spool/plymouth     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0
tmpfs /var/spool/rsyslog     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0

tmpfs /var/www     tmpfs defaults,auto,noatime,nodiratime,nodev,nosuid,async 0 0

sudo sublime-text /etc/sysctl.conf
fs.inotify.max_user_watches =2097152

After modifying the file should run
sudo sysctl -p


Type about:config in firefox address bar and click I'll be careful,I promise!.Right click on blank area and create a new string value called ,set its value to

  • Type about:config into the address bar
  • Type browser.cache into the Filter field
  • Set browser.cache.memory.enable to true (double click it)

  • browser.sessionhistory.max_entries 50 -> 5
  • gfx.color_management.mode ->1
  • gfx.color_management.rendering_intent -> -1 
  • browser.display.auto_quality_min_font_size -> 6 
  • browser.cache.disk.metadata_memory_limit -> 1024
  • browser.cache.disk.preload_chunk_count ->8

  • Get rid of application with high I/O usage
    To move the cache in Firefox, in the browser type ‘about:config’,
    right-click anywhere and select
    New –> String,
    for a super-fast memory cache

    Close all Firefox tabs and windows, and then restart the browser

    compact firefox DB's:

    for f in ~/.mozilla/firefox/*/*.sqlite; do sqlite3 $f 'VACUUM;'; done
    for chrome edit the icon lanch command:
    default command: /opt/google/chrome/google-chrome %U

    /opt/google/chrome/google-chrome %U --enabled --enable-http-pipelining --enable-smooth-scrolling --enable-threaded-compositing  --enable-accelerated-filters --disk-cache-dir='/tmp/chrome/' --disk-cache-size=1073741824

    In firefox:

    Monday, March 12, 2012

    Clock settings in gnome like windows

    To see all the options: man date | less +/"FORMAT controls"

    mine are like windows 7: %H:%M%n%d/%m/%Y

    Sunday, March 04, 2012

    Using PHP5-FPM With Apache2 On Ubuntu 11.10

    Could not reliably determine the server’s fully qualified domain name

    sudo gedit /etc/apache2/httpd.conf

    ServerName localhost
    sudo /etc/init.d/apache2 restart

    Thursday, March 01, 2012


    How to redirect your website base on country ip request, Apache, geoip, rewrite

    Install the mod-geoip

    sudo apt-get install libapache2-mod-geoip

    Enable the mods:

    sudo a2enmod rewrite
    sudo a2enmod geoip

    In your file ".htaccess" add these lines:

    # if country is PT
    RewriteEngine on
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^PT$
    RewriteRule ^(.*)$
    # else
    RewriteEngine on
    RewriteRule ^(.*)$

    You have to configure the virtual host to read the .htaccess file.
    <directory /var/www/site/>
     Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all

    In your file "httpd.conf" add these lines:

    GeoIPEnable On
    GeoIPDBFile /usr/local/share/geoip/geoip.dat
    Download the file from and put it in /usr/local/share/geoip/geoip.dat

    There are a lot of versions. This one is free for countries :)

    Using mod_spdy With Apache2 On Ubuntu 12.04

    SPDY runs over HTTPS, so we need an HTTPS-enabled web site to test SPDY. Please note that SPDY will fall back to HTTPS if the user's browser does not support SPDY or if things go wrong, so installing mod_spdy doesn't hurt your existing setup.

    a2enmod ssl
    a2ensite default-ssl
    /etc/init.d/apache2 restart

    cd /tmp
    dpkg -i mod-spdy-*.deb
    apt-get -f install
    /etc/init.d/apache2 restart

    Wednesday, February 22, 2012

    grub ubuntu

    Configure netbeans fonts in ubuntu

    sudo gedit /usr/local/netbeans-7.1/etc/netbeans.conf


    add this at the end of the line
    --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd

    or just this, if you don't won't the new java look.
    -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd

    Tuesday, February 21, 2012

    How to setup a Google Apps account in Pidgin?

    You have to change the advanced options of the account.

    Set "Server" to

    Tuesday, February 14, 2012


    Username and Email
    git config --global "Pedro Abrantes"
    git config --global
    git config --global diff.tool meld
    git config --global merge.tool meld
    git config --global push.default matching

    Use colors in git
    git config color.ui true

    Pretty Log
    git config format.pretty oneline

    Get latest from server
    git fetch origin
    git merge origin/"branch"

    Delete branch
    git branch -d branch
    git push origin --delete branch

    View differences between branches
    git difftool master..devel

    View differences between local file and other branch
    git difftool  other_branch -- path_to_file
    git difftool  other_branch path_to_file

    View differences between branched for one specific file
    git difftool  one_branch other_branch -- path_to_file
    git difftool  one_branc..other_branch path_to_file

    Get an archive from differences between branches
    git archive -o version3.1.18a $(git diff --name-only version3.1.18_merged )

    How do I create a new git branch from an old commit and checkout it?
    git checkout -b <name> <oct>

    Checkout file from previous commit

    First get the file back from one commit before:

    git checkout HEAD~1 path/to/file.ext
    Then commit it:

    git commit -a -m 'Retrieved file from older revision'
    If only the changes to that file where present in the last commit, you can even use git-revert:

    git revert HEAD
    I think it would be better to make this a separate commit, because it tells you exactly what you've reverted, and why. However, you can squash this into the previous commit by using the --amend switch to git-commit.

    Checkout a remote branch without locally created
    git checkout -t origin/branch
    git fetch origin
    git checkout -b test origin/test

    Check files on disk
    git fsck-objects --full

    To see the changes between the working directory and the index. This shows what has been changed, but is not staged for a commit.

    git diff

    To see the changes between the index and the HEAD(which is the last commit on this branch). This shows what has been added to the index and staged for a commit.

    git diff --cached

    To see all the changes between the working directory and HEAD (which includes changes in the index). This shows all the changes since the last commit, whether or not they have been staged for commit or not.

    git diff HEAD

    To view only the difference in patch mode
    git format-patch branch1..branch2

    to make a single patch use:

    git format-patch branch1..branch2 --stdout > my_new_patch.diff
    and apply
    git am < my_new_patch.diff

    To squash all commits since you branched away from master, do
    git rebase -i master

    Saturday, February 04, 2012

    Check open ports on Ubuntu Linux

    One may want to check open ports on Ubuntu to ensure that there are no services listening that shouldn't be. If we remember, a port is what an application will use to communicate with another application, provide a service, etc. To get an idea of what services are running on a system, we would need to check the open ports on the system.
    It is easy for us to install a program which provides a service and then forget about it, so we may have our machine listening on a number of ports waiting for incoming connections. Attackers love when ports are open, as the applications listening on these ports are the easiest targets. In order to ensure that our Ubuntu Linux system (or any other system for that matter) is as secure as possible, we need to be aware of what ports are open and providing what services.
    In the tutorial below, we will look at how to check open ports on Ubuntu or other versions of Linux.

    Checking open ports on Ubuntu

    To check which ports are open on our Ubuntu box, we can issue the command shown below. Note that this should also work for other flavours of Linux as long as they have netstat installed.
    Run the following in a terminal:
    netstat -anltp | grep "LISTEN"
    The typical web server which runs FTP, SSH, and MySQL will have output like:
    tcp     0   0*   LISTEN   21432/mysqld
    tcp     0   0*   LISTEN   4090/apache2
    tcp     0   0*   LISTEN   7213/sshd
    tcp6    0   0 :::21             :::*        LISTEN   19023/proftpd
    tcp6    0   0 :::22             :::*        LISTEN   7234/sshd
    What the above command does is run the netstat utility with the appropriate flags, then pipes the output to grep which then extracts the lines which contain the word "LISTEN". What we have as the result of that, is a list of the ports that we have open and the names of the processes which are listening on those ports.

    Which ports are open to the world

    Note that a service may have a port open, but that port may be only listening on the current machine. That is, a port is open, but you will not be able to access it from over the network. This is useful for security as something like a web server should have port 80 open to the world, but the world need not know about (or be able to connect to) port 3306, the port which the MySQL server that powers the website is listening on.
    Ideally, if you are running a web server, the only ports that you would want visible on the outside are HTTP port 80 and maybe SSH port 22 since you still need to be able to connect to the web server to run commands.
    The ports which have services available to the localhost only, will have the IP address in its local address field. In the example above, that would be:
    tcp     0   0*   LISTEN   21432/mysqld
    As we can see, MySQL is listening on port 3306 on an IP address of This means that only programs on the same machine will be able to connect to the MySQL server.
    That is it for this tutorial on checking open ports on Ubuntu Linux. We hope you enjoyed it. Check out the links below for other articles which you may like.

    Friday, February 03, 2012


    É maior que Deus, Pior que o diabo, os pobres tem, os ricos precisam, quando você come morre.?

    Friday, January 27, 2012

    Hide PHP on Apache and Apache itself

    Hide PHP on Apache and Apache itself:
    In httpd.conf
    ServerName localhost
    # ...
    # Minimize 'Server' header information
    ServerTokens Prod
    # Disable server signature on server generated pages
    ServerSignature Off
    # ...
    # Set default file type to PHP
    DefaultType application/x-httpd-php
    # ...
    ; ...
    expose_php = Off
    ; ...

    Sunday, January 22, 2012

    How to install Eclipse 3.7 on Ubuntu 11.04

    The Eclipse packages in Ubuntu are are very out of date. The latest version in the Ubuntu repos is 3.5.2 where as the latest version of Eclipse is 3.7. I’m posting this because Ubuntu 11.04 uses the new Unity desktop which uses overlay-scrollbars (scrolls bars that are hidden until you hover over them). For some reason Eclipse 5.3.2 doesn’t like to play nice with the overlay scrollbars, and I’d rather use the newest version anyways. With Eclipse, you can just download the tar.gz file from and run it no problem, but I like set things up in a cleaner fashion, so here’s how I did it.

    1) Download Eclipse. I got eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
    2) Extract it
    tar zxvf eclipse-SDK-3.7.2-linux-gtk-x86_64.tar.gz
    Or just be lazy and Right Click > Extract Here
    3) Move to /opt/ folder
    sudo mv -f eclipse /opt/
    cd /opt/
    sudo chown -R root:root eclipse
    sudo chmod -R +r eclipse
    4) Create an eclipse executable in your path
    sudo touch /usr/bin/eclipse
    sudo chmod 755 /usr/bin/eclipse
    sudo nano /usr/bin/eclipse
    copy this into nano
    #export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
    export ECLIPSE_HOME="/opt/eclipse"
    $ECLIPSE_HOME/eclipse $*
    save the file (^O = Ctrl+o) and exit nano (^X = Ctrl+x)
    5) Create a gnome menu item
    sudo nano /usr/share/applications/eclipse.desktop
    copy this into nano
    [Desktop Entry]
    Comment=Eclipse IDE
    save and exit nano
    6) Launch Eclipse for the first time
    /opt/eclipse/eclipse -clean &
    7) The update Site

    How to get the IP address of the docker host from inside a docker container

    /sbin/ip route|awk '/default/ { print $3 }'