tie the knot

lab :: papervision3D torus knot demo

tie the knot - papervision3D demo

so i had the chance this weekend to create a few 3D models and export their geometry into papervision3D primitives. so i decided to create a demo, using both my as3 torusKnot primitives and the new flex accordion component. about the time i finished my demo i decided to re-sync my pv3d folder with the svn. at that exact same moment their was a slip-up. somehow one of the new dev materials got leaked into the public svn. the new material features dynamic lighting! so i decided to hack it into my new demo. so enjoy my custom primitive shadedColorMaterial demo created in flex3.

Read: tie the knot »

papervision3D

code :: real 3D in flash

papervision3D logo

so i finally got a copy of adobe cs3 and flex builder2. flex is amazing, combining mxml and actionscript 3 together into a seamless package. now that im on the as3 tip, i decided to dive into papervision3D. pv3d is a set of actionscript classes that are used to create 3D objects within the flash environment. it's currently in beta and the source code is only available to osflash emailing list members. so if you want it signup here. thanx to carlos for creating pv3d, and to his girlfriend for convincing him to release the project open source!

pure php email validation

code :: using regular expressions

<?php
$email = 'someone@somewhere.com';
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
    //invalid email
} else {
    //valid email
}
?>

SQL get last ID

code :: mssql and mysql

here's a simple SQL script that returns the last row created. this is great for when you add a new record that has an autogenerated id and you need that number.

mssql

CREATE PROCEDURE [dbo].[getLastLogin]
AS
SELECT TOP 1 *
FROM dbo.login
ORDER BY id DESC
GO

mysql

SELECT * FROM `login` 
ORDER BY `id` DESC
LIMIT 1,1;

graphic reset buttons

code :: w/o javascript

i was having some trouble at work creating form buttons with graphics for reset buttons. i just thought someone might be interested in my non-javascript solution:

<button style="background: none; border: none;">
<img src="reset.jpg" alt="" />
</button>

post and querystring vars in dotnet

code :: asp.net c#

here's a nice little snip of c# code. this is meant to be used in an asp.net web application. the following code will return either a querystring variable or a post variable, it tries both and finds the valid one.

public string RequestParam(string paramname)
{
    string result = string.Empty;
    if (Context.Request.Form.Count != 0)
    {
        result = Convert.ToString(Context.Request.Form[paramname]);
    }
    else if (Context.Request.QueryString.Count != 0)
    {
        result = Convert.ToString(Context.Request.QueryString[paramname]);
    }
    return (result == null) ? string.Empty : result.Trim();
}

random page perl script

code :: CGI randomization

place this code in a file called index.cgi, chmod it to 775, and place it in a directory of html files. this script will pick one of the files in the specified directory at random, and print it to the screen. refresh the page for a new random one.

#!/usr/bin/perl
print "Content-type: text/html\n\n";
 
#print "<pre>";
$basep = "/wwwroot/path2/randomdir";
 
srand(time ^ $$);
#print "got random time...\n";
 
@files = `ls $basep/*.html`;
#print "got file list...\n";
#foreach (@files) { print "-----$_\n";}
 
$file = rand(@files);
#print "got random file...$phrase\n";
 
$nupath = "$files[$file]";
#print "got new path...$nupath\n";
 
open(LOG, $nupath) or die "$!\n"; 
while () 
{
  print $_;
}
close (LOG);
#print "</pre>";

exit;