Busy days, few posts
As you have probably noticed, the frequency of posting on this blog decreased drastically in the past few weeks. That’s because of several reasons:
- I have a very important exam at the end of this year (Baccalaureate, for those who know what it is - I don’t exactly know the USA/UK/etc equivalent, but it is the exam at the end of high school). Therefore, I have to learn something, here and there, especially for Romanian Literature, which 101% sucks big time.
- I had some small, but time consuming projects on ScriptLance these days, “topped” by a mentally-retarded client with whom I’m not yet finished dealing with…
- I’m trying to write bits of code for one of the many personal projects. I started working on this one a long time ago, rewrote it from scratch 2 or 3 times, and now I woke up in the middle of this busy year with it still unfinished. But, I WILL complete it - even if this will happen after the exam, it will certainly happen
- Obviously, personal life (as in, but not limited to: personal entertaining) has to take it’s share of my free-time “cake”
As you can see, my day is pretty (over)loaded, with a small amount of time left to take care of this blog. I try to stay up a bit later, but I am very tired in the morning and during the day, so I have to give up this nasty habit…
Sorry for this, but it is a though year for me, especially because I feel that all this s*#tty school / exam stuff is useless for me - yeah, you heard me: useless… but about this rant, in another post.
I’ll try to write here and there, stay tuned :) !
Great Thoughts #4
Money without brains is always dangerous.
Napoleon Hill
Hint: see USA :)
Great Thoughts #3
Whenever you find yourself on the side of the majority, it’s time to pause and reflect.
Mark Twain
Unset variables after you finished using them [TotD]
As I’ve said before, it is good practice to close mysql connections after you have finished working with them.
The same idea applies to variables, especially large arrays holding user data for example. After you used a certain variable and you are sure you don’t need it anymore in your script, simply destroy it to free the memory it used.
The code is dumb-simple:
<?php
$foo="string";
$file="test.php";
//deletes the value of the variable
unset($foo);
//deletes the file
unset($file);
//etc
?>
Note that unset() destroys the value held by a variable (string, array, file etc.), not the variable itself. For example, if you use isset() after unset(), it would still return true, since the variable exists (is set :) ). Take note of this when writing your scripts, since it can be more of a issue than you would see at a first glance.
Categories STILL not fixed
I haven’t managed to sort the mess with my categories - I had a full day, and will be the next one. Stay tuned, though, I’ll do it soon enough - I have to :)
Great Thoughts #2
If you cannot do great things, do small things in a great way.
Napoleon Hill
Do Not Overuse OOP [TotD]
In an attempt to make every piece of code reusable and nicely encapsulated in a function / class, you might in fact slow down the execution of a script. Each method and object call consumes memory - a lot. Basically think of what code you will actually reuse later in your application / in other application, and which not.
Also, do not implement every data structure as a class. Arrays are useful, too, for this job.
The idea to remember is that, strictly speaking, the execution of OOP code is slower than procedural code, so you’d better be careful when implementing everything as OOP. What has to be OOP, let it be OOP - the rest, make it the easy way :)
Categories kinda messed up
I’m currently trying to tidy up the categories on my blog and reduce the number, in an attempt to have an organised, easy to browse taxonomy.
However, I suddenly realized that I had no plan in mind, before starting this, on how the category tree should look like. Therefore, I decided to abandon this job mid-way to completion and postpone it for tomorrow, since it is past 1 AM and I am really tired.
So, if you see some strange things with the categories on this blog, any post that belongs to a category it shouldn’t, or any kind of wrong stuff related to categories, don’t worry, it will be fixed tomorrow, first thing in the morning.
PS: as a quick advice to be learned from this “experience” - always have a plan, a sketch of the “big” thing, whenever you start doing something - not only on the internet, but in real life, too.
PS2: after I’ll be done cleaning the categories, I’ll post a recap to explain what each category contains, so that you, my dear reader, will easily find what you are looking for. Also, I’ll write a blogging schedule, so that you know what content to expect, and when to expect it.
Use PHP built-in functions for strings instead of regex [TotD]
PHP has quite a lot of build-in, bundled functions that make your life easier - if used, of course :)
Anyway, since regex is quite a pain in the back for lots of programmers, here’s a good advice: use string-related functions to achieve what you need.
Here are some useful ones:
strncasecmp: Binary safe case-insensitive string comparison of the first n characters
strpbrk: Search a string for any of a set of characters
stripos: Find position of first occurrence of a case-insensitive string
These 3 are only few of what PHP can “do” to your string :). Read the full list here: PHP string functions
Happy coding!
Great Thoughts #1
Humanity finds, as history has proven, a great pleasure in engaging in activities such as philosophy, thinking of the universe and it’s mysteries, the greater good and so on and so forth - you get the idea.
The results of such activities are statements, sentences, group of words which I like to call them “Great Thoughts”.
Since every day I come across such great thoughts on the web, I decided to create a new category on my blog: “Great Thoughts” (doh).
Every day, I’ll post a “Great Thought” I find on the internet to share it with you. Some of them really put you into a state of deep thinking, meditation, engages you in a discussion with yourself - you’ll see what I’m talking about.
We will either find a way, or make one.
Hannibal


Recent Comments