Join the forums now, and start posting to receive access to our Scripts Vault!
if(constant==variable){ //do magic code}
The main thing one had to do is try and make the application as fast and solid as possible.That generally means using methods like mem-caching to store data for faster usage. Others are only reading chunks of data to make a script faster. There are many, depends on the application you are building I'd say.
I like how you failed to format your code insert as per the coding style you supposedly follow
if($variable===1){ //do some magic code}
if(1===$variable){ //do some magic}
#!/bin/bashvariable=$(date -u);project_location="/home/username/project_name";cd $project_location;git commit . -m "Bidaily commit on $variable";
Strongly disagree with this. Make your code solid, sure (the exact definition of what qualifies as "solid" is debated, but I think having a good automated test suite is pretty critical). But making your code faster is premature optimisation, commonly referred to as the root of all evil. Your code should only be as fast as is necessary. Unless you're serving upwards of a few hundred requests a second, this is probably nothing too sophisticated. You might need to optimise the odd query here, add an index there, but besides that you don't need anything fancy. And the decision to optimise should be based on where you actually *need* it, not on where you think "hmm, this could be faster if I just add these funky hacks..." The reason for this is the fancy stuff starts to make your code difficult to work with. It's unnecessary complexity.
@133794m3r: ah, okey, that's provided you don't use IDE and are prone to this error, usually it's easy to spot the difference between = and ===besides it relies on using not-assible expression - thus usually a magic value - in the condition which is highly discouraged and also error-prone (unless they are constants, not literals; still, constants are difficult to test with, replace etc.)Periodic commiting of a random bulk of files is a very bad git practice imho... how you're gonna do reverting? branching? and readability is nonetake a look at this https://github.com/nette/nette/commits/master?page=3 the commits are just clear, easy to undo whatever change...I use IDE and can do 40-80 commits a day and don't feel it hampers my speed anyhow, it's just a few seconds each time
You just commit bits and pieces of your code? I always commit all of my changes when I do a commit. If I have worked with 20 files, I commit the changes in all 20 files.
I made some really stupid mistake on my code, and wanted to go back to the last known working state. Well according to git, I hadn't remembered to commit in five days. So instead of attempting to work my way out of the mess. I threw away five days of work. Now I'll lose at most 12hrs, if I do something stupid again.
I commit all the changes made in a certain logical section. The phrase meant I don't see as a good to send changes in combat, tweaking config values, playing with CSS, changing logger, adding new code for areas - all that bulked in a one big commit with either some generic vague messages or a very long one.--- what if you want to roll back only all the combat changes? you'd have to do it manually file-by-file...If it's not possible maybe the code is too coupled or repeated...With the new GIT integration into Netbeans you don't go outside IDE, you just click and it's done... don't you want to give your brain a few moments to rest? Perhaps the coding would go better if done in a more relax way ... when dived in, you perhaps type more lines but when thinking about it more, perhaps you could have it written in a different way and do the same with less typing and re-usable in futureTake a look at github into their repos, you'll see they do it similarly as I discribed ... trying one more time: https://github.com/doctrine/doctrine2/commits/masterBut the process you describe at the end is interesting, I like that ('m using this one http://nvie.com/posts/a-successful-git-branching-model/ ... and plan to check the stability per entity, not in bulk...haven't been writing tests but 'm gonna do that now and then continue by using TDD)You can do infinite loop with for too
If you're going to auto-commit every x hours, you might as well use a backup tool and not git, since you are not using git the way it should be used. You're just creating copies of your working code.QuoteYou just commit bits and pieces of your code? I always commit all of my changes when I do a commit. If I have worked with 20 files, I commit the changes in all 20 files.Yes, you separate your commits into distinct bits of which files you've changed for a particular feature. That's what the staging area is for. Otherwise you might as well use svn.QuoteI made some really stupid mistake on my code, and wanted to go back to the last known working state. Well according to git, I hadn't remembered to commit in five days. So instead of attempting to work my way out of the mess. I threw away five days of work. Now I'll lose at most 12hrs, if I do something stupid again.You should be making commits all the time. Forgetting to commit in 5 days is bad practice, version control should be well integrated into your coding process. You don't always need to commit only after a big feature is done. Make commits all the time, even for small stuff.
The quote about optimization is used out of context and quite overused, see http://programmers.stackexchange.com/search?q=premature+optimizationAs long as you use some framework (which imho you should), caching becomes quite easy so there's not really an argument against usage in performance critical areas, which you can profile, but in practice you often know what it is...it's no use optimizing script sending forgotten password but optimizing combat calculations or something that runs on every request surely pays off.And lazy loading brings close to none additional complexity and decreased readability, yet it's a very good tool.
The main thing one had to do is try and make the application as fast and solid as possible.
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.