Installing Moodle 1.9 in Ubuntu 12.04

Step 1: Install and set up MySQL

  • sudo apt-get install mysql-server (assuming password ‘123456’)
  • mysql -u root -p123456
    • CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    • GRANT ALL PRIVILEGES ON moodle.* TO moodleuser@localhost IDENTIFIED BY ‘123456’;
    • GRANT SELECT,LOCK TABLES on moodle.* TO moodlebackup@localhost IDENTIFIED BY ‘123456’;
    • FLUSH PRIVILEGES;
    • QUIT

Step 2: Install Apache

  • sudo apt-get install apache2
  • sudo gedit /etc/apache2/httpd.conf
    • ServerName localhost
  • sudo chown -R www-data:www-data /var/www/
  • sudo /etc/init.d/apache2 restart

Step 3: Install PHP

  • sudo apt-get install php5-ldap php5-odbc
  • sudo apt-get install libapache2-mod-php5 php5-gd php5-mysql

Step 3: Install Moodle

  • cd /var/www
  • sudo wget http://download.moodle.org/stable19/moodle-latest-19.tgz
  • sudo tar -zxf moodle-latest-19.tgz
  • sudo mkdir /var/www/moodledata
  • sudo chown -R www-data:www-data /var/www/moodledata
  • sed -i ‘s:/var/www:/var/www/moodle:g’ /etc/apache2/sites-available/default
  • sudo /etc/init.d/apache2 restart
  • sudo chmod -R 755 /var/www/moodle/
  • sudo chown -R www-data:www-data /var/www/moodle

Step 4: Set up Moodle

References:

How to creates a free micro instance at Amazon

Step 1: Creates your AWS account

  1. Enter in http://aws.amazon.com/free/
  2. Creates an Amazon account, the same used to purchase books (requires a valid credit card)
  3. 3. Completes the form..
  4. Verifies your telephone

Step 2: Creates a micro instance

  1.  Enter in http://aws.amazon.com/free/
  2. Goes in ‘Account’ > ‘AWS Management Console’
  3. Click in EC2 (default hostage: US East N. Virginia)
  4. Click in ‘Launch instance’
  5. Select ‘Classic Wizard’
  6. Choose an image (Ubuntu 12.04 LTS)
  7. Selects instance ‘T1 Micro, 613MB Free Tier’ (On demand)
  8. Skips Advanced Instance Options (choose specific kernetl or RAM disks)
  9. Storage (8 GB)
  10. Skips Tags
  11. Createa key pair named ‘microaws’ (do NOT proceed without a Key Pair)
  12. Skips configure firewall (which will creates group quick-start-1, allowing SSH at 22)
  13. Review instance info and
  14. Launch it

Step 3: Access instance via ssh

  1. Change key pair file permission
    • chmod 600 microaws.pem
  2. Connects to remote host:

Step 4: Enables port 80

  1. Enter in http://aws.amazon.com/free/
  2. Goes in ‘Account’ > ‘AWS Management Console’
  3. Click on ‘Security Groups’
  4. Select group ‘quick-start-1’
  5. Click on tab ‘Inbound’
  6. Add rule > Create a new rule > HTTP
  7. Apply Rule Changes
  8. Tests port 80
    • telnet <EC2-HOSTNAME> 80

References:

Copiando coleções em Java

Em java, para fazer com que uma coleção tenha o mesmo conteúdo que outra, podemos fazer o seguinte:

  List<String> a = new LinkedList<String>();
  a.add("1");
  a.add("2");
  List<String> b = new LinkedList<String>(a); //aqui b copiará a

No entanto, os elementos de b, que copiou tudo de a, continuarão referenciando os mesmos elementos de a na memória. Em alguns casos isso pode não ser o comportamento desejado.

Para forçar o Java a duplicar as instâncias da coleção copiada na coleção de destino, adicione após o construtor de b  o seguinte comando:

  Collections.copy(b,a);

Observe que se vc chamar apenas o comando copy sem ter feito a construção corretamente, provavelmente encontrará uma exceção informando que B não suporta A, ou que B não é grande o suficiente para A.

Text replacement in multiple files using sed and find

A common task in programming routine is to change variable names, methods in multiple files. This can be performed by a refactor operation in the most IDEs (eclipse, netbeans). However if you have many text files, such as parameter files, configuration files you can do it in a single command in shell:

$ find . -name "*.c" -exec sed -i "s/oldWord/newWord/g" '{}' \;

Explaining:

  1. find . -name “*.txt”: search all files with extension “.txt”, starting from current directory (.)
  2. -exec sed -i : edit file (option -i) with name received from find
  3. “s/oldWord/newWord/g”: replace all ocurrences “oldWord” by “newWord”
  4. ‘{}’: list of file names retrieved from find
  5. \;: end of exec command (it allow mutiple commands)

See more:
http://how-to.wikia.com/wiki/Howto_use_find_and_sed_to_make_a_replace_in_multiple_files

See ya

Google Wave Notifier

As I didn’t knew any notifier to Google Wave (such as a Gmail Notifier that seems be out of plans of Wave project), I entered in the site sporadically and wore little. A third party releases a Google Wave Notifier to Google Chrome that adds an icon next to the search bar that allows you to check if you received a message and also make a shortcut to the site. Follow a preview:

See ya