Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. This will work if you only have one DB connection. If you work with more than one DB server you should use something like: $userData = array_map(function($value) use (&$db2) { return mysql_real_escape_string($value, $db2); }, $_POST); $db2 being the database connection you want to use.
  2. http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn http://code.google.com/p/zen-coding/wiki/ZenHTMLElementsEn Complete explanation of what you want to achieve. Going wild: html[lang="nl" class="foo"]:5>body>div[id="wrapper"]>(div[class="left"]>div*3)+(div[class="middle"]>div*3)+(div[class="right"]>div*3)
  3. I wrote this. Assuming both times are on the same day. try { $t1 = new Time($argv[1]); $t2 = new Time($argv[2]); echo $t1->diff($t2); } catch (Exception $e) { echo $e->getMessage(); } class Time { private $seconds; public function __construct($time) { if (!self::valid($time)) throw new InvalidArgumentException('Invalid time. Type: ' . gettype($time)); $this->seconds = $this->_toSeconds($time); } public static function valid($time) { if (!is_string($time)) return false; return preg_match('~^(\d|0\d|1\d|2[0-3])\d|[0-5]\d)$~', $time); } public function diff(Time $t) { $t1 = $this->toSeconds(); $t2 = $t->toSeconds(); $diff = ($t1 - $t2); if ($diff === 0) return '00:00'; return $diff < 0 ? $this->_toString($t2 - $t1) : $this->_toString($diff); } private function _toSeconds($time) { if (!self::valid($time)) throw new InvalidArgumentException('Invalid time. Type: ' . gettype($time)); sscanf($time, '%d:%d', $h1, $m1); return ($h1 * 3600) + ($m1 * 60); } public function toSeconds() { return $this->seconds; } private function _toString($seconds) { if (!is_int($seconds)) return false; return floor($seconds / 3600) . ':' . floor(($seconds % 3600) / 60); } } >php time.php 13:35 17:35 4:00 >php time.php 21:35 05:35 16:00 # reverses the arguments
  4. ignace

    CSV

    See: Replication
  5. Go for 18k. If it's true that you are hard-working, and committed, plus you work in your spare time your even worth more than that.
  6. Well you never gonna get a raise from 14 to 25k unless you are a business critical asset. Try 16k or if you are bold enough, try 18
  7. Yes. If that domain/URL publishes that information.
  8. <sarcasm>You forgot to mention that he also should have graduated from MIT with honors, and solved at least one mathematical mystery.</sarcasm> An entry level job is: -- What the employer expects: Knows HTML, CSS, JS, and PHP, and able to understand what the f*ck he wrote and able to debug it when it fails. What the employer gets: Has seen HTML, CSS, JS, and PHP somewhere in his career as a student. With some luck he can actually write a script without syntax errors. -- GoF, OOP, scalability, availability, .. is medior-ish. It's the medior's/senior's who teach all junior developers. We are the exceptions, gentlemen. We could write and debug as a junior developer, there are not many like us!
  9. Junior Webdeveloper or Senior Webdeveloper has nothing to do with "I know shit" but instead is an inidication to a possible future employer how cheap or how expensive one is. For example some companies say that you are a Junior Webdeveloper when you have less than 5 years of professional experience, Medior from 5+ years and Senior from 10 to 15+ years of experience. It makes it all nice and easy for a company who want to hire someone but don't have the money to pay a senior. So some companies only consist of Junior Webdevelopers... Someone once told me his official title at the company he then worked was Junior Webdeveloper while he had 7+ years of experience.. Or how do you slave labour in the modern era.. Titles mean jack-shit, if you think you are a valuable asset, play your odds and go to your boss and tell him you want a raise... And 9 out of 10 you'll get it! Asking for a raise is also an indication that you have thought hard and long wether you deserve it, and since you had the balls to get in there and ask for it, your worth it!
  10. The correct implementation would be below. Do you understand why? And why yours couldn't work? $path_to_image_dir = "./uploaded/images"; // path to your image directory $xml_string = <<<XML <?xml version="1.0" encoding="UTF-8"?> <gallery> </gallery> XML; $xml_generator = new SimpleXMLElement($xml_string); $photos = $xml_generator->addChild('photos'); if ( $handle = opendir( $path_to_image_dir ) ) { while (false !== ($file = readdir($handle))) { if ( is_file($path_to_image_dir.'/'.$file) ) { $photo = $photos->addChild('photo'); $image = $photo->addChild('content'); $image->addattribute('src', $path_to_image_dir.'/'.$file); } } closedir($handle); } header("Content-Type: text/xml"); echo $xml_generator->asXML();
  11. Whenever you press a color they query their server and return 8 images (one image for every angle). IMO all shoes have been modelled in Illustrator or the like with editable layers (every part of the shoe), through some mechanism/server they tell which color each layer should have. Since it's due in February and you don't know how to do this. I suggest you start looking local/internet for someone who can, and sub-contract them.
  12. What have you tried so far? Because since you can't answer your own question I assume you just copied the above code from somewhere.
  13. Wut? What are you talking about?
  14. LOL I think the entire mod/admin team has quite some stories to tell you They hanged the pictures of the SMF dev team on their wall for a regular darts game!
  15. Get a lawyer, this is going to get messy! If he bought the domain and you only rented it with him, and payed him monthly, that still makes him the owner!
  16. Here's an example: interface DB { public function __construct(array $config); public function query($sql); } interface DB_Result { public function fetchAll(); } class DB_MySQLFunctions implements DB { private $conn; public function __construct(array $config) { $this->conn = mysql_connect($config['host'], $confg['user'], ..); } public function query($sql) { return new DB_MySQLFunctions_Result(mysql_query($sql, $this->conn)); } } class DB_PDO implements DB { private $pdo; public function __construct(array $config) { $this->pdo = new PDO($this->_PDODSN($config)); } public function query($sql) { $result = $this->pdo->query($sql); return new DB_PDO_Result($result); } private function _PDODSN($config) { /*..*/ } } class DB_PDO_Result implements DB_Result { private $result; public function __construct($result) { $this->result = $result; } public function fetchAll() { return $this->result->fetchAll(); } } And in your application you could have code like: /** * @param DB $db * @return DB_Result */ public function queryForAllUsers(DB $db) { return $db->query('SELECT * FROM users')->fetchAll(); } This code now works for all implementations of DB. So: $this->queryForAllUsers(new DB_MySQLFunctions); // using mysql_* $this->queryForAllUsers(new DB_PDO); // using PDO
  17. re-usable as in php code? or as in the entire thing (images, css, js, ..)? The first scenario means a strong abstraction. The second implies the use of modules (or mini-app): module1 - css - js - img - something.php - manifest.xml module2 - css - js - img - something.php - manifest.xml
  18. scootstah's way in OOP would be something like: class Template { private $engine; // Smarty, Twig, PHPTAL, .. private $title; private $stylesheets; private $scripts; private $headers; private $variables; public function render($script, $variables = array()) { print $this->engine->render($script, $this->_mergeAndReturnVariables($variables)); } } In the $script you would like to render you write: <?php $this->render('header'); ?> Content goes here. We can use variables that we passed in earlier. <?php echo $foo; ?> <?php $this->render('footer'); ?> Take this a step further and implement a Two-Step View. The idea is that you have one file that defines your header and footer and puts a placeholder for the content ("Content goes here. We can use variables that we passed in earlier. <?php echo $foo; ?>") The view is rendered in two-step view: 1) the content 2) the template (header + footer). Basically the inverse of the above.
  19. You could of course be the next Mark Zuckerberg. When he started Facebook with friends there were already quite a few social networks available. The reason Facebook became attractive was because it was exclusive. Same goes for Apple, everyone loves their products because they are "exclusive". Facebook first became a leader in a niche before they expanded and made the big step of becoming a player in a market that was saturated. It could of have gone either way. Pick a market, find out who your foes are and use their apps if possible. Socialize with their user-base (if possible, do a market research otherwise, be creative) and find out what your competitor sucks at and how you can be better. This is not a magic bullet of course, just look at Google+, they listened to their audience and created a product that respects your privacy and allows you to selectively talk to groups of people. However: "but all my friends are already on Facebook!" and "do I have to register again? Can't I log in with my Facebook account?" When you have an idea, create a SWOT (Strength-Weakness-Opportunity-Threath) analysis. When your competitors are too strong, specialize your idea and start a niche, and become a leader in this new niche. For example you can't beat Facebook, but you may thrive well when you create a niche for example: social network for children < 13 or a social network for people on retirement. EDIT: Look around I'm sure there are books that explain this better than I did.
  20. Create a model for each table. This makes sure that you can benefit of all what the framework has to offer (Like the Associations in CakePHP). Create a new model that will sit on top of these table models. class FridgeController extends AppController { public function analyseMyFridgeAndReturnPossibleRecipes() { $recipes = $this->FridgeRepository->findPossibleRecipesByFridgeContents(); return $recipes; } }
  21. Just put the joke on him, next time you find a bug in a file. Throw all code through a php obfuscator and paste it in (but keep a backup). Tell him there is a bug and that you want him to fix it. Add a PS rule saying that for his convenience you have adjusted it to his coding style!! Or take one of his scripts, use NetBeans or something to properly format the code and save it as a version 2. Run both in a benchmark (say 100.000 requests), that should convince either you or him.
  22. LET'S PARTY AS IF IT'S THE END OF THE WORLD !!! 12/21/2012 HERE WE COME !!!
  23. Anecdote: We had a candidate for a job interview and as part of the reviewing process we had him write some PHP code. This guy had 10+ years of prof. experience with PHP but always started his code with <?. As he tried to run his code he noticed nothing appeared... Compelely baffled, he calls the interviewer and tells him the server is broken since he can see his PHP code when he opens the browser's view source window... We didn't hire him but I'm pretty sure that guy will start all his files now with <?php
×
×
  • 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.