Tuesday, September 21, 2010

P2PU: Drupal Introduction #1

I’ve started two drupal courses through P2PU and want to keep my work on each separated.

To achieve this I need:

  • Two separate drupal folders
  • Two separate drupal databases
  • Two separate virtual sites for apache

I made the first site “drupalintro” in the same manner as outlined in my earlier post P2PU: Drupal Social Web Application #1 with the following changes.

  1. The drupal directory was named /var/www/drupalintro
  2. $ mysqladmin –u root –p create drupalintro
  3. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupalintro.* TO ‘<drupaluser>’@’localhost’ IDENTIFIED BY ‘<drupalpass>’;
  4. mysql> FLUSH PRIVILEGES;
  5. mysql> \q
  6. $ vim /var/www/drupalintro/sites/default/settings.php
  7. edit:  $db_url = ‘mysql://<drupaluser>:<drupalpass>@localhost/drupalintro’;
  8. $ cp /etc/apache2/sites-available/default /etc/apache2/sites-available/drupalintro
  9. $ vim /etc/apache2/sites-available/drupalintro
  10. edit: DocumentRoot /var/www/drupalintro
  11. edit: Directory /var/www/drupalintro

Now to make the second site called “openhippel” I did the same again with the following changes:

  1. The drupal directory was named /var/www/openhippel
  2. $ mysqladmin –u root –p create openhippel
  3. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON openhippel.* TO ‘<drupaluser>’@’localhost’ IDENTIFIED BY ‘<drupalpass>’;
  4. mysql> FLUSH PRIVILEGES;
  5. mysql> \q
  6. $ vim /var/www/openhippel/sites/default/settings.php
  7. edit:  $db_url = ‘mysql://<drupaluser>:<drupalpass>@localhost/openhippel;
  8. $ cp /etc/apache2/sites-available/default /etc/apache2/sites-available/openhippel
  9. $ vim /etc/apache2/sites-available/openhippel
  10. edit: DocumentRoot /var/www/openhippel
  11. edit: Directory /var/www/openhippel

Now to change between the two virtual sites I simply use the following (shown for selecting drupalintro)

  1. $ sudo a2dissite openhippel && sudo a2ensite drupalintro
  2. $ sudo /etc/init.d/apache2 reload

Then I can browse to my localhost address and see the home page for the desired site.

Saturday, September 18, 2010

P2PU: Drupal Social Web Application #2

Just finished the first Tokbox session for the Drupal Social Web course. Bit of a bumpy start with the first session starting half an hour late!

I’m starting by forking three repositories from GitHub that will be used for this project. The repositories as I understand them are:

  1. hippel_idea the features package
  2. hippel_kit which will contain drush makefiles
  3. hippelicious a hippel theme

It looks like the idea this week is to make sure we can fork these and edit them locally before commiting, pushing back to our own github forks and sending a pull request to the original repository.

At this stage I will consider it an added bonus if I can make these work in my drupal install…

Technorati Tags: ,,

Wednesday, September 15, 2010

P2PU: Drupal Social Web Application #1

I’ve enrolled in a P2PU course called Drupal Social Web Application. Over the next 6 weeks I’ll be learning how to use Drupal and git while working on development of the Open Hippel platform. Most of this stuff is pretty new to me so I’ll be in over my head. I’ll also be moving house at the same time, hopefully without too much of a no interwebs period. When it rains it pours!

I’ve been getting acquainted with Drupal this week and after some trials with the Ubuntu drupal6 package I’ve opted for the manual installation of Drupal as outlined in the Ubuntu Community Documentation. The manual installation allows me some more flexibility in terms of where I keep my files and which version I use when compared to a package install.

Here is a brief outline of the steps I followed on an Ubuntu Server 10.04 virtual machine.

  1. $ cd ~
  2. $ wget http://ftp.drupal.org/files/projects/drupal-6.19.tar.gz
  3. $ tar zxvf drupal-6.19.tar.gz
  4. $ sudo mkdir /var/www/drupal
  5. $ sudo mv drupal-6.19/* drupal-6.19/.htaccess /var/www/drupal
  6. $ sudo mkdir /var/www/drupal/sites/default/files
  7. $ sudo chown www-data:www-data /var/www/drupal/sites/default/files
  8. $ sudo cp /var/www/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php
  9. $ sudo chown www-data:www-data /var/www/drupal/sites/default/settings.php
  10. $ mysqladmin –u root –p create drupal
  11. $ mysql –u root –p
  12. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupal.* TO ‘<drupaluser>’@’localhost’ IDENTIFIED BY ‘<drupalpass>’;
  13. mysql> FLUSH PRIVILEGES;
  14. mysql> \q
  15. $ vim /var/www/drupal/sites/default/settings.php
  16. edit:  $db_url = ‘mysql://<drupaluser>:<drupalpass>@localhost/drupal’;
  17. $ cp /etc/apache2/sites-available/default /etc/apache2/sites-available/drupal
  18. $ vim /etc/apache2/sites-available/drupal
  19. edit: DocumentRoot /var/www/drupal
  20. $ sudo a2dissite default && a2ensite drupal
  21. $ sudo /etc/init.d/apache2 reload
  22. From the host (or any machine on the same network) browse to “<server ip>/install.php” and follow the web based setup for Drupal
Technorati Tags: ,,,

Tuesday, September 14, 2010

Mount a Windows Share in Ubuntu Server

It is really ease to access a windows share from the console of Ubuntu Server. The following steps were performed on Ubuntu Server 10.04 to access a share on a QNAP NAS with no username or password required.

  1. $sudo apt-get install smbfs
  2. $mkdir ~/temp
  3. $sudo mount.cifs //192.168.0.x/public ~/temp

Now it is possible to cd into temp and ls the contents of the public share.

Technorati Tags: ,,,,

Tuesday, August 31, 2010

Git and GitHub

I recently brought up version control systems at a circuit hacking evening at the Artifactory. Not surprisingly for a room of open source/linux type people almost everyone was in favour of using git. I was even pointed to a youtube video of Linus Torvalds on git which is not a tutorial on how to use git but does provide a good overview of why it might be better than other version control systems. I also found the video quite amusing due to Linus’ famously abrupt manner.

My concern with using git was that I am a windows user and didn’t expect it to work natively with windows. It doesn’t matter how many ways git is superior to other version control systems, if it doesn’t work well on windows it’s not for me.

Fearing that I would be wasting my time I tried out msysgit (git for windows) which includes such goodies as shell integration that allows for a gui or bash interface for managing repositories. It actually turned out to be quite good. The interface is not as nice as TortoiseSVN but the distributed version control nature of git more than makes up for that.

The only way to properly test something like this out is to use it on a real project so I started using git for version control of my BalanceBot project on my laptop.

I don’t like to have anything which is important to me stored in only one location so after checking out my options I started a GitHub account. It’s a safe place to push repositories to and it’s free as long as your projects are open source. There is also a neat Watch function that allows you to track other interesting repositories, kind of like social media for code.

Monday, July 26, 2010

BalanceBot 2

I finally have communication between an Arduino and an ADXL345 accelerometer over SPI!

I used the SPI library from the Arduino playground but was still having trouble so in the end resorted to following the example source code provided by sparkfun for the ATmega328.

The following listing is copied straight from my Arduino environment.

#include <Spi.h>

/*
  BalanceBot
  Read from an accelerometer ADXL345.
  ADXL345 max clock speed is 5MHz, default arduino CLKi/o is 16MHz/64 (OK)
  ***SPI Pins***
  SCK    PB5    13
  MISO    PB4    12
  MOSI    PB3    11
  SS    Any    10
  Ben Caldwell
*/

byte tmp;
byte readData; //The byte that data read from SPI interface will be stored in
byte fifo[6]; //data read for x,y,z axis from the accelerometer's FIFO buffer
float x,y,z; //The ranged x,y,z data
float range; //The range of the x,y,z data returned

// The setup() method runs once, when the sketch starts

void setup()   {               
  Serial.begin(9600);
  Spi.mode((1<<SPE) | (1<<MSTR) | (1<<CPOL) | (1<<CPHA) | (1<<SPR1) | (1<<SPR0));

  Serial.println("Starting Setup");
  //Set SS high, slave disabled waiting to pull low for first exchange
  digitalWrite(SS_PIN, HIGH);
  delay(4000);
  //Wait for POWER_CTL register to go to correct state
  readData = 0x00;
  while (readData != 0x28)
  {   
    //POWER_CTL register: measure
    digitalWrite(SS_PIN, LOW);
    Spi.transfer(0x2D);
    Spi.transfer(0x28); //Measure
    digitalWrite(SS_PIN, HIGH);
    delay(5);
    digitalWrite(SS_PIN, LOW);
    Spi.transfer(1<<7 | 0x2D); //Set "read" MSb
    readData = Spi.transfer(0x00); //Send dummy byte to keep clock pulse going!
    digitalWrite(SS_PIN, HIGH);
    Serial.print("POWER_CTL: ");
    Serial.println(readData, HEX);
    delay(1000);
  }
  //Set FORMAT
  digitalWrite(SS_PIN, LOW);
  Spi.transfer(0x31);
  Spi.transfer(0x08);
  digitalWrite(SS_PIN, HIGH);
  delay(5);
  //Readback FORMAT
  digitalWrite(SS_PIN, LOW);
  Spi.transfer(1<<7 | 0x31);
  readData = Spi.transfer(0x00);
  digitalWrite(SS_PIN, HIGH);
  readData = readData & 0x03;
  switch (readData)
  {
    case 0:
      range = 2.0;
      break;
    case 1:
      range = 4.0;
      break;
    case 2:
      range = 8.0;
      break;
    case 3:
      range = 16.0;
      break;
  }
  Serial.print("FORMAT: ");
  Serial.println(readData, HEX);
  //Set FIFO
  digitalWrite(SS_PIN, LOW);
  Spi.transfer(0x38);
  Spi.transfer(0x00);
  digitalWrite(SS_PIN, HIGH);
  delay(5);
  //Readback FIFO
  digitalWrite(SS_PIN, LOW);
  Spi.transfer(1<<7 | 0x38);
  readData = Spi.transfer(0x00);
  digitalWrite(SS_PIN, HIGH);
  Serial.print("FIFO: ");
  Serial.println(readData, HEX);
  delay(4000);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{
   //All x,y,z data must be read from FIFO in a multiread burst
  digitalWrite(SS_PIN, LOW);
  //Start reading at 0x32 and set "Read" and "Multi" bits
  Spi.transfer(1<<7 | 1<<6 | 0x32);
  for (int i=0; i<6; i++)
  {
    fifo[i] = Spi.transfer(0x00);
  }
  digitalWrite(SS_PIN, HIGH);
  delay(5);
  //The measurements in the FIFO 10bit 
  x = (float)((fifo[1]<<8) | fifo[0]) * range / 512.0;
  y = (float)((fifo[3]<<8) | fifo[2]) * range / 512.0;
  z = (float)((fifo[5]<<8) | fifo[4]) * range / 512.0;
  Serial.println("********************");
  Serial.print("[X,Y,Z](g): [");
  Serial.print(x);
  Serial.print(",");
  Serial.print(y);
  Serial.print(",");
  Serial.print(z);
  Serial.println("]");
  delay(1000);

}

 

References

  1. The SEN-09156 breakout board:
    http://www.sparkfun.com/commerce/product_info.php?products_id=9156
  2. Sparkfun example code:
    http://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345-talktest.zip
  3. Arduino SPI library:
    http://www.arduino.cc/playground/Code/Spi

Friday, July 9, 2010

Convert DVDs to MKV

I’ve been looking at options for ripping my DVDs to my home NAS that I connect to with a media streamer. Anyone who has ever tried ripping DVDs will know that this can be an overly complicated and often disappointing task.

I recently had the most success to date using a utility called MakeMKV. This utility takes the files in the Audio_TS and Video_TS folders and encapsulates them in a single .mkv file for each title on the DVD.

My WD TV Live plays MKV files perfectly, the quality looks the same as the original DVD to me. For PC playback I was disappointed to see WMP does not play MKV files out of the box, but there are plenty of options out there in the form of codecs and alternative free players.