Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, May 21, 2024

10 commandments of Coding

 

1. Thou shalt comment thy code: Always add comments to explain your code. Future you (or others) will thank you for the clarity.

2. Thou shalt use meaningful names: Choose descriptive names for variables, functions, and classes. Clarity is key to understanding code.

3. Thou shalt format thy code properly: Consistently indent code, use proper spacing, and follow a consistent coding style. It makes code easier to read and maintain.

4. Thou shalt test thy code: Write tests to verify that your code works as expected. Don't rely solely on hope or luck.

5. Thou shalt handle errors gracefully: Anticipate and handle errors in your code. Don't let unexpected situations crash your program.

6. Thou shalt not repeat thyself (DRY): Avoid duplicating code. Instead, use functions, classes, or libraries to reuse code and keep it maintainable.

7. Thou shalt strive for simplicity: Keep your code simple and straightforward. Complexity breeds bugs and confusion.

8. Thou shalt follow best practices: Stay updated on coding best practices and industry standards. Continuous learning is key to improvement.

9. Thou shalt respect thy fellow coders: Be considerate of others who may read or work on your code. Write code that's easy for others to understand and contribute to.

10. Thou shalt refactor thy code: Regularly review and improve your code. Refactoring keeps codebase clean, efficient, and adaptable to change.

Thursday, June 5, 2014

Change ‘Edit Top 200 Rows" on SQL 2008

Working with live data and 'concerned' clients, i always have to recheck and modify data from database using SQL 2008. 

The default value for editing table only 200 rows, and the rest i have to do it using script. A bit tedious because i cannot actually read the data and edit it. 

But here is the solution yey :D

Tools >Options >SQL Server Object Explorer, Expand this tree ‘Commands’

I change the '200' to 0 , and i will get all data :)
Hope this will help :)

Thursday, February 27, 2014

Get image details using PHP


Syntax

list($width, $height, $type, $attr) = getimagesize("image_name.jpg");

Code

This is a sample code, change image_name to your image name and test it!

list($width, $height, $type, $attr) = getimagesize("image_name.jpg");

echo "Image width " .$width;
echo "
";
echo "Image height " .$height;
echo "
";
echo "Image type " .$type;
echo "
";
echo "Attribute " .$attr;

?>
Simple rite :)

Wednesday, October 2, 2013

What is actually in my mind..

I am a programmer or some people call it system developer. My work is to do the thinking other people don't want to do- that's what i do for a living. I think.

I like to think and do calculation and making logic. My judgement is only based on math and logic and structure. If the math is correct, does it logic? If its logic will it provide a good structure for the foundation?
When all lead to YES, then i will start typing my codes, hundreds and thousands of lines, to build one perfect system for the client.

When i work, i love quite uninterrupted place. Where i can do all the math inside my brain before my fingers start moving typing the codes. When the logic become hard, my brain work really hard and i will be easily annoyed even with simple not-so-funny conversation.

Programmers is not weird person, they just being themselves, thinking and structuring. Well at least they are more realistic than some people who converse a lot or very loud but well an empty can. Not all, some people can be very loud but they have the brain or at least vision in life.

I might be very quiet ( sometimes ), that is when i analyzing new people or people i don't really know. I prefer to absorb all the talking rather than do the talking. Sometimes i just laugh at some stupid boasting talk some people will do to impress other people. Gosh, maybe the saying "It's better to keep silent and be thought as a fool , than to speak and remove all doubt" is indeed true :)

So when some people very quiet, don't simply judge them by saying they have the cruelest mind or cold or stupid or do not mingle or whatever negative judgment you have in mind. before you put any judgment on other person, make sure you are perfect. If not, you just another dog who bark the loudest but doesn't bite. After all action is better than just mere talking rite? :)


Tuesday, January 8, 2013

Wrong 'Loaded Configuration File' path on phpinfo

That's killing me!

My phpinfo(Loaded Configuration File still pointing to my other php. I have 3 different servers in my machine. WAMP Apache, IIS and hardened Apache. 

Solution? :D

Just add this at Apache configuration : httpdconf, and walla! Happy happy.. :D . Or you can read more here


AddType application/x-httpd-php .php
PHPIniDir "C:/Program Files/PHP5"

Thursday, October 25, 2012

PHP : Deprecated: mysql_escape_string()


The website that i currently working on now in a final stage where it need to be uploaded and setup at the client's server.

And i actually just waste my 30 minute trying to figure out what's went wrong with all my codes after I push the script to production server.

I am using mysql_escape_string() in most of my pages and now i get this error :


How to solve? Simple haha:


mysql_escape_string is not depreciated from 5.3 but, for 4.3.0 and above. So any One using PHP version above/or 4.3.0 should use mysql_real_escape_string


So thats it :)

Related Posts with Thumbnails