Description

List of various tests written and that could possibly be re-used. Files that contains a // Tags: as the first or second line are automatically sorted by tags. Files with a description, // Description:, will be searchable.

The works included in this archive of sorts stem from a whole variety of places, most of the snippets included here are bits of code that I've used on a wide range of projects, collected over a long period of time thus making it difficult to know for sure who created them in the first place. Let me know if there's code here that shouldn't be.

Files

svn-revision.phps (Show source)
Tags: svn, revision
Description: Returns the revision number currently in use. Assumes that the svn-directory is local. From Gregarious.net and made independent of the projects own functions and classes
Source: http://svn.gregarius.net/trac/browser/trunk/rss/util.php?rev=959

code-mail-address.phps (Show source)
Tags: E-mail, mail(), preg_match()
Description: Function to transform (to example) "User@example.net" in "user AT example DOT net" and conversely.
Source: http://wwww.php.net/manual/en/function.str-replace.php#71408

compress-file.phps (Show source)
Tags: Compress file, gzip, filesize(), file
Description: Compress a file

conditional-probability.phps (Show source)
Tags: Probability
Description: Returns conditional probability of $A given $B and $Data. $Data is an indexed array. Each element of the $Data array consists of an A measurement and B measurment on a sample item.

create-password.phps (Show source)
Tags: Password
Description: Creates a password hash eight characters long

domain-from-url.phps (Show source)
Tags: preg_match(), host, domain
Description: Getting the domain name out of a URL

get-bytes.phps (Show source)
Tags: Bytes
Description: Calculates bytes from GB, MB or KB

get-filename.phps (Show source)
Tags: filename, file, array_pop()
Description: Gets filename from a string or path

in-directory.phps (Show source)
Tags: File handling, directories, security, validation
Description: Finds out wether a certain file is located within or underneath a certain directory or not
Source: http://www.php.net/manual/en/function.dirname.php#52326

inside-frame.js (Show source)
Tags: Frame, window.self
Description: Checks whether or not the current page is shown in a frame or not

is-defined.js (Show source)
Tags: defined, typeof()
Description: Returns false if variable is undefined

mysql-to-date.phps (Show source)
Tags: Date(), mysql
Description: Convert MySQL-date format to Norwegian date formatting
Source: http://www.php.net/manual/en/function.date.php#82374

quicksearch.html (Show source)
Tags: Search, keypress
Description: Submit field when user presses the return-key

remove-non-numeric.phps (Show source)
Tags: preg_match_all(), numeric, numbers, remove characters
Description: Remove non alpha-numeric characters from string

week-limits.phps (Show source)
Tags: Week, calendar, date()
Description: Returns the start- and end time of the week as an array
Source: http://www.php.net/manual/en/function.date.php#73798

hex-to-rgb.phps (Show source)
Tags: Colours, hex, rgb
Description: Decode an HTML hex-code into an array of R,G, and B values. Accepts these formats: (case insensitive) #ffffff, ffffff, #fff, fff