Archive for the 'Programmation' Category

Page 2 of 4

For your caching needs

Your website is attracting a lot of visitor and taking much of your bandwidth? You are the kind of person who submit a lot of content to social bookmarks and get hit by the traffic? Well, you should consider using the cache function provided by PHP. It will save you many downtime and bandwidth by creating a page which will act like an html in content but will still provide the php functions (posting). The first option is http://www.ilovejackdaniels.com/php/caching-output-in-php/ The first one is a really nice script by Daniel. I loved it. The only problem I had was with
php_value auto_prepend_file /begin_caching.php php_value auto_append_file /end_caching.php
due to the fact we can’t use these in the .htaccess on the server. But I figured a way you could make it still be working. Here is how. The user make a page and call it loader.php (for example). In the .htaccess, you use the following:
RewriteRule ^([a-z]+)$ loader.php?p=$1
This will tranfert to the loader a variable which is the page name. In the loader.php, you use the following:
This way, each time people get on ANY page, they get the loader to add the begin and end cache and loads the page between, without using the use php_value, hope I helped some of you guys 🙂 Second option is http://www.devshed.com/c/a/PHP/Output-Caching-with-PHP/ This one is for more advanced programmers because it requires some understanding of the process going on. I’d rather stick to the first option if you’re looking for a good caching without getting too much involvement in the script.

eMule Plus programmers’ requirements

1. Reverse a string (e.g. array of chars) in place. 2. Reverse a linked list. 3. Count all the bits that are on in a byte. 4. Let’s say we have (fixed size) array of bool, which is filled by false, except one element, which is true. You don’t have direct access to elements of that array, but have function, IsTrueElementInRange that accepts range of elements (e.g. from n to m) and returns true or false. What’s the best algorithm for finding true element using that function, and what’s its name? 5. Let’s say we have (fixed size) array of int, which is filled by numbers from 1 to 5. Calculate counts of each number in the array (e.g. how many 1’s there are in array, how many 2’s and so on). Calculation should be made in single array walk. 6. What’s the purpose of virtual destructor in C++? 7. What class is the base of all window classes in MFC? 8. What class is the base of most of other classes in MFC and what are the services it provides? 9. How do you walk through vector’s elements in STL? 10. Let’s say you created dialog in MFC, put RichEdit control on it, and dialog failed on create. What did you forget to do? 11. What happens if you call new operator to create some object and it fails because out of memory? 12. How do you synchronize two or more threads? 13. Implement simple read-write lock mechanizm, which allows multiple readers simultaneously, but only one writer (of course, while we write, noone can read until we finish). 14. What is the function you call to get new interface in COM? 15. What interface should COM object provide in order to be used in script languages, like VBScript, Javascript? 16. What does a sequence diagram represent? 17. What is the difference between a class and an object? 18. What are the following examples of: Factory, Prototype, Adapter, Bridge, Composite and Iterator? 19. What is a class factory and why would you want to use one? 20. How would you create a singleton in C++? (Show what should be in the .cpp and .h files.) Answer only those questions that you know

My c++ challenge (part 2)

So far, I’ve written about 174 lines with the AI, though it’s not completed yet. I only need to program what the AI moves will be and it’s done. Should be done within 26 lines 🙂

I should be positing the source code when I’m done, that should be done in the next few day.

eMule programmers’ wiki

Since I’ve got a lot of free time during my vacation, I started learning C++ (which I had previously learned), but this time, with in depth understanding. I don’t have much knowledge about the language yet though but I can understand pretty well what’s going on if you give me a bit of code. I’ve setup a temporary wiki at http://djzarek.com.ru/wiki/ in order to get more info about each specific file and with a hope that some emule modders, programmers will come and help out filling this wiki that might be useful for their community later on.

My c++ challenge (part 1)

Done, with 124 lines. 🙂 Look at the file for yourself