Jump to content

Koobi

Staff Alumni
  • Posts

    419
  • Joined

  • Last visited

    Never

Posts posted by Koobi

  1. In terms of being appealing to a potential employer, would you say that getting your RHCE (Red Hat Certified Expert) and/or Zend certification is a good idea?

     

    I have over 7 years of working experience as a developer but I have no bachelors degree (only an associates) so, what do you think?

     

    I am getting my CCNA within the next 30 days. I may consider CCNP as well.

    Feel free to suggest any other certifications as well.

  2. String replacement functions are ideal when you know exactly what you want to replace.

     

    If you are unsure about exactly what you want to replace but you have a vague idea of where the data you want to replace will appear, you could use pattern matching.

     

    Pattern matching in PHP is done using Regular Expressions.

     

    I am assuming you will always want to replace anything that appears within the quotes of the href attribute with your own text. If so, this will work:

    <?php
    $subject = "<a class=\"scorelink\" target=\"match_details\" onclick=\"window.open('','match_details','width=400,height=188,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=yes')\" href=\"/default.dll/game?comp=cl_group_A&game=357186\">";
    
    $replaced = preg_replace('/href=(["\'])[^\1]+\1/i', '', $subject);
    
    
    echo htmlspecialchars($subject);
    echo '<hr />';
    echo htmlspecialchars($replaced);
    

  3. Oh wow, that's excellent :) Never thought of it that way.

     

    This works fine:

    SELECT `users`.`id` AS `uid`,
                 `users`.`name_first`,
                 `users`.`name_last`,
                 `cinemas`.`id` AS `cid`,
                 `cinemas`.`title`
    FROM `cinemas`
    LEFT JOIN `users_cinemas`ON`users_cinemas`.`cinema_id`=`cinemas`.`id`
    LEFT JOIN `users`ON `users`.`id`=`users_cinemas`.`user_id`
    WHERE `users`.`id`=1
    

    Do you see any potential bugs?

     

     

    Btw, any tips on naming conventions for a database? As in, naming conventions for field names, table names, join tables, primary keys, foreign keys, etc?

  4. I think you guys misunderstood what I was saying. Or maybe I just didn't explain completely in my last post.

     

    I am running on a custom compile of 5.3 too but the thing is, I'm building a framework for people to download and use.

     

    So if Joe Schmo wants to download my framework and use it on his server and he has no control over the PHP version on his server, he won't use my framework.

     

    I'm hoping to complete the framework by March. I'm just wondering if it's a realistic goal to build for 5.3 in case 5.3 is not widely supported by then.

     

    On average, how long does it take for hosts to upgrade to a release? 6 months? 1 year?

    Any ideas guys? I've been out of the loop for a while :/

  5. I got my first PC around 1999.

     

    Before that I used to mess around with Pascal/QBASIC/C/C++ at the school computer lab on my own. Funny thing is I have never, in my life, taken computing as a subject haha but it seemed so appealing.

     

    Anyway, after the PC in 99, I used to use the net a lot and I really got into design, almost sat for the Adobe Certified Expert test because I was so into it.

    Then I wanted to turn the designs into HTML so I started mucking about with HTML.

    Of course, that led me to CSS. I eventually got sick of CSS because it's so browser depedant and I wanted something dynamic so I got into JavaScript for a bit.

    Again, JavaScript was browser dependant and that really annoyed me so around 2002-2003, I thought I'd give PHP a shot since it seemed so easy to get started with and the syntax was somewhat similar to C.

     

    I finally settled with PHP because unlike client side languages, it behaves as expected on almost any environment.

     

    I also liked the fact that I could quickly implement ideas in PHP because it's such a light language. Really easy to build working prototypes.

    I started freelancing with PHP around 2005 and loved it.

     

    Took a small break from all scripting for about two years, beginning around 2007 to sort out some personal matters.

     

    I started messing with Ruby On Rails about 1.5 years ago just for fun. Mostly experimenting with things. I love their philosophy and the Ruby language is pretty awesome IMO. So I'm in between PHP and Rails at the moment.

     

    Wow...long post :)

  6. No clue, it generally takes them a while just because it tends to break a lot of scripts doing updates. I know some hosts still run 4.x EEEK.

     

    The best bet is to do a dedicated and you can update it yourself :) But yea, I am sure you can find some hosts with 5.3 on them right now. Or you can probably coerce your webhost to upgrade by paying them an admin fee to do it, as they can still keep everyone else at a PHP version lower than 5.3 by setting the version in php.ini (at least I think you can).

     

    I would say March 2010 is a good estimate.

     

    Oh I'm on a rackspace cloud so I can install any version I want :D

    But I'm creating a framework and I can't decide on making the minimum requirements PHP 5.2 or 5.3

     

    I would love to go with 5.3 simply because there's so much more you can do with it...but if there's going to be little support, what's the point :/

     

     

    Last I checked, RHEL based Linux distros were lame enough to only support 5.1.

    I'll bet Debian will take about a year to get 5.3 :/

  7. I love some of the new things that PHP 5.3 brings with it.

    The problem is, it's quite new (6 months old?)

     

    I was wondering, how long do you guys think it would be before most reputed web hosts out there would start using PHP 5.3 as opposed to 5.2?

     

    I hope they begin supporting 5.3 before March 2010 at least!

  8. hmmm...So the idea is to start with the joining table and use left joins on that to connect to the others?

     

    I should re-learn my SQL joins. Can you recommend a good resource?

     

    In the meantime, using this query, on what basis would I order it to get the results I want?

  9. Oops. Yeah, my mistake.

     

    I would change that to:

    SELECT *
    FROM `users`, `cinemas`, `users_cinemas`
    WHERE `users`.`id`=`users_cinemas`.`user_id`
      AND `cinemas`.`id`=`users_cinemas`.`cinema_id`
    

     

    But how do I make sure my data is ordered the way I want it?

  10. Actually, I was hoping you could tell me the best way to do that too.

     

    I've forgotten a lot of my SQL during my hiatus and I used to mostly use ORM's anyway so I never really used raw SQL but I want to get back into it.

     

    Right now, I would do it like this:

    SELECT *
    FROM `users`, `cinemas`, `users_cinemas`
    WHERE `users`.`id`=`users_cinemas`.`user_id`
      AND `cinemas`.`id`=`users_cinemas`.`cinema_id`
      AND `users`.`id`=1;
    

  11. $ mysql -V
    mysql  Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2
    

     

    SQL is not one of my forte's, unfortunately, so I need your help with this :)

    Let me first show you the tables involved.

    mysql> show tables;
    +----------------------+
    | Tables_in_issue_sort |
    +----------------------+
    | cinemas              | 
    | users                | 
    | users_cinemas        | 
    +----------------------+
    3 rows in set (0.00 sec)
    
    mysql> describe cinemas;
    +-------+-------------+------+-----+---------+----------------+
    | Field | Type        | Null | Key | Default | Extra          |
    +-------+-------------+------+-----+---------+----------------+
    | id    | smallint(6) | NO   | PRI | NULL    | auto_increment | 
    | title | varchar(25) | NO   | UNI | NULL    |                | 
    +-------+-------------+------+-----+---------+----------------+
    2 rows in set (0.00 sec)
    
    mysql> describe users;
    +------------+-------------+------+-----+---------+----------------+
    | Field      | Type        | Null | Key | Default | Extra          |
    +------------+-------------+------+-----+---------+----------------+
    | id         | smallint(6) | NO   | PRI | NULL    | auto_increment | 
    | name_first | varchar(15) | NO   |     | NULL    |                | 
    | name_last  | varchar(15) | NO   |     | NULL    |                | 
    +------------+-------------+------+-----+---------+----------------+
    3 rows in set (0.00 sec)
    
    mysql> describe users_cinemas;
    +-----------+-------------+------+-----+---------+-------+
    | Field     | Type        | Null | Key | Default | Extra |
    +-----------+-------------+------+-----+---------+-------+
    | user_id   | smallint(6) | NO   |     | NULL    |       | 
    | cinema_id | smallint(6) | NO   |     | NULL    |       | 
    +-----------+-------------+------+-----+---------+-------+
    2 rows in set (0.01 sec)
    

     

     

    As you can see, `users_cinemas` is a join table.

     

     

     

     

     

     

    I have to display a form where the Users details can be edited.

    This form would have a bunch of checkboxes of the Cinemas that can be assigned to the User.

     

    The checkboxes of Cinemas must be displayed in a particular order.

    The order is, the Cinemas which are assigned to the User being edited must appear first.

     

     

     

    How would I do this?

     

    Thanks for reading.

     

     

     

     

    :EDIT:

    I've included the SHOW CREATE TABLE output as well:

    mysql> show create table cinemas;
    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table   | Create Table                                                                                                                                                                                      |
    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | cinemas | CREATE TABLE `cinemas` (
      `id` smallint(6) NOT NULL auto_increment,
      `title` varchar(25) NOT NULL,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `title` (`title`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.01 sec)
    
    mysql> show create table users;
    +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table | Create Table                                                                                                                                                                                             |
    +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | users | CREATE TABLE `users` (
      `id` smallint(6) NOT NULL auto_increment,
      `name_first` varchar(15) NOT NULL,
      `name_last` varchar(15) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
    +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> show create table users_cinemas;
    +---------------+--------------------------------------------------------------------------------------------------------------------------------------------+
    | Table         | Create Table                                                                                                                               |
    +---------------+--------------------------------------------------------------------------------------------------------------------------------------------+
    | users_cinemas | CREATE TABLE `users_cinemas` (
      `user_id` smallint(6) NOT NULL,
      `cinema_id` smallint(6) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
    +---------------+--------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.01 sec)
    

  12. What can you control under linux that you can't control under Windows?

     

    wow. i'd say almost everything :)

    i feel so restricted when i get on my dad's Windows PC. Windows comes packaged a certain way and there's very little you can change in comparison to Linux. In Linux, you can take the entire OS apart if you really want to.

    In Windows, I can maybe customize my theme, mess with the registry a little and little things like that.

     

    luckily i'm not so fond of computer games so i don't need Windows :D

     

    i do a lot of audio production and so i have a MIDI controller. i can even hook that up via USB on Ubuntu and use audio software like RoseGarden and do all my production work.

     

     

    my dad uses Avast on his PC...i hope that's a good one because he really doesn't know what he's doing on the computer, half the time haha

  13. PHP will probably be around for the next 30 years along with the other language. Look at Perl, its been around for what 20 years already? People still make websites with that. ALthough its not as popular.  I see ASP though taking the spotlight now, but I have no idea why, I dont think any developer worth their spit would actually WANT to use Windows for a server. Why lock yourself into propriety software?

    The next break threw I would see is language that takes advantage of multi-core CPU's natively, without much effort on the developer's end.

     

     

     

     

    compared to PHP, Perl is a MUCH better designed language overall.

    PHP evolved from a bunch of scripts to the language it is. it was never originally designed to do what it does today. that's why the OOP support was so poor prior to version 5.x and it's still not fully OOP although most people will argue that this is not necessary in a web scripting language.

     

    Perl was designed for what it does right now, from the start. it's extremely flexible. especially for Linux/UNIX admin work.

     

    regarding threads...i doubt any scripting language itself would let the coder manipulate threads themselves...most web scripting languages are loosely typed and garbage collection is handled internally...i can't imagine someone going through the trouble of making a web scripting language that lets us explicitly manage all this...that will be interesting to see though :)

     

     

     

     

    2. A lot of companies feel more at ease with having another company they can turn to if things go wrong.  Open source is scary to a lot of people, even today.  A common thing I hear from people on the business side of things is that going open source means working without a net.  There's no ultimate authority to contact when things go wrong.  Keep in mind that developers often don't have the final say on what platform a company will use.  It's often the clients that have decided, for whatever reason, to go Microsoft or not.

     

    i totally agree with this. at the end of the day, your boss is going to want to have one single entity that he can hold responsible if things go wrong.

  14. I believe PHP will be around and be strong for a while...AT LEAST 5 years, minimum.

    but i hope the PHP team doesn't take that for granted.

     

    there were some features that were requested a while ago but were never implemented until very recently only after ROR (Ruby On Rails) started making a name for itself.

     

    it's interesting that they added those features NOW because you can now create a clone of Ruby On Rails in PHP. CakePHP comes close by PHP 5.3 makes it possible to almost make an identical clone of ROR.

     

    to tell you the truth, i prefer Ruby to PHP. it's a much nicer language IMO with a full OOP implementation.

     

    one thing that really really really ticks me off about PHP is how inconsistent it is in terms of function arguments.

    for example, array functions generally accept arguments in the needle/haystack order while string functions accept arguments in the haystack/order

    and then there's the implode() function which is ambiguous in the way it accepts arguments.

     

    i know those are tiny things but it really affects me because i don't like having to stop to double check the order of arguments when i'm deeply immersed in scripting.

     

    hopefully, PHP will either fix all these things in the near future or another more consistent and equally flexible language will emerge soon.

    </rant>

  15. the files in /etc/logrotate.d are just the configuration files.

    these config files tell logrotate where the actual logs exist and how often you want them rotated and other things.

     

    by default, most linux's would store your logs in /var/logs

     

    i don't recommend you actually disabling your logs unless you're absolutely sure you'd need them.

    what you can do, however, is to remove the files in /etc/logrotate.d

    the files that you remove will not go through logrotate.

     

    also, post your crontab listings.

    this should post the crontab of the user you log in as:

    crontab -l
    

     

    in case you don't log in as root, this should display the root users crontab:

    sudo crontab -u root -l
    

  16. compression in git is pretty awesome. it uses its own compression algorithm. therefore, it's very fast.

     

    commits are local. so, if you're not connected to the net (maybe you're flying), you can commit locally and once you're connected to the net, you can push your changes to the main repo.

     

    when you clone a repo, you're cloning the entire project so every repo is a copy of the entire project which means, you have multiple backups.

     

    suppose you worked on some code for the last 6 months and i join your team today and i make a clone of the git repo on server X. i now have a record of all the commits you made from 6 months ago and so  don't have to be connected to the net if i need to revert to a commit made 5 months ago, for example.

     

    merging branches are so much more easier compared to svn. svn used to drive me crazy when it came to merging but git is a lot easier.

     

    also, starting a git repository is done like this:

    git init
    

     

    and then you just add in all your files with:

    git add .
    

     

    and you make a commit:

    git commit -m "my first commit"
    

     

    that's it. i don't remember how i used to initialize an svn commit but it wasn't so simple and so i happily forgot :)

     

    Linus Torvalds (author of the Linux kernel) is the creator of git and he created it to manage Kernel development. apparently he was using tar balls to manage version control before using git as he wasn't too fond of SVN. although he did admit that Mercurial was pretty good.

     

    just google around and you might see if git is actually the right fit for you. it usually is.

     

    this is what i found: http://whygitisbetterthanx.com/

  17. how did you come to the conclusion that it was logrotate that was causing the problem? if it was via `top`, then paste the entire line with the parameters of the logrotate command.

     

    also, i think it's much safer to spend a few minutes figuring out what log is being rotated before you decide to do away with it.

    tell me what distribution you're running.

     

     

    if you really want to disable logrotate, you can prepend all the lines of /etc/cron.daily/logrotate with a '#' in order to comment it out.

     

     

    however, i still think you should figure out which log is being rotated and then come to a decision.

    the way to do that is, as i said, show me the output of `top` that shows logrotate running. if you figured out logrotate was the culprit some other way, then let me know how.

     

    OR

     

    post the contents of /etc/logrotate.conf

  18. It is better practice to use a switch.  A lot of problems with this type of system.

    [/quote

    just curious :) but what are the problems with what Trizen posted originally? apart from the fact that a switch is faster than an if condition by a few microseconds?

×
×
  • Create New...

Important Information

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.