Perl arrays within arrays

March 9th, 2010

http://www.suite101.com/article.cfm/perl/94552

http://www.misc-perl-info.com/perl-array-length.html
EXAMPLE

# Parts and Programme Codes

@PSUB01 = (’PSUB01′,[”Part A”,”Part B”,”Part I”]);
@PSUB02 = (’PSUB01′,[”Part A”,”Part B”]);
@PSUB03 = (’PSUB03′,[”Part A”,”Part B”]);
@PSUB12 = (’PSUB12′,[”Part A”,”Part B”,”Part I”]);
@PSUB13 = (’PSUB13′,[”Part B”,”Part I”]);

@programmecodes = (\@PSUB01,\@PSUB02,\@PSUB03,\@PSUB12,\@PSUB13);

Useful information on getting files (local/urls/etc)

February 24th, 2010

http://www.php-mysql-tutorial.com/wikis/php-tutorial/reading-a-remote-file-using-php.aspx

EAccelerator - max your PHP

February 19th, 2010

http://www.geektips.net/105/how-to-install-eaccelerator.html

Setting up Yum on FC2

February 6th, 2010

http://forums.spry.com/centos-fedora-redhat/201-setting-up-yum-fc2.html

Upgrade to PHP 5 on Plesk 7.5.4

February 6th, 2010

http://forums.serverbeach.com/showthread.php?t=6125

Upgrading plesk mysql database

February 3rd, 2010

Great article thanks Jeff:

http://jeffbaier.com/articles/how-to-upgrade-mysql-on-a-server-with-plesk/

Restoring a MySQL replication slave (linux)

January 27th, 2010

If you find the slave you are using is out of sync too much to skip and ignore you really need to do a rebuild.  Sometimes this isn’t possible as the database is a live system and cannot be stopped.

Best to open two windows as the next couple of steps need to be done quickly.

On the master server login to mysql and type; show master status;

Make a note of the file and position (masterserver-bin.00000001,  123321123)
Stop the mysql service on the slave server, service mysqld stop

Now you need to copy the live database (MYI, etc.) files from the master server to the slave:

cd /var/lib/mysql/databasename

scp -pr * 192.168.0.1:/var/lib/mysql/databasename/
(p is to copy permissions and r is to copy recursive just in case)

When the copy finishes restart the service on the slave; service mysqld restart

stop slave;

change master to master_log_file=’servername-bin.0000001′, master_log_pos=101010101010;

Now start the slave (start slave;) and run `show slave status;` you may have to skip a couple of files (depending on your db size and how quick you were in the first couple of steps)
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; slave start; show slave status;

Repeat the last step until the database reports no duplicate entries (we also had to repair a table or two - easy `repair table tablename;`)

Deleting incorrectly submitted assignments

January 27th, 2010

Open the submitted assignments grading page and hover over the file that has been submitted

At the bottom left hand corner of your browser it should give you the full url to that file including after the word assignment the assignment id (i.e. 201) and the student id (i.e. 56), e.g. /assignment/201/56/submittedfile.doc
Open the files directory in a new tab or window and navigate into moddata/assignment/201/56/

Right click on the submitted file and save to desktop (just incase something goes wrong)

Now delete the folder and the file in it (/56/)

There is still a row in the database that says the student has submitted a file so open the database and the assignment_submissions table, search for the assignment id (201) and userid (56)

Delete the row

Go back and log in as the student to check they can now upload a file.

How to identify the file extension of an uploaded file PHP

November 11th, 2009

$ext = strtolower(substr(strrchr($file[’name’], ‘.’), 1));

PHP regexp to match a URL

June 18th, 2009

http://snipplr.com/view/2371/regex-regular-expression-to-match-a-url/

$url = preg_replace(’@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@’, ‘$1‘, $url);