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);

Remote Desktop: Printing to a local machine (XP)

February 27th, 2009

The way this works depends on the server having the drivers for the printer on the machine you are rdp-ing too.

When connecting via rd make sure the Printers tick box is ticked in the local resources tab of your remote desktop settings (for that particular account)

Connect via rd and your printer should appear in Printers and Faxes.

I have had a case of this now where the printer does not connect (I believe after installing a new printer on the remote network).  I remote desktop-ed into the server and added a new (dummy) printer of the type I needed to print from on my local machine.  After doing this the drivers appeared to be reloaded and I then had two printers - the one I had manually added and now the session based printer I actually wanted to print too.  I deleted the manually added printer and it’s been fine since.

Protected: Site Structure Package

February 24th, 2009

This post is password protected. To view it please enter your password below:

Search for installed packages on Linux

February 6th, 2009

rpm -qa | grep firefox

(searching for firefox for example)

Search moodle for crazy overrides!

February 5th, 2009

SELECT *  FROM `role_capabilities` WHERE `roleid` = 7 and capability LIKE ‘%forum%’ ORDER BY `role_capabilities`.`capability` ASC

Find files larger than 50mb on Linux through the command line

February 5th, 2009

find / -type f -size +50000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

MySQL search and replace

February 5th, 2009

UPDATE resource SET alltext = replace(alltext,””,”"), name=replace(name,””,”"), summary=replace(summary,””,”")

UPDATE assignment SET description = replace(description,””,”")

UPDATE block_search_documents SET title = replace(title,””,”")

UPDATE cache_text SET formattedtext = replace(formattedtext,””,”")

UPDATE course_sections SET summary = replace(summary,””,”")

UPDATE event SET description = replace(description,””,”")

UPDATE forum SET intro = replace(intro,””,”")

UPDATE forum_posts SET message = replace(message,””,”")

UPDATE glossary_comments SET entrycomment = replace(entrycomment,””,”")

UPDATE glossary_entries SET definition = replace(definition,””,”")

UPDATE label SET name = replace(name,””,”"), content = replace(content,””,”")

UPDATE lesson_pages SET contents = replace(contents,””,”")

UPDATE message SET message = replace(message,””,”")

UPDATE message_read SET message = replace(message,””,”")

UPDATE question SET questiontext = replace(questiontext,””,”"), generalfeedback = replace(generalfeedback,””,”")

UPDATE question_answers SET feedback = replace(feedback,””,”")

UPDATE quiz_feedback SET feedbacktext = replace(feedbacktext,””,”")

TAGS - moodle - strange characters - search and replace

Convert mysql database to unicode

January 27th, 2009
ALTER DATABASE `dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci

Configuring upload limits in php.ini

December 10th, 2008

Try these:

post_max_size = 16M
upload_max_filesize = 16M
memory_limit = 16M

(memory_limit only affects this if you have configured
php with –enable-memory-limit)

vi /etc/php.ini

Compare perl strings - operators

November 20th, 2008

if ($string1 eq $string2) { # equal too

print”\$string1 is equal to \$string2\n”;

} elsif ($string1 lt $string2) { # less than

print”\$string1 is less than \$string2\n”;

} elsif ($string1 gt $string2) { # greater than

print”\$string1 is greater than \$string2\n”;

}

if ($string1 ne $string2) { # not equal too

print “\$string1 is not equal to \$string2\n”;

}