Educating the world

Our blog has over 10,000 readers a month

SD card is read-only on Mac

June 11th, 2013

I spent almost half a day trying to figure out why the SD card plugged into the side of my MacBook Pro suddenly became read-only.

After wading through an awful lot of Apple forums containing “are you sure you have the SD card read-only lock in the correct position” I discovered several aspects of this problem that will hopefully save other people from pulling their hair out.

  1. The problem happens more often than not on SDHC type cards.
  2. Mac has some out-of-specification code to write to SD cards which is not compatible with other card readers.
  3. There is a fault with the onboard card reading which falsely reports that the physical read-only lock is active.
  4. It matters how you insert the SD card into the SD reader’s slot.
  5. All problems can be solved by using an external card reader.

The problem I was suffering from was that of the false positives on the SD card reader’s read-only sensor. The device file for the onboard SD card reader was /dev/disk1 so I’ll use that in the work-around procedure that follows:

  1. Open a terminal window and type:

    $ ls -l /dev/disk1*
    br–r—– 1 mrn operator 14, 0 11 Jun 00:24 /dev/disk1

  2. Make sure the SD card’s physical switch is pressed down in the unlocked position. There should be a label on the card itself to remind you.
  3. Insert the card firmly applying the pressure directly along the line of insertion.
  4. Run the above line again to check the read-only status.
  5. If the device still reports as read-only, pull the card out and insert your fingernail in between the physical lock switch. The gap should remain when you remove your nail, then repeat the test.
  6. Increase the width by about a fingernail’s worth each time you run the test and eventually you will reach the sweet spot. The test will report:

    $ ls -l /dev/disk1*
    brw-rw—- 1 mrn operator 14, 0 11 Jun 00:24 /dev/disk1

It took me about 3 or 4 iterations to find the right point.

How can I stop a Facebook App filling up my wall and annoying my friends?

April 17th, 2013
  1. Go to Settings > Account Settings > Apps > Apps you use.
  2. Find the game, click Edit.
  3. Change Visibility of App to Only me.
  4. Also delete the This app can also post on your behalf bit.

Installing OpenMeeting with MySQL

March 14th, 2013

From Wikipedia OpenMeeting is:

OpenMeetings is software used for presenting, online training, web conferencing, collaborative whiteboard drawing and document editing, and user desktop sharing. The product is based on OpenLaszlo RIA framework and Red5 media server, which in turn are based on a bunch of open source components. Communication takes place in meeting rooms which are set to different communication, security and video quality modes. The recommended database for backend support is MySQL. The product can be set up as an installed server product, or used as a hosted product.

Today we will be installing OpenMeeting on CentOS 6.3 (64-bit).
Find a nice place to work:

mkdir /home/dev
cd /home/dev

Go to http://openmeetings.apache.org/downloads.html and download and unpack latest binary.

  1. wget http://archive.apache.org/dist/incubator/openmeetings/2.0-incubating/apache-openmeetings-incubating-2.0.0.r1361497-14-07-2012_1108.tar.gz

  2. mkdir openmeeting

  3. cd openmeeting

  4. tar -xzvf ../apache-openmeetings-incubating-2.0.0.r1361497-14-07-2012_1108.tar.gz

The default installation of OpenMeeting uses an integrated Apache Derby database to persist data at the back end. They recommend MySQL (or a real database) for production installations. I however, like to easily poke around the database and investigate how the product works. The trouble with an integrated database is that it won’t be available when the application is down and it may not be available to clients outside the application.

OpenMeeting requires UTF8 so we’ll install MySQL and configure the collation.

  1. Install PHP and MySQL with yum
  2. yum install php mysql-server mysql

  3. There are a few problems of setting the collation with MySQL so. Edit /etc/my.cnf and add the following lines to the mysqld section:

    [mysqld]
    skip-character-set-client-handshake
    collation-server = utf8_unicode_ci
    init-connect=’SET NAMES utf8′
    character-set-server = utf8

  4. Then restart MySQL with:

    /etc/init.d/mysqld restart

Now that we have MySQL installed, we’ll have to create a MySQL account for OpenMeeting to use.

  1. Login to MySQL:

    mysql -uroot

  2. Create the database:

    CREATE DATABASE openmeetings;

  3. Create a MySQL user for the application:

    CREATE USER openmeetings;

  4. Set permissions:

    GRANT ALL ON openmeetings.* TO openmeetings@localhost;

  5. Set password (change **** to your password):

    SET PASSWORD FOR openmeetings@localhost=PASSWORD(’****’);

  6. Log out of MySQL:

    exit;

  7. Now we will just check that our new user is set up properly. (Where **** is the password)

    mysql -uopenmeetings -p**** openmeetings

OpenMeeting isn’t bundled with all the database connectors so we’ll have to download and install the MySQL connector in order to talk to the database.

  1. Start off in our dev area:

    cd /home/dev

  2. Go to http://www.mysql.com/downloads/connector/j/ and download the latest ConnectorJ (at the time of writing this was 5.1.24)
  3. Unpack it:

    tar -xvzf mysql-connector-java-5.1.24.tar.gz

  4. Move the connector to the correct place in the OpenMeeting directory structure so it can be found by the application:

    mv mysql-connector-java-5.1.24/mysql-connector-java-5.1.24-bin.jar openmeeting/webapps/openmeetings/WEB-INF/lib/

We are not using the default database type so we must change the configuration files so that the OpenMeeting installation process uses the MySQL configuration file instead of the integrated Derby configuration file.

  1. Go to the connectors folder:

    cd /home/dev/openmeeting/webapps/openmeetings/WEB-INF/classes/META-INF

  2. Use the MySQL configuration template:

    cp mysql_persistence.xml persistence.xml

  3. Edit persistence.xml and change the MySQL credentials. At the bottom of the file you will see

    value="DriverClassName=com.mysql.jdbc.Driver
    , Url=jdbc:mysql://localhost:3306/openmeetings?autoReconnect….
    …. , MaxActive=100
    , MaxWait=10000
    , TestOnBorrow=true
    , poolPreparedStatements=true
    , Username=openmeetings
    , Password=****"/>

    Change the Username and Password to what you set earlier. If you want to change the database name localhost:3306/openmeetings? will become localhost:3306/my_database?.

Now we are going to set up Enabling Image Upload and import to whiteboard.

To install ImageMagick we’ll use the package manager:

yum install ImageMagick

Installing ImageMagick will install GhostScript as a dependency so we get part 1 of Enabling import of PDFs into whiteboard for free. Part 2 requires installing SWFTools which we will do now:

  1. Start in our development directory:

    cd /home/dev

  2. Go to http://www.swftools.org/download.html and get the latest version:

    wget http://www.swftools.org/swftools-0.9.2.tar.gz

  3. Unpack with:

    tar -xvzf swftools-0.9.2.tar.gz

  4. If this is a minimal version of CentOS (or you type gcc and get bad command) then you’ll need to install the C compiler and tools:

    yum install gcc* automake zlib-devel libjpeg-devel giflib-devel freetype-devel make

  5. Prepare to build the software:

    cd /home/dev/swftools-0.9.2

  6. Run the pre-build configuration script:

    ./configure

  7. Build SWFTools:

    make

There is a bug in the make install step so we’ll just fix that before running it.

  1. Edit /home/dev/swftools-0.9.2/swfs/Makefile
  2. Search for the install: directive and change:

            rm -f $(pkgdatadir)/swfs/default_viewer.swf -o -L $(pkgdatadir)/swfs/default_viewer.swf
            $(LN_S) $(pkgdatadir)/swfs/simple_viewer.swf $(pkgdatadir)/swfs/default_viewer.swf
            rm -f $(pkgdatadir)/swfs/default_loader.swf -o -L $(pkgdatadir)/swfs/default_loader.swf
            $(LN_S) $(pkgdatadir)/swfs/tessel_loader.swf $(pkgdatadir)/swfs/default_loader.swf
    

    to

    <TAB>rm -f $(pkgdatadir)/swfs/default_viewer.swf
    <TAB>$(LN_S) $(pkgdatadir)/swfs/simple_viewer.swf $(pkgdatadir)/swfs/default_viewer.swf
    <TAB>rm -f $(pkgdatadir)/swfs/default_loader.swf
    <TAB>$(LN_S) $(pkgdatadir)/swfs/tessel_loader.swf $(pkgdatadir)/swfs/default_loader.swf
    
    

    Make sure that the first and only character at the start of the replacement lines is a TAB and not a space.

  3. Now we can run:

    make install

Next we’ll install the dependencies for Enabling import of .doc, .docx, .ppt, .pptx, … all Office Documents into whitebaord. This also installs Oracle’s Java which is why we didn’t install it earlier.

  1. Install Libre Office:

    yum install libreoffice-writer

Enabling Recording and import of .avi, .flv, .mov and .mp4 into whiteboard requires FFMpeg which is not available via standard yum so we’ll add another repository that does contain it. Thanks to needlessly does a “yum update” which would probably update everything seeing as CentOS keep stable older version instead of the bleeding edge.

  1. Edit /etc/yum.repos.d/dag.repo
  2. Add:

    [dag]
    name=DAG RPM Repository
    baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
    gpgcheck=1
    enabled=1

  3. Import keys so we can talk to the repository securely:

    rpm −−import http://apt.sw.be/RPM-GPG-KEY.dag.txt

  4. Start installation:

    yum install ffmpeg

Enabling Recording and import of .avi, .flv, .mov and .mp4 into whiteboard also requires SOX but that is available on the standard yum so just install that.

yum install sox

I have read through the installation instructions for OpenMeeting and they are as clear as mud. Half the documents seem to say that JODConverter is needed and the other half say that it isn’t. Even the project page for JODConverter says that the project isn’t even maintained. It has some connection to OpenOffice/LibreOffice, so I’m installing it anyway just in case.

  1. Change back to our scratch folder:

    cd /home/dev

  2. Go to http://code.google.com/p/jodconverter/
  3. And download the latest version:

    wget http://jodconverter.googlecode.com/files/jodconverter-core-3.0-beta-4-dist.zip

  4. Then unzip it

    unzip jodconverter-core-3.0-beta-4-dist.zip

Well that’s it for the dependencies. Hopefully OpenMeeting will find all the things it needs during it installation.

After following the original instructions for installing OpenMeeting, the Oracle Java had been replaced by the GNU version of the Java runtime. When I started the OpenMeeting container it use that version instead of the Oracle implementation and didn’t work.
If you install the dependencies in the order that I described above then Oracle’s Java should come out on top. We need to check to make sure though:

  1. Get which version of Java are you running:

    java -version

  2. You should get:

    java version “1.7.0_13″
    Java™ SE Runtime Environment (build 1.7.0_13-b20)
    Java HotSpot™ 64-Bit Server VM (build 23.7-b01, mixed mode)

  3. If you don’t then you’ll have to uninstall the GNU version:

    yum remove gij
    rpm -e jre

  4. And reinstall Oracle’s Java over the top:

    1. Navigate to: http://www.java.com/en/download/manual.jsp
    2. And download the appropriate version I selected “Linux x64 RPM".
    3. Install via the Redhat Package Manager, you might see a couple of errors like “Error: Could not open input file” but you can ignore these.

      rpm -i jre-7u13-linux-x64.rpm

OpenMeeting uses a couple of ports to communicate with so make sure your firewall allows traffic on them. For development purposes the following will remove all firewall rules until you reboot.

iptables -F

To start OpenMeeting:

  1. Change directory:

    cd /home/dev/openmeeting

  2. Type:

    ./red5.sh

It should print a lot of information on the screen. There will be pauses and gaps but when it starts repeating no Appointments in range you are ready for the next step.

You can check [crudely] that the database has been created in MySQL by ensuring that there are plenty of files in:
/var/lib/mysql/openmeetings/

The final part of the installation is run from the web interface so navigate to:
http://localhost:5080/openmeetings/install
where localhost is the machine you have installed OpenMeeting on.

Click the link Continue with STEP 1. This will take you to the initial configuration screen where you can set up the application:

In the Userdata section fill in the admin user

Username: admin
Password: admin
Email: myemail@example.com

In the Configuration section I didn’t touch anything but the names seem pretty self explanatory if you know how to set up your mail system (which is beyond the scope of this document).

In the Converters section we need to add the paths to the support utilities as they won’t be available to the servlet container.

All the Converter support applications should be in your path except jodconverter-core. I still don’t understand if or how JODConverter is needed, so add a reference to the JOD path anyway.

/home/dev/jodconverter-core-3.0-beta-4/lib

I leave all the other stuff to their defaults.

Finally click INSTALL. The red5.sh screen will spend a couple of minutes spewing out data, so let it get on with it. When it has finished your web browser will sent you to the “Installation Complete!” page.

Click Enter the Application and login with Username as admin and Password as admin.

The rest is up to you! Good luck.

Killing a crashed Task Manager

March 7th, 2013

I’m running Vista at the moment and it is terrible. I think we are all tired of the appalling file copying mechanism. I came across a new bug in Vista today and thought I’d blog how I got out of it.

Task manager was loaded in and minimized.

Symptoms:

  1. Right-clicked on the Task manager icon in the systray and the menu appeared. The menu items were click-able but the clicks wouldn’t register. The menu wouldn’t disappear after that, no matter what you did.
  2. The minimized icon in the systray was spiking, It appeared to be flashing as it rapidly switched from high CPU to low CPU.
  3. I couldn’t start any explorer sessions using the following methods:

    1. The WindowsKey-E wouldn’t work.
    2. Running explorer from Start->Run
    3. Clicking New Task… inside the Task manager and running explorer

Solution:

We must kill Task manager from the command line.

  1. First we need to start a Powershell session, because a normal command window doesn’t have the right tools in its path. Start->Run

    powershell

  2. Next list the processes currently running on the machine.

    PS C:\Users\mrn> Get-Process
    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
    ——- —— —– —– —– —— – ———–

    118 9 4552 11972 98 0.95 4132 taskmgr

  3. Make a note of the the Id of the Task manager process (taskmgr).
  4. Powershell makers have created a “kill” alias to the Stop-Process command to make it look a bit more like wonderful unix.

    kill 4132

  5. You may find that the systray icon is still present. If you hoover over the icon it will disappear.

Configuring a permanant DHCP reservation on a Cisco ASA/PIX

February 2nd, 2013

One of our offices uses a Cisco ASA/PIX and we want to manage all the IP address allocations with DHCP. The main benefit of this is that the dynamic IP address allocations can be managed centrally. If we change the default gateway of the network then no one needs to make any changes to the network settings on their devices.

Each device on the network gets an IP address when they ask for it and keeps it for a fixed amount of time called a lease. When that time has expired the device releases the address and asks for another. In most cases the device will be given the same information again by the DHCP server.

If you have a network with a lot of laptops, phones, tablets or printers then devices will come and go quite frequently. You will find that if you switch off the device for any amount of time it will come back with a different address. For laptops and personal devices this doesn’t matter. However if the device is a shared resource like a printer or file server then it can be a problem. Anyone who still wants to use that shared resource now needs to know about its new address.

We want to be able to tell the DHCP server that while it can allocate IP addresses from a certain pool we want to make sure that it can only allocate some of them to specific network devices. This will ensure that if a printer goes for repair and comes back in a week, when it’s switched back on it will have the same IP address that it always had.

Unfortunately there isn’t a structured way of doing this with a Cisco ASA/PIX so we need to find a work-a-round.

The following instructions describe how to do this but they also describe how to get into the administration section of the Cisco ASA/PIX because most of the instructions (on the internet) assume you know how to do this already. There is a strong argument that you should know what you are doing before you play with a router/firewall’s configuration but if your network man is on holiday then you might have to get your hands dirty yourself.

There are various GUIs to help with this kind of administration and that’s fine if you are at the customer’s site but most of the time I’m not. Short of connecting to the VPN and using the management console the easiest way is to go in on the command line using telnet.

In the following scenario we have been told that the printer is set to use DHCP and its current IP address is 192.168.1.69. We want to add that to the pool and make sure it is given the same IP address each time.

So connect to the Cisco ASA/PIX. There’s no user name only a password, so enter the user level password:

host# telnet 192.168.1.254
User Access Verification

Password: ***
Type help or ‘?’ for a list of available commands.
cisco>

Once logged in we need to switch to the administration mode.

cisco> enable
Password: ***

The user told us the printer was currently switched on so we can read the router’s Address Resolution Protocol table which lists the mappings between IP addresses and Media Access Control address (MAC address or address network card address). We’ll need the MAC address as it is the reference the router talks to whereas the IP address is only an abstraction.

cisco# show arp
inside 192.168.1.69 0c1b.ae43.bd21

Now we can check that the 192.168.1.69 address is in the pool of DHCP addresses

cisco# show running-config dhcpd
dhcpd address 192.168.1.20-192.168.1.70 inside
dhcpd dns 8.8.8.8 4.2.2.2 interface inside
dhcpd domain 360inspire.com interface inside
dhcpd enable inside
!

which it is and we can check that the MAC address is not currently assigned to anything else.

cisco# show running-config arp
cisco#

Our sanity checks are ok so we are ready to proceed with the update. We must enter the configuration section by specifying that we will change the configuration from the terminal.

cisco# configure terminal
cisco(config)#

Once in the configuration section we can start changing the settings. The following line says that when we see the MAC address 0c1b.ae43.bd21 we are going to statically refer to it with the IP address of 192.168.1.69. The Cisco ASA/PIX knows that this is already in the DHCP pool and won’t allocate it again.

cisco(config)# arp inside 192.168.1.69 0c1b.ae43.bd21

We can check the change has been added with the following command:

cisco(config)# show running-config arp
arp inside 192.168.1.69 0c1b.ae43.bd21
cisco(config)#

If you have miss-typed or you would like to remove an old entry you can do so by prefixing the existing command with no. For example:

no arp inside 192.168.1.69 0c1b.ae43.bd21

The changes are currently only made in memory, so we need to write the current running configuration down to disk.

cisco(config)# write mem
Building configuration…
Cryptochecksum: 389f1812 7c29dd7b 50ad4ca0 4ce3fd5e

4396 bytes copied in 1.480 secs (4396 bytes/sec)
[OK]
cisco(config)#

And finally the job is done so we exit cleanly

cisco(config)#
cisco(config)# exit
cisco# exit

Logoff

Connection closed by foreign host.

Rebooting the printer will result in the printer coming back with the same IP address.

Many thanks to goldplated for his original article.