Feed on
Posts
Comments

Archive for the 'Programming' Category

Even Waterstones …

This, from the UK’s leading high street bookseller.  You’d expect them to get it right, wouldn’t you? It should be “Waterstones.com has shipped your order.”

Read Full Post »

Wall-E

This movie has had rave reviews all over the place, but the one thing all those reviews fail to mention is that the film is bloody awful. It’s a disappointing triumph of style over substance. The visuals are nothing short of stunning - almost real in their detail - but the plot is [...]

Read Full Post »

The wine is good but, like all fast food, the KFC never lives up to the picture. Zinger Tower Burger. “Tower”, my arse. It’s crap, but after watching a bunch of grown-ups playing rounders for a couple of hours, it’s just about tolerable.

Read Full Post »

Save & Delete Attachments

This macro for Outlook 2002 will traverse every folder in your “Inbox” and then save any attachments to a location you speficy, mirroring the structure of your Inbox. Once saved, the attachments are removed from the email message. A note is added to the top of affected messages to indicate where the attachment has been [...]

Read Full Post »

Strip HTML Tags

Fairly self-explanatory. This example gets its input from a file called ‘filename’, strips the HTML markup and displays what’s left in the browser.
<?
$fp=fopen (”filename”,”r”);
$file=fread ($fp,filesize (”filename”));
$fclose($fp);
$pattern=”‘<[\/\!]*?[^<>]*?>’si”;
$replace=””;
$file = preg_replace ($pattern, $replace, $filev[$r]);
print “$file”;
?>

Read Full Post »

RC4 Encryption

To use this code, simply call the EnDeCrypt function with two parameters: the string you want to encrypt/decrypt; the encryption password.

<?
function EnDeCrypt($plaintext,$strPwd)
{
$intLength=strlen($strPwd);
$sbox=Array();
$key=Array();
$cipher=”;
$i=0;
$j=0;
for ($a=0; $a<256; $a++)
{
$key[$a]=ord(substr($strPwd,($a % $intLength),1));
$sbox[$a]=$a;
}
$b=0;
for ($a=0; $a<256; $a++)
{
$b=($b + $sbox[$a] + $key[$a]) % 256;
$tempSwap = $sbox[$a];
$sbox[$a] = $sbox[$b];
$sbox[$b] = $tempSwap;
}
for ($a=0; $a<strlen($plaintext); $a++)
{
$i=($i+1) % 256;
$j=($j + $sbox[$i]) % 256;
$temp=$sbox[$i];
$sbox[$i]=$sbox[$j];
$sbox[$j]=$temp;
$k=$sbox[($sbox[$i] + $sbox[$j]) % 256 [...]

Read Full Post »

MS Access Database Structure

This VBScript ASP writes the structure of a MS Access database to the browser. Change the value of dbName accordingly.

<%
dbName=”c:\temp\temp.mdb”
Set DataConnection = _
Server.CreateObject(”ADODB.Connection”)
DataConnection.ConnectionString = _
“Provider=Microsoft.Jet.OLEDB.4.0; _
Data Source=” & dbName & “; _
Jet OLEDB:Database Password=dbpwd;”
DataConnection.Open
Set rs = DataConnection.OpenSchema(20)
While rs.EOF <> True
If Left(rs.Fields(”Table_Name”).Value, 4) <> “MSys” Then
Response.Write rs.Fields(”Table_Name”) & “<br>”
Set DataSet = DataConnection.Execute(”SELECT * FROM _
[" & [...]

Read Full Post »

List Form Elements

This VBScript ASP writes the contents of form fields from the previous page (submitted with the POST method) into hidden fields on the current page. I found this handy when I needed to spread a form over several pages - it’s far quicker than writing hidden fields by hand, and you don’t have to worry [...]

Read Full Post »

LTrim() RTrim() Trim()

To use these, just call LTrim(), RTrim(), or Trim() with the string you want trimmed.

<script type=”text/javascript”>
<!–
function LTrim(trimInputString)
{
while(trimInputString.charAt(0)==” “)
trimInputString=trimInputString.substring(1,trimInputString.length);
return (trimInputString);
}
function RTrim(trimInputString)
{
while(trimInputString.charAt(trimInputString.length-1)==” “)
trimInputString=trimInputString.substring(0,trimInputString.length-1);
return (trimInputString);
}
function Trim(trimInputString)
{
while(trimInputString.charAt(0)==” “)
trimInputString=trimInputString.substring(1,trimInputString.length);
while(trimInputString.charAt(trimInputString.length-1)==” “)
trimInputString=trimInputString.substring(0,trimInputString.length-1);
return (trimInputString);
}
//–>
</script>

Read Full Post »

List Last x Days

To show the dates for Today - x days, set the value of x accordingly.

<script type=”text/javascript”>
<!–
DateToday = new Date();
x=7;
for (y=0; y<x; y++)
{
MyDate = new Date(Date.UTC(parseInt( _
DateToday.getYear()), _
parseInt(DateToday.getMonth()), _
parseInt(DateToday.getDate()))- _
(60*60*24*1000*y));
MyDateString=MyDate.getDate() + ‘.’ _
+ parseInt(MyDate.getMonth()+1) _
+ ‘.’ + MyDate.getYear();
document.write (MyDateString + “<br>”);
}
//–>
</script>

Read Full Post »

Next »