Wednesday, February 23, 2005

Php without global vars using GET

I post here about work in php without global vars, now I offer you another post but using GET as a METHOD, not POST. Here's the code:

<?
if ($_GET['table']) {
$table = $_GET['table'];
echo "You wanna select this: $table";
}else {
echo "You didn't say a word";
}
?>

Tuesday, February 22, 2005

I've discover pello's web, he offers us a comic strip : c0der's where you may find a couple of carachters (C++ developer, Perl coder, Java fan, ...) working at an ISP, the one I like is Perl coder, for sure.

Let my highlight some of them:

Monday, February 21, 2005

Silent PC in five simple steps

Bigruin offers us five simple steps to a quieter PC, they all very easy to accept, not allways so easy to achieve:

  1. Colling fans
  2. Cases
  3. Fan Controllers
  4. Power Supplies
  5. Noise / Vibration Isolators

Since a lot of people use to keep on their PC's for downloading or to work as a firewall / switch / router, it may be interesting.

Free Techs and Programming Books

I don't remember how, but some I come to http://techbooksforfree.com/, a place to find links to free avalaible book on computing and programming issues. You may find books about system administration (like those about FreeBSD) or those those book php programming ...

Php without global vars

I was trying a simple form write in php. As usual, I try it in the old way, look for an example and then copy and paste... unsuccessfull ...
After become a little bit crazy I remember those changes done by php team around register globals in 4.2.0

I look around for a while, specially reading php documentation and I found very good examples and explanations.For example at register globals documentation page I found inspirer contributions. Now I offer you mine own code:
if ($_POST['submit']) {
...
$name = $_POST['name'];
...
echo "You say $name";
}else{
...
echo "<form>Nombre:<input type="text" name="name">
<input type=...>
</form>";
}

I hope it would help somebody...

Friday, February 18, 2005

Append a new line with sed

I've write before about how much I like Perl ... well, related with Perl and command line you got sed wich is:
Ed is a line-oriented text editor, used to create, display, and modify text files (both interactively and via shell scripts). For most purposes, ed has been replaced in normal usage by full-screen editors (emacs and vi, for example).

You got a file and you want to append this new line under these pattern.

What I've done is

  1. create a file intructions.ed containing
    g/pattern/a\
    this new line
    w
    q

    ... and save this file
  2. assume that original file and intructions.ed are in the same path, then type
    ed original_file.txt < instructions.ed
  3. Done! you see a number at your screen, wich are bytes after and before been tracted by you intructions.ed file

sed are used for pattern substitutions but not usually for append a new line, that why I post this lines.
P.D There were a mistake at this entry I've fixed, you must finish with a backslah after final a (this a stands for append), otherwise it shouldn't perform anything...