Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. No idea. You could contact him through his website: http://fagsoft.no
  2. If you use it for nothing else but to promote your work to a potential client they won't pursue a lawsuit.
  3. I already ran an anti-virus which turned up one virus which it removed but it still goes to 100% hdd. Will try the process explorer.
  4. Hi, My mother-in-law asked me to check on her laptop (win8) and I tried but was unable to find a solution. The problem is that the hard-drive is at a constant 100% which makes the laptop really slow except in safe mode. Process list shows no process using 100% of the hdd, I already did a chkdsk and it returned no errors. I suspect it's due to the task scheduler and stopping the active tasks indeed lowers the hdd usage to 6-11% but it does not remain there probably because new tasks are started. I also removed several software which I suspected were the ones creating the tasks to no avail. It appears as if Windows itself is running tasks that slow down the laptop to a crawl, but disabling task scheduler does not seem a good idea. Any ideas?
  5. Create another .png where your character looks like he is slashing something. Then when a user clicks, replace the image with the slashing image and back. Pre-load the image to make it fluent or use a sprite .png where it has all your characters movement and simply change the offset for each individual movement.
  6. I guess it's possible though it's really complex both technically and mathematically. JavaScript already has a 3D library that you can use: http://threejs.org/ Now you just need to figure out how to turn a bunch of images into a 3D model.
  7. Something along the lines of: foreach ($_SESSION['cart'] as $line) { $sql = 'INSERT INTO table (column, ..) VALUES (?, ..)'; $stmt = mysqli_prepare($db, $sql); $stmt->bind_param('s..', $var1, $var2); $stmt->execute(); }
  8. INSERT INTO table (columns, ..) VALUES (values, ..);
  9. Consider the following code: function foo() { $foo = Configuration::get('foo'); // .. }In this example you can't change the class that is being used to read the configuration data unless you manually edit the code that uses it. The bigger your application gets, the more it takes to change it everywhere. function foo(Configuration $bar) { $foo = $bar->get('foo'); // .. }In this example it is easy to simply provide a different implementation and pass it as an argument. All it takes is changing the calling code. Because all your code expects it as an argument you can probably set the class at one point (for example index.php) which is then used throughout your entire application thus changing the implementation means changing it at that one point to make your entire application use the new Configuration instance.
  10. /contracts -- View all contract templates /contracts/new -- Create new contract template /contracts/{contractId} -- View contract template /contracts/{contractId}/edit -- Edit contract template /contracts/{contractId}/delete -- Delete contract template /people -- List of people in the organization /people/add -- Add existing person to the organization (not new since the person already "exists") /people/{personId} -- View specific person /profile for logged in user /people/{personId}/edit -- Edit person /people/{personId}/delete -- Delete person /profile -- Person's profile /my/contracts -- Contracts signed by the user /people/{personId}/contracts -- View contracts signed by person (/portfolio may also be a good candidate) /people/{personId}/contracts/{contractId}/renew/{renewToken} -- Renew contract for person /people/{personId}/contracts/{contractId}/sign -- Sign a new contractPlanning an application does not start by defining the URL structure but by writing down a list of the things the application needs to do in as much detail as is required to start work on the item. When you have written down the requirements list then you move on to creating a wireframe giving you an idea how the application will look and work and what content you will need. If your application involves roles, you will also need to write down which role can access which parts of your application. At this point you have a good view of how your application will look and work and the content needed so you can move on to creating your entities and their behaviors for example: class Employee { private $portfolio; // .. public function sign(Contract $contract) { $contract->signedBy($this); // other necessary code to sign a contract and what not. $this->portfolio[] = $contract; } }
  11. We already explained this to you at: http://forums.phpfreaks.com/topic/293408-how-to-make-configuration-settings-available-to-all-scripts/ Using a static class couples your code to a specific implementation and makes it harder to change later on. Also if you ever become a professional programmer your colleagues will frown upon your use of static anything. Both me and Jacques gave you good examples of the best practice.
  12. Hello and welcome! Please do not hesitate to post any questions you may have in the forum.
  13. Ok yeah sure I hammer everything with OOP but that does not mean you have to ridicul it to such extremes because my solutions are spot-on. And sure I never keep it to simply the solution and extend further upon it to show the OP what other options it extends him with. Because it might just be that at some point he considers to cache his configuration with APC which is far better then loading it from INI files on each request. And I am not showing off there are people here that are far better at it then I am. And at the very least I try to learn the OP some new things not bitch about other people's posts, how contributing of you. And I DO solve real problems. 70,000 requests per second problems I solve every day, keeping the number of servers to an absolute minimum for which many even applaud my solutions. So I may be in an ivory, but so are you thinking your solutions and intellect solve world-hunger.
  14. A class per table would be much better then having a class per query. This however means you will need to map the fields to the appropriate classes when doing joins. Doctrine has a class that can do this for you. http://doctrine-orm.readthedocs.org/en/latest/reference/native-sql.html#resultsetmappingbuilder This means that you will map the fields from the result to their appropriate objects incl. hierarchy.
  15. It's not over-engineered instead it's practical. I believe having at least one interface for a class that might change in the future is a good thing and many will agree with me as is making the OP aware of this. Always keep an open-mind that the OP could be writing a program that at some point could get lots of load. Teach a man to fish etc.. If you have a legitimate reason why my code is bad practice then please do note them, if not keep your childish comments for yourself. Also I insist you refrain from hijacking the OP's topic further.
  16. Currently your Configuration object doesn't allow many different uses. Using the full extend of OOP, you get something like this: interface Configuration { function get($key, $default = null); function set($key, $value); } class ArrayConfiguration implements Configuration { private $data; public function __construct(array $data) { $this->data = $data; } // implement methods } class IniConfiguration extends ArrayConfiguration { function __construct(SplFileInfo $filepath, $processSections = false, $scannerMode = INI_SCANNER_NORMAL) { parent::__construct(parse_ini_file($filepath, $processSections, $scannerMode)); } }Now you can create Configuration from an array or from INI files. This logic can also be put into an object: class ConfigurationFactory { public function createFromSource($source) { if (is_array($source)) { return new ArrayConfiguration($source); } elseif (is_file($source) && '.ini' === substr($source, -4)) { return new IniConfiguration($source); } else { throw new RuntimeException('Type of source is not supported, expected array or filepath got ' . gettype($source)); } } } $factory = new ConfigurationFactory(); $factory->createFromSource(array('hello' => 'world')); // returns ArrayConfiguration $factory->createFromSource('/path/to/file.ini'); // returns IniConfiguration function doSomethingBasedOnConfigValue(Configuration $cfg) { if ($cfg->get('foo') == 'bar') { // do bar } }The above code is unaware if this value came from a simple array (during testing) or from a ini source file (in production). Even better now you can extend your code without altering your existing code. class ApcConfiguration extends ArrayConfiguration { function __construct($cacheKey) { parent::__construct(apc_fetch($cacheKey)); } }APC stores data in memory and is persisted (shared) between requests avoiding to load from the hard drive (which is way slower then simply loading from memory). doSomethingBasedOnConfigValue(new ApcConfiguration('my_cache_key'));As you see the above code does not have to change although your configuration is now loaded from a shared source.
  17. MySQL has FULLTEXT indexing on InnoDB starting from 5.6. However I've always used ElasticSearch instead of fulltext indexing.
  18. Yet why is it then that nobody does this, since this is so performant?
  19. Uhu, if there was a point in there that proved creating databases and tables on-the-fly is more performant I missed it.
  20. It's better to keep it all in one database. If you are unsure of the performance impact then simply set up a test database, fill it with data (try to keep it close to reality using current growth data), add proper indexing, then test your application performance. You can still add caching front-ends if needed. Of course this means that during development you will have to centralise your queries so that in case you need to add a caching front-end it is easy to add in. This is the idea: interface ProductQuery { // relevant query methods } class DbProductQuery implements ProductQuery { // methods } class CacheProductQuery implements ProductQuery { private $productQuery; public function __construct(ProductQuery $fallbackProductQuery) { $this->productQuery = $fallbackProductQuery; } }Replace ProductQuery with your own version, perhaps CustomerQuery and ElectricalBillQuery interface CustomerQuery { public function findCustomerById($id); // more methods.. } interface ElectricalBillQuery { public function findElectricalBillById($id); // more methods.. } class DbEntityQuery implements CustomerQuery, ElectricalBillQuery { // implement all methods } // or separate class DbCustomerQuery extends DbQuery implements CustomerQuery { // }And this is just one way for you to go. You can still add scaling, sharding, and other stuff to improve your performance. So get rid of the idea of creating tables or databases on-the-fly because it will only hurt performance.
  21. Here are several https://packagist.org/search/?q=socket
  22. It's a game played in a browser online. It is possible for 2 people to be at the same place at the same time thus they both could attack the same monster thus the loot dropped should not be awarded 2 times. It's a multiplayer PvE, adding PvP is merely allowing one to also attack other players.
  23. Yes, it is better to store it in a database then simply relying on the fact whether or not the session ID still exists. Which you will have to store in the database anyhow, if you would want to re-use it on re-authentication. Also storing it into a database allows for multiplayer shared loot and making sure the same drop item is not taken more then once.
  24. This is a problem most employed developers experience. Clean code, refactoring, testing, .., all those good bits do not convert in more ROI. "It works!" is the one and only measure in our industry. I have worked with cowboy programmers, and even with people who write stuff like: function a($b, $c) { // do stuff with $b and $c, and create variables like $d, $e, $f, .. }Not example function names, literally named like that. When I complained about it they replied it works and it goes faster then what I wrote. A part of me simply wanted to do the very same thing, write code just the same way until it was such a ball-of-mud that I could go to them and say: NO I CANT FIX IT, NO ONE CAN! BUT HEY YOU KNOW WHAT IT IS FAST
  25. Sessions are coupled to cookies. Cookies are coupled to browsers. Browsers do not share cookies, so a different browser means the user will have to authenticate again. If your concern is load on the database, this is not the solution.
×
×
  • 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.