Alecs’s blog
Fii linux! Descarca-te de problemele neimportante din memorie!

if you want to break apart the routes to the module level, you have to add into your “apps/APPNAME/config/routing.yml” solething like

<?php @include(dirname(__FILE__).'/../modules/MODNAME/config/routing.yml')?>

that will enable your
apps/APPNAME/modules/MODNAME/config/routing.yml

Pay attention not to have any spaces before

<?php


Tags: , ,

You need to a flashplayer enabled browser to view this YouTube video


1) You should choose the right development application. The one that is more fit for your application. Not the one that is in vogue. Do not put your resumee first. Allways consider the technical means that you have on your disposal.

2) Do not build skycrapers if is not necesarily. Diminish the complexity if is not needed.

3) Allways communicate with your client and your team to find the fit solution for your needs.

4) Allways try to find the right ballance between server, client, programmer needs and usability, security and so on.

5) Allways seek the value of the requested features. You might end-up with with expensive solution to a non important feature.

6) As said Skyscrappers aren’t scalable. Work modular. Make releases often. You will be able to fix more quickly the bugs that might occur. Also, you will be able to anticipate the scalability issues.

7) When you are trying to provide a detailed answer to a customer, try to be as short as possible in your answer. Do not end-up with technical explications. Your client might just get start to bore after first word. He might not be a technical person. The terms like “scalability”, “optimization” might not be in his dictionary with the meaning you want to transmit.

8) Try to get certain datas about the project. Try to put as many questions to clarify the quantity. Answers like “many”, “soon”, “more” should not be accepted as viable options.

9) If you are a software architect and  developer in one project, you should be able to see the micro and the macro. Written specifications do not worth anything. Those are there just to help you figure out how it will end up the project. The main goal is finishing the project.

10) There is no “one-size-fits-all” solution. Each project has own tricks. You only should be able to see which you need to implement, and also, to refine the technical part to be as optimal as possible.

application


Tags: , , ,

Last days I attended at eLiberatica 2nd edition. This participation has changed my way of thinking completely, and revolutionized a few things to me. Among these I mention that i have I decided to focus on project management. After I attended several conferences held by project managers with experience (Razvan Gliga - IBM, Ovidiu Negrean - http://www.lucrez.in/IT, Lucian Parvu - Luxoft Romania / former ITC Networks, Maria Diaconu and Alex Bolboaca - MosaicWorks / OpenAgile community ) also from a dutch PM named Jurgen Appelo ( ISM e-Company ) and a US Craftsman named Corey Haines, i have got the conclusion that is time to start a career into Project management and software architecture.

I think this is the time to make a stand for my career and myself. I will try to become the best in my branch. I know that my youthful thinking dictates me that i should start right away to work when i have a new task, but in the last time i have spent more time to think about another things like software architecture, database optimisation and many more.

The  erepublik way, and also Andru Beldie meant a turning point into my thinking, even if i haven’t noticed on the right moment. The problems treated into Erepublik project remained in my head as existential problems for any software application. Of course … “There is no one-size-fits-all sollution”, but the main problems could be same in the most of the projects. We speak here about Scalability of any level (database, storage, bandwidth, processor power and so on), application optimisation (database mostly), application complexity (how could we make the project with as less resources consumed, without make it more complex than it should be), what technologies to use (in order to have a viable alternative, without complicating things more than they are), and so on. I think those kind of problems should have a software architect. When i wake -up in the morning, and one of these come in my mind first, then i think i have a problem. Either I have some problems with my mind, either i have to become a project manager.

Lately, i wrote my own code being concerned about the impact that might have on the server, the load or other effects. I do thing way too much about servers and about my own code. As it said Corey Haines: “Write your code as if the one who will maintain it is a psychopath who knows where you live.”, well, i am really doing that. I am trying to improve my code as much as possible …

I have reasiled that, if i would become a good software architect or a project manager, i should start again to learn. This time much more than i have learned few years ago.

I will try to come in the future with more details about the technologies that i have learned or about which i have read about. It is really the time to GROW


Tags: , , ,

The main ideea of this script is that if it is set up in crontab, it will check if your root partition is filled up of logs… if so, then it will backup some logs into home partition, and after that will truncate all main files and will erase old logrotate logs.

for the moment the script will do these actions if your free space is lower than 1G (if [[ $var < 1.0 ]] )

After the job done, it will send you a mail and it will tell you how much free space you had before run the script, and how much do you have now.
#!/bin/bash

#
# Version 1.0
# Script done by Lupu Alexandru
#
# You may add any modifications.
# This script is meant to check if the root partition is almost filled up.
# If it is filled up, then backup the logs and clear that partition
#

# MUST NOT BE / or any filesystem type (ext2, ext3, jfs, etc.)

looking_for=”your root filesystem label or size ”
date=`date +%Y%m%d`
path=/home/logs/$date
# main script
str=`df -h | grep $looking_for | awk ‘{print $4}’ `
var=${str/G/}
SUBJECT=”Automated Mail Alert”
MESSAGE=”/tmp/message.txt”
EMAILADDR=”your address here ”
#we check if requiered directories exists
function directory {
if [[ !( -d /home/logs/) ]]; then
mkdir /home/logs
fi
if [[ !( -d $path ) ]]; then
mkdir $path
fi
}

# we clean the mess in the /var/log/lighthttpd dir
function lighthttpd {
cd /var/log/lighthttpd/
tar czf $path/lighthttpd.tar.gz /var/log/lighthttpd/
echo “” > access.log
echo “” > error.log
}

# we clear the mess with maillogs in /var/log/
function maillogs {
cd /var/log/
tar czf $path/maillog.tar.gz /var/log/maillog*
echo “” > maillog
rm -f maillog.*
}

# we also clear the mess in /var/log/httpd
function httpds {
cd /var/logs/httpd/
tar zcf $path/httpd.tzr.gz /var/log/httpd/
echo “” > access_log
echo “” > error_log
echo “” > ssl_access_log
echo “” > ssl_error_log
echo “” > ssl_request_log
rm -f *.*
}

# we notify the project manager and the developer
function mails {

echo “The hard disk it was almost full. i had to make a copy of logs in $path.” >> $MESSAGE
echo “Before my action there were $str available. ” >> $MESSAGE
echo “Now there are `df -h | grep $looking_for | awk ‘{print $4}’` available. “>> $MESSAGE
echo “Please correct this issue ASAP” >> $MESSAGE
echo “Time: `date`” >> $MESSAGE

$(type -p mail) -s “$SUBJECT” “$EMAILADDR” < $MESSAGE

rm $MESSAGE
}

if [[ $var < 1.0 ]]; then
directory
lighthttpd
maillogs
httpds
mails
fi


Tags: , ,
May
11.

I decided to write this post in english because it might be utile to more people this way.

Recent experience, tough me that a good database structure is not enough when your site increases number of visitors exponential without possibility to have any time to rewrite the code or restructure your database model.

The whole ideea is to make a decisional system (algorithm) that decides whatever you use: cache system or block system. If your system uses block system, then is mandatory to generate the cache.

In the next rows i will try to present you some cache methods that are quite useful.

1. Caching the whole page
This is not a good practice when you have an online store or you have an application that requires a lot of information from database, but it can be useful for the site applications that have a lot of pages and a big number of visitors. The whole ideea is to keep your database server as free as possible. This way you can cache any page that is not often changed. A page like that can be stored with a big time buffer (example you regenerate that page twice or once per day).

For a page that is often modified, you can set the cache buffer somewhere below, i mean you could regenerate that page 1 per hour or you can generate it 6 times per hour. If the page is very often modified or it need to take online users or a number that has a small interval of changing, this time can be reduced to any measure.

2. Caching page sections

This ideea is similar with first one, but instead caching all the page, you might simply cache just a part of your web page … that means you will be able to control your modules that are grouped in one page more easily and they could have separate cache lifetime. You might be intrested to cache 3 modules in this way. 1 module with a cache life time around 10 minutes, 2nd module with a cache lifetime of 1 day, and 3rd with a cache of 1 week.

3. Caching variables

This one might be a good option for the sites with a great number of visitors, but its content is changing often. in this case you can cache each variable as a file, or the entire set of variables into a file. Either you cache one variable or you write them all in a single file, result will be the same.

3.1. Storing all variables in a single file

If you choose this type of caching then you must be aware that is the best for you separate yor sql queries / results from the process code. This way you can have a bigger control over your cache system. Also is more easy to generate your cache. Must be aware that your php structure will create separate including files that will be generated at a specified time … or simply, to make them permanent, you set them to expire in 1.. 2 ..100 years.

<?php

$variable1 = “foo_value”;

$variable2 = “foo2_value”;

?>

3.2. Storing all variables in multiple files

This way, you will not be forced to separate your sql queries, but your code will be more complicated because you will be “forced” to write more decisional conditions in your code. This can be a mess when you try to echo more variables in a single row or something like that. A second strategy would be to make a function with some paramehers like:
function my_cache_function($path_to_file,$time,$expression){
// a decisional if
if (file_exists($path_to_file) && (filectime($path_to_file)>(date(”U”)-$time))){
$my_cached_var = file_get_contents($path_to_file);
}else{
eval(\$my_cached_var = $expession);
unlink($path_to_file);
file_put_contents($path_to_file,$my_cached_var);
}
return $my_cached_var;
}

this function will allow you to write in your code expressions like:
$messages = my_cache_function(”./cache_dir/messages.cache”,60,” mysql_result(mysql_query(\”SELECT count(*) as nr FROM my_messages_table WHERE my_field=’{$user_id}’\”),0,\”nr\”)”);

In the example below i’ve shown how can you cache a variable for a time of 60 seconds. Of course, the main ideea of a cache system is to get some variables that remain constant for a long period, or they consumes a lot of resources to be shown.

3.3 Using memcached.

By using memcached, you will be able to store the variable into ram memory for a long time period.

I haven’t checked all the versions, but, if you test my ideea/ script that is presented here, you are doing at your own risk.


Tags: , , ,
May
11.

Hi there!

Almost 2 or 3 years ago i’ve found qmail MTA and suite. The bad part is that the qmail is hard to configure if you are a newcomer in linux / qmail. All the tings you have to is to search in google for qmailrocks and you will find a cool place where to start, with a nice tutorial and a good and maintained mail list.

As ubuntu/ debian user, i am triing to make a script that will do your life easier. I am planning to make a script (started to work at it), that will provide you qmail rocks full flavour, including all packages, features and patches that you need to run to configure it.

I hope i will post it here asap, depends on my free time (if i have any… )


Tags: , , ,
Mar
08.
Category: php

Zilele trecute stateam de vorba cu alti doi colegi programatori despre OOP.

Il intrebasem pe unul cateva chestii de baza despre OOP, iar el mi-a raspuns:

ai obiectul Radu (al 3-lea coleg) si metoda “Latra” . deci o sa ai $radu->Latra(); Sau, ca sa fiu si mai explicit ai obiectul “Om” si proprietatea “nume”. deci, o sa ai:

$om->nume = “Radu”;

totusi vei avea si metoda radu si obtii ceva de genul:

$om->nume= radu;

si $om->radu->Latra();

si ii cere colegului sa “latre”. Radu, dupa cateva momente de gandire … raspunde sec: “Miau!”…

cel care explica a raspuns instant “#### are bug-uri”…

in acel moment, amandoi (atat eu, cat si Radu) am izbucnit in ras…


Tags: ,

Azi am descoperit cu adevarat ce inseamna programarea. In spatele zecilor, sutelor, miilor poate milioanelor de linii de cod ce sunt scrise pentru obtinerea produsului finit se afla alte cateva sute, mii, milioane de randuri acumulate in asa numitele specificatii tehnice.



Powered by Wordpress
Theme © 2005 - 2009 FrederikM.de
BlueMod is a modification of the blueblog_DE Theme by Oliver Wunder