Jump to content
xisto Community

slu

Members
  • Content Count

    27
  • Joined

  • Last visited

Posts posted by slu


  1. I am kind of wondering why for some reason, Perl does not have an interactive mode in its parser like Pythong does in its. Also, Python comes pre-packaged with a GUI like parser and it is written in Python\Tk (I think that's what its called). I know that Perl has Perl\Tk, and I know it has an eval function. Why is there no interactive parser like that. I think I could come up with one. Anybody, wanna see if we can build a interactive module like the Python one?

    Several options for interactive mode already exists.

     

    Perl has a builtin debugger, that enables you to try code (and scripts) interactively. To get an debugging prompt start Perl like this:

    CONSOLE
    $ perl -d -e 1

     

    Loading DB routines from perl5db.pl version 1.28

    Editor support available.

     

    Enter h or `h h' for help, or `man perldebug' for more help.

     

    main::)-e:1): 1

    DB<1> print "Hello\n";

    Hello

     

    DB<2> exit;

    Debugged program terminated. Use q to quit or R to restart,

    use o inhibit_exit to avoid stopping after program termination,

    h q, h R or h o to get additional info.

    DB<3> q

    $

    you can read the man pages "man perldebtut" and "man perldebug" or perldebug and perldebtut to learn more.

     

    If the debugger isn't your thing, you can try the Perl Console, that seems to be very similar to the Python interactive mode: http://www.sukria.net/perlconsole.html

     

    It looks like this:

     

    Posted Image

     

    Another option is The Perl Shell (psh), which is exactly that: a shell aiming at being a replacement of your favorite shell (i.e. bash). It's a bit different fromt the debugger and console, but you might like it: https://sourceforge.net/projects/psh/


  2. I've never had the need (urge) to write a desktop app. (in any language). My first choice for doing such a thing, would be Perl. My second choice would be Java.

     

    Several GUI toolkits exists for Perl: Tk, Gtk, Win32, QT, and wx. Perl/Tk is the oldest and simplest, and it's cross platform. Wx is what I would check out first, unless the app. should only run on Linux or Windows - then I would go for Gtk or Win32...

     

    But if it's a game you're doing you have to look at Perl/SDL, which is a toolkit aimed at game.

     

    For inspiration check out the great and addictive arcade game Frozon Bubble - written in 100% Perl!


  3. Convert any number of seconds to days,hours,minutes and seconds. Useful for converting unix time differences into days,hours,minutes and seconds.

    Inputs: ConvertSeconds(no. of seconds)

    Returns: $days,$hours,$minutes,$seconds

    Assumes: 100% Accurate

    	sub ConvertSeconds {		...	}

    Your code does not work. Depending on the final if-statement $seconds might be undefined. A much simpler version would use the standard localtime() funtion:

     

    sub ConvertSeconds {	my ($secs, $minutes, $hours, $days) = localtime(shift);	return $days-1,$hours-1,$minutes,$secs;}


  4. This is a simple code to register and login.. this uses cookies.. i want to use sessions instead.. can someone tell how i can do it ?



    Your're confusing the terms a bit here. A session really isn't an alternative to using cookies. When using a session, the default behavior is to store the session using a cookie, which will happen automatically. Check out the documentation of start_session(), which you need to call to use sessions:

    http://dk2.php.net/manual/en/function.session-start.php

    If you don't want to rely on cookies at all, you either add the Session ID (SID) to all your urls/links or enable automatic url rewriting. You can read more about this here:

    http://forums.xisto.com/no_longer_exists/

  5. I'm guessing that $text = 'First Second'...

    You need to insert some wild cards, like this

    $search_text = '%' . str_replace(' ', '%', $text) . '%';

    and then do:

    SELECT * FROM `$table` WHERE `row` LIKE '$search_text'

    this should search for everything that includes the two words...

    You might need to put some extra spaces in the $searc_text...

  6. I'm now using a Windows machine and obviously the perl script doesn't work and I need a way to compile, sign and upload oll these files.

    Why wouldn't the perl script work? Have you tried ActivePerl? Most perl scripts work across platforms. And if ActivePerl doesn't work you could try installing Cygwin, where you get a more complete UNIX/Linux-like environment (including perl) on a Windows-system.

    I'm now trying to write a java app that compiles, signs and uploads the other program. At the moment I'm stuck on trying to get the new java app to create and send a command to compile the other program.

    I would suggest using a proper build tool. In the case of Java development Apache Ant is the standard. It has the ability to compile, sign and upload - just what you need...

  7. My code will looke like this

     

    if (navigator.appName="Whatever Opera's app name is") {     my code etc etc; }

    I know internet explorer's appName is Microsoft Internet Explorer and

    Firefox's is Netscape.

     

    Is Opera's appName Opera?

    204420[/snapback]


    No, Opera's appName is Netscape! It might seem weird, but it has been chosen for compatibility reasons....

     

    You need to check the User Agent String to detect whether a Opera browser is used. The User Agent String will include the name "Opera", so your code could be written like this:

     

    if ((navigator.userAgent).indexOf("Opera") != -1) {     your code etc etc;}

    If you really want to go in to the gory details of browser detection check out the Browser Capabilities Project.

  8. Yeah, the Evolt browser archive is a nice thing, esp. if you have a user/customer using some old system...

    But the guys at BrowserCam are a bit smarter. Here you can submit an url and a set of screen dumps are created automatically on several combinations of operating systems and browsers. See https://www.browsercam.com/

    Only bad thing: it's a paid service, but you can try it out for free, and the prices are reasonable.

    Implementing the functionality of BrowserCam yourself wouldn't be impossible. Start by installing some kind of virtualisation system (e.g. qdos or vmware), and you would be able to run several different operating systems on one machine. Alternativly you could make a multi boot machine, but then the machine had to do a reboot everytime a new OS was needed.

    Now each OS should be set up to do the following when starting (booting):

    1. look for an url (or list of urls) on a FTP-server,
    2. open the urls in the installed browsers
    3. taking screen shots of each browsers, and upload the image to the FTP-server

    Now the FTP-server could be on the same physical machine, where we are running all the test OS's virtually... the process might take some time, but it would run automatically, and your web design would be tested across several OS'es and browsers!

    It's not rocket science, but it will proberly take some trial and error.


  9. I cant seem to find a way of sending a response back in perl, anyone know of something similar to echo? I've looked through LWP but couldnt find anything suitable??

    179108[/snapback]


    That would be print. Here's the most simple perl/cgi-script:

    #!/usr/local/bin/perlprint "Content-Type: text/plain\n\n";print "hello";
    Notes:

    * You might need to change the path in the first (shebang) line, it depends on your platform...

    * Change text/plain to text/html if you want to return HTML

    * print is standard perl and has nothing to do with CGI/LWP - everything sent to standard out is send to the users browser.


  10. So far, I have installed Apache webserver and Java 2 EE. How

    do I get started with servlets and jsp pages? Are servlets and

    jsp pages same? I am able to code/compile/run java programs.

     


    An Apache webserver can not run servlets/jsp's... you need an servlet engine for that, for example Apache Tomcat - http://tomcat.apache.org/

     

    The Apache Tomcat has its own built-in webserver, but can also be used in conjunction with the Apache webserver. For developmet I deploy and run applications directly on the tomcat server.

     

    There's some ok documentation on the tomcat website. After having installed tomcat try the Application Developer's Guide - it's short and pretty east to follow: http://tomcat.apache.org/tomcat-5.5-doc/appdev/

     

    JSP and Servlets are not the same from a logical point of view, but when Tomcats "sees" a JSP-file it converts it into Java code which is compiled into a Servlet.


  11. You're trying to run Java code compiled with 1.5 SDK on an earlier VM (e.g. 1.4).

     

    Version 49 => Java 1.5 and 48 => Java 1.4

     

    By default compiling code with a 1.5 Java compiler will generate bytecode that only runs on a 1.5 VM, but you can set flags to make the bytecode backwards compatible.

     

    Tomcat 5.5.x is (AFAIK) buildt with 1.5 SDK, but with backwards compability enabled. Thus Tomcat can run on an 1.4 VM...

     

    You could either upgrade the VM Tomcat is running on, or compile your code with the "-target 1.4" option, e.g.

     

    javac -target 1.4 MyCode.java


  12. Hard to say. I like all that applies to GNU/GPL.

    149773[/snapback]


    I'll second that, but (not to start a flamewar) my favorites are:

     

    1. GNU Emacs - spend more than 6 hours daily using this (development, web design, etc.)

    2. Mozilla Firefox - a fantastic browser made even better with great extension like Adblock, Aardvark, Web Developer and Greasemonkey!

    3. Perl - this is the programming language I would take with me on a deserted island - it's just so versatile.

     

    And luckly all three products works on everything I use : Linux, Unix and Windows...


  13. I've been working with professional web development for more than five years, and in my experience very few solutions/customers have the need for "real enterprise components" (e.g. EJB's) - it's a bit overkill.That doesn't mean you should completely ignore the principles of multi tier development - it's just a question of the right balance.My instinct says that your setup (apache, tomcat, struts, hibernate, and sql server) is adequate.


  14. I second the template comment by stu. I just finished applying the new layout for my site, and if I had a template engine, it would have taken much less because the only thing I had to do when editing my pages was to move text around, and that took weeks.

    155723[/snapback]


    If doing a redesign of a complete site PHP-Mesh is the way to go. You can change the layout without changing your original files! PHP-Mesh inserts code before and after all php/html pages and takes the html apart and puts it together again. You describe how to put your page back together again (i.e. the (new) layout) with one or more Decorator classes. A simple decorator would look like this:

     

    <html>  <head>    <title>MySite :: <?php $page->title(); ?></title>    <?php $page->head(); ?>  </head>  <body>    <h1><?php $page->title(); ?></h1>    <?php $page->body(); ?>  </body></html>

    In the above example all pages will get a title that starts with "MySite :: " and the title of the page is repeated in a H1 at the beginning. There's an $page object available in all Decorators, it contains methods corresponding to html-tags. Each method returns the contents from the original page. As the Decorators are just php files you can do all kinds of coding (like switching designs on certain pages).

     

    It's awesome and seems like magic...

     

    See http://forums.xisto.com/no_longer_exists/

     

    The concept is based on SiteMesh, which does a similar thing for Java-based web sites.


  15. For the past three years most of my programming has been done in Java. But i also use Perl almost every day - mainly for smaller stuff: scripts and quick-and-dirty hacks.The very first language I learned was COMAL. Later I got a C64 and played with BASIC and Assembler. My first "real" language was C. I can't remember I what order I learned the rest of the languages I know, but Java is the latest addition to the list.If I had to select only one language (to take with me on an deserted island) it would be Perl.How about an programming language alphabet? Here's mine (letters in paranthesis indicates that I don't know (or recall) any language starting with that letter):Awk, Brainf*ck, C/C++, (D), E (great language on the good old Amiga), FORTRAN, (G), HTML, (I), Java, (K), Lisp, M4, (N), Oberon, Perl, QBasic, REXX, SQL, Tcl/Tk, UML, Visual Basic/VBScript, (W), XML, (Y), (Z)I could add more to the list, like PHP and Pascal, but that wouldt fill out any emty slots...Does anybody have a full alphabet?


  16. then you can use gd to make images with php

     

    Just make sure that GD-support is enabled in the PHP you're using (it usually is, but you can always try a call to phpinfo()).

     

    Here's a small example that does what the OP is asking for:

     

    <?phpif (isset($_REQUEST['img'])) {  header("Content-type: image/png");  $image = imageCreateFromPng("background.png");  $black = imageColorAllocate($image, 0, 0, 0);  imageString($image, 5, 10, 10, $_REQUEST['img'], $black);  imagePng($image);  imageDestroy($image);  exit;}?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <title>Add text to image</title>  </head>  <body>    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">      Text:      <input name="text" type="text" value="<?=$_REQUEST['text']?>">      <input type="submit" value="OK">    </form>    <br>    <img src="<?=$_SERVER['PHP_SELF']?>?img=<?=$_REQUEST['text']?>">  </body></html>

    save the above somewhere your webserver can find it and place a png image called background.png in the same directory.

     

    For more information and examples check http://php.net/manual/en/ref.image.php


  17. My favorite client is Mutt - it's a text-based console app. which means that,1. I can control everything with my keyboard2. it's fast3. only shows the text (ignoring anoying colors and fonts)besides that it is highly customizable, handles threaded messages very good, and supports both POP3, IMAP and PGP/GPG.I also have Thunderbird installed, and it's is my absolute favorite of the non-console-based clients.Of the web-based email clients I think Yahoo and GMail are both very good. In contrast to Hotmail, which really sucks: it's very limited in both message/inbox size and functionallity.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.