Wednesday 25 April 2012

OpenAid

http://drupal.org/project/openaid

"OpenAid is a turnkey website platform designed and built by international public health and knowledge management experts to help small NGOs and international development projects create cost-effective program-focused websites quickly."

Google Drive SDK - PHP example

https://developers.google.com/drive/examples/php

"DrEdit PHP is a sample Google Drive app for the Google Drive SDK written in PHP. It is a text editor capable of editing files with the MIME types text/* and extensions such as .txt.html.csv.xml, etc. that are stored in a user's Google Drive. This article describes the complete application to help you in your integrations."


Hmm..  i think I've got a Drupal module idea.

Managing Javascript in Drupal 7

http://drupal.org/node/756722

"Drupal 7 has introduced several new techniques that allow you far greater flexibility and control in the scripts you can have on your Drupal site's pages."

Tuesday 25 January 2011

Webform module out of memory

The webform module will give a PHP fatal out of memory error when downloading and if your result set is rather large ( tens of thousands of records)..

Issue is discussed here, along with patches

Thursday 13 January 2011

Finding fragmented MySQL tables and optimising them - bash script

Via here


Note: if you just want to find fragmented tables and don't want to optimise, just comment out the "OPTIMIZE TABLE" line in the script below


#!/bin/sh

echo -n "MySQL username: " ; read username
echo -n "MySQL password: " ; stty -echo ; read password ; stty echo ; echo

mysql -u $username -p"$password" -NBe "SHOW DATABASES;" | grep -v 'lost+found' | while read database ; do
mysql -u $username -p"$password" -NBe "SHOW TABLE STATUS;" $database | while read name engine version rowformat rows avgrowlength datalength maxdatalength indexlength datafree autoincrement createtime updatetime checktime collation checksum createoptions comment ; do
if [ "$datafree" -gt 0 ] ; then
fragmentation=$(($datafree * 100 / $datalength))
echo "$database.$name is $fragmentation% fragmented."
mysql -u "$username" -p"$password" -NBe "OPTIMIZE TABLE $name;" "$database"
fi
done
done

Wednesday 12 January 2011

Find fragmented tables in MySQL

Via Mindraven:

Over time some of your MySQL tables may end up fragmented. If you run any type of diagnostic script like mysqltuner, it will even tell you how many of your tables are fragmented. You can easily fix this by optimizing the fragmented tables. The problem is, you might not know which tables are fragmented.

Here’s a quick little query you can run that will give you the tables that are fragmented and how badly fragmented they are:

select TABLE_NAME, TABLE_SCHEMA, Data_free from information_schema.TABLES where TABLE_SCHEMA NOT IN ('information_schema', 'mysql') and Data_Free >0;

Just in case anyone didn’t catch the optimize bit above. Once you’ve found your fragmentend tables, you can fix them with the following query, replacing %TABLENAME% with the actual table name:

optimize table %TABLENAME%

JMeter and MySQL

Jmeter and MySQL - a How To on installation and configuration.

Tuesday 21 December 2010

mysql dumping via an ssh tunnel

First , connect to the remote mysql instance via an ssh tunnel on port 10000

ssh -f -N -L 10000:localhost:3306 remoteuser@remoteserver

Try out the connection via the mysql client

mysql -u remote_sql_user --password=remote_sql_pass -h 127.0.0.1 -P 10000 remote_db_name

Type "show databases" , and you should see a list of databases available on the remote sql instance.

To dump out a database locally, quit the mysql client, and type :

mysqldump --host=127.0.0.1 --port=10000 --user=remote_sql_user ==password="remote_sql_pass" --verbose > /your_local_directory/name_of_db.sql


For very large db dumps, it is faster to use zcat & gzip, then pipe to mysql :

gzip name_of_db.sql

zcat name_of_db.sql.gz | mysql -u local_sql_user --password=local_sql_pass --database=name_of_db

Friday 17 December 2010

Convert m4a to mp3

Via the Debian Linux Desktop survival guide


Using faad, convert the m4a to wav:
$ faad -o abc.wav abc.m4a

Yes you read that right - faad has output as the first option, and input as the second option.

Then using lame convert wav to mp3. Bitrate is specified with the "-b" option.
$ lame -h -b 192 abc.wav abc.mp3

You can combine this into a script that will convert all m4a's in a directory into mp3s
for i in *.m4a
do
faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"
done