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:

Advertisements

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

Meld: diff and merge files

Diff tools are very useful to identify changes in file versions (CVS, subversion). There are some command line tools such as diff and diff3 that compare two or three files, line per line, returning those that present differences. However, in some cases, a visual tool that highlight the differences could be more effective. Meld aims to handle this issue. It can be used not only to compare files but also to compare folders, to find files that exists in one and doesn’t in other. It can be installed through apt-get tools:

sudo apt-get install meld

Take a look on some previews provided by Meld Project:

See ya

Shutter: A snipping tool for Ubuntu

The standard PrintScreen key get the image of the entire Desktop. If you want just the active window, on Ubuntu, you can use Alt + PrintScreen. However, sometimes you may need only to snip only a specific part of the active window. The intuitive option is to take a PrintScreen and cut it on a image tool such GIMP. By the way, if you need to do it many times you can think on better alternatives, such as Shutter, a useful tool that can be configure to replace the standard PrintScreen key and handle this issue. You can install using apt-get:

sudo apt-get install shutter

The installation does NOT configure it as the default PrintScreen mechanism. To do it, open Shutter tool, click on Edit > Preferences, go to [Behavior] tab and mark [Capture] and [Capture with selection] options. After it, you may need to restart the GDM.

Check out some previews offered on Shutter Blog:

See ya