Posts

Showing posts from July, 2012

How to quickly collapse all projects in solution explorer

Image
If you find it tedious and irritating to collapse all projects or hierarchical folder chains in Visual Studio's solution explorer  (as I've always been, especially with solutions having more than 30 projects), you may wish to give a try to  this Plugin  (Its free:). Its not something new but I recently came to know about it from my colleague Sumit  and just love it since.

PHP form

In this tutorial we will know how to create PHP forms. To understand this tutorial you need to have basic idea about HTML form . Typically for collecting information from users we use PHP form. Many kinds of form we use to collect user information such as login form, registration form. PHP form start with <form> tag and ends with </form> tag. See the example below how PHP form works. <form action="landing_page.php" method="post"> FirstName:<input type="text" name="first_name" /><br /> LastName:<input type="text" name="last_name" /><br /> <input type="submit" value="submit" /> </form> We usually use two parts in PHP form. The first part is action, and the second part is method. In the action part we use action page links. And in the method part we use method name such as $_GET or $_POST method. This method describes how we collect information from users

Passing variable values from URL with PHP Get method

Today we look at how can we sent variable data from one page to another page through url. In real life web application we need to send data from one page to another page.  To do this, we will open two pages. First page contains a URL with variable value and second page collects that value using PHP $_GET method. We name the first page is first_page.php and second page is second_page.php.  So the first page looks like this <a href="second_page">Second Page</a> Save this page in your localhost folder. This is a HTML URL example page. Now we see how to send data from url. To do this you need to put a question mark in the URL and then you need to write your variable with values. Now the page is <a href="second_page?name=Sharif">Second Page</a> In this portion we just set one value but in real life problem we need to send two or more values from url. To send two or more values you need to set & operator after each variable. So the page is <

PHP control statement and logical operator example

This tutorial is not like other PHP tutorial. To understand this tutorial you need to have enough knowledge on PHP control structure such as if, else, if….else etc and PHP logical operators. It gives you some capability to solve complex problem. Real life problem is very complex. For example, if Rahim age is between fifteen and sixteen then we call Rahim is teenage boy. So guys let’s start to write the problem in PHP code. <? Php $ Up_years = 20 ; $ Low_years = 15 ; If ($ up_years < 20 && $ low_years> 15) echo “Rahim is teenage boy”; ?> We now try to write the problem in another way, if Rahim age is not between fifteen and twenty and also is not between twenty and hundred then we call Rahim is a little boy. <? Php If (($ low_years< 15 && up_years > 20) && ($ low_years> 2 0 && $ up_years <100 )) echo “Rahim is a little boy”; ?> If Rahim age is fifteen or twenty then our program print “Now you are teenage”. We can solve it us

PHP comments

Normally to understand PHP code we use comments. We use comments to make PHP code more readable and understandable. Suppose you write a complex code and two years later you need to add new functionality in that code. But when you open your code you do not understand the code because you did not use comment in your code. Below some strategies are given for you. We make comment in two ways. (1)     One line comment (2)      Two or more lines of comment. One line comment If the comments do not exceed one line then we call it one line comment or single line comment. We use // symbol to represents php one line comment. See the example below <? Php / / This line show the hello everyone echo "Hello Everyone, This is My First PHP Code"; ?> Two or more line comments If your comment exceeds one number of line you can use double or more line comments. See the example below. <? Php / * This line show the hello everyone And also it print my first program * / echo "Hello Ever

Why we learn PHP

In this episode we'll see why we are trying to learn PHP and Why PHP is so much razzle-dazzle. The question is, there have many web programming languages throughout the world but why we want to learn PHP. I hope it is easy to answer these questions, so let’s start with us to discover the question. PHP is free. So you can easily use PHP without investing any costs. PHP language is platform independent. Independent means it supports Windows platform, Linux platform without any hassle. You can use any operating system and PHP perform same in all operating system. PHP is an object-oriented language. You cannot understand object-oriented languages now but I will discuss it. You can see object-oriented concept in our PHP object-oriented tutorial. PHP is now more popular because of object oriented capability. There are millions of people continuously develop websites with PHP web programming language. The demand of PHP web programmer increases day by day. So by learning PHP web developmen

What is PHP

Previous Tutorial                                                Next Tutorial The meaning of PHP is Hypertext Preprocessor . PHP is a server side scripting language. You may   ask me that why PHP is not programming language. I will discuss it but now you need to concentrate on PHP. Server side scripting language means that the language can contact with server and run in the server. PHP language is designed only for this kind of purpose related with web design and development. In our whole tutorial we use the term server that is actually means database and we use PHP-MySQL enable Vertrigo Server. We use server to store website information. We can show server information via PHP in the HTML page. Where the website information is stored in the database and the database information is displayed in the HTML page we can call this kind of website is a dynamic website . Otherwise if a website information shows only using HTML then we call this type of website is static website . So the thin

PHP tutorial introduction

Here this is your first attempt on PHP web development. You are here, because you want to learn PHP through our PHP tutorial . If you already knew a lot about PHP, this web site may help you in some aspects. But if you have no idea about PHP or if you are trying to learn PHP, then this website will show you the way. Before starting this expedition you have to know the following subject such as HTML & JavaScript.  Learning PHP is very easy and simple, we hope it will be a funny way. PHP is very simple language by comparing other programming languages. You can learn php from our website easily. I hope you will enjoy our PHP tutorial. We start with written PHP tutorial, at the same time I will try to provide video tutorial as well as PHP pdf tutorial so that you can understand our PHP tutorial easily. I suggest that firstly try to read the whole written php tutorial and then you can go to watch our video tutorial. Also you can download each php tutorial in a pdf format. So now

[Note] Useful shortcuts for Awesome window manager

mod + shift + tag-number: move window to specified tag number. mod + ctrl + shift + tag-number: duplicate window to specified tag number. mod + shift + ,: move window to left/previous tag number. mod + shift + .: move window to right/next tag number.

Distributed Team Planning Poker Tools

Planning Poker (PP) is among the most popular and effective estimation techniques available today. But  a question here - "How can I play planning poker with teams that are geographically distributed" ? There are likely many options to achieve this. Sharing a few common ones below: Option-1: Chat Window (Tried, but leaves loop holes for biased points selection) It is implied that communication mediums like GoTo or WebEx are used when teams are geographically distant. Once the requirements are clear, product owner can signal via an utter to give points and every member can use chat window of tools to put a number and hit enter. Option-2: Webcam (I'm using this one in current project - Not great fun, But works!) If communication medium used supports video conference with multiple people (Google+ video a free and popular one), one person takes responsibility of saying 1-2-3-Go and as soon as "Go" is said, teams can show up their cards on webcam. Since tools support

Factors to Take Into Account When Hiring a Web Designer

Hiring a web designer becomes a perfect solution for small business owners who want to have an interesting website because it enables them to have their desired website without spending too much money. As you surely have known, small businesses usually have small working capital. If they want to survive in this bad economic condition, they should be smart in spending their money. In this case, hiring a web designer is more affordable than employing an IT graduate because employing an IT graduate requires you to give monthly salary and other allowances. If you hire a web designer, you just need to pay for a project he or she carries out. Since you certainly want to get maximum benefits from hiring a web designer, you should choose a web designer selectively. For this purpose, there are three factors to take into account. The first factor is experiences. If you want to receive the best Web design Westchester , you should choose a web designer that has extensive experiences because the mo

Throw your own - Nested exceptions

If you think that working with exceptions is hard to understand, exception nesting will look even harder (nested exceptions, chained exceptions, exception bubbling - it is all the same). Well, it is a step above, and it can be used if your application is structured in several layers, but at the end you'll see that it is a concept which is here to make your life easier. The basic syntax try { // do something that can go wrong } catch (Exception $e) { throw new Exception( 'Something really gone wrong', 0, $e); } Yes, you could see that kind of example at php.net, but it still does not make much sense. Why you caught it at first place, just to throw a new one? To be honest, it is a bad example (just like the examples on php.net). No wonder that you can not understand it. But lets stick on it for one more moment. First, you caught exception, like in any other try catch block, and than you passed it to an another one. It means that the second exception has reference to the

Using V8 Javascript engine as a PHP extension (update: write PHP session)

"We Are Borg PHP. We Will Assimilate You. Resistance Is Futile!" Just got to something described as: This extension embeds the V8 Javascript Engine into PHP. It is called v8js and the documentation is already available on php.net , examples and the sources are here . V8 is known to work well in browsers and webservers like node.js, but does it work inside PHP? YES! Here is the installation on Ubuntu 12.04: sudo apt-get install php5-dev php-pear libv8-dev build-essential sudo pecl install v8js sudo echo extension=v8js.so >>/etc/php5/cli/php.ini sudo echo extension=v8js.so >>/etc/php5/apache2/php.ini php -m | grep v8 Let's run a small test script: <?php $start = microtime(true); $array = array(); for ($i=0; $i<50000; $i++) $array[] = $i*2; $array2 = array(); for ($i=20000; $i<21000; $i++) $array2[] = $i*2; foreach ($array as $val) { foreach ($array2 as $val2) if ($val == $val2) {} } echo (microtime(true)-$start)."\n"; // 8.60s $star

MySQL or MySQLi or PDO

Lessons learned: MySQLi is 3-4 times slower than MySQL when fetching less then 500 datasets MySQLi is 2-4 times faster than MySQL when fetching more than 500 datasets PDO is 2-5 times slower than MySQL/MySQLi Unbuffered queries are 15-40 percent faster than buffered queries in MySQLi Unbuffered queries are 10-25 percent faster than buffered queries in MySQL for less than 10000 datasets Unbuffered queries are 3-7 percent slower than buffered queries in MySQL for more than 10000 datasets Unbuffered queries are 0-5 percent faster than buffered queries in PDO Non thread safe versions of PHP on win32 are 50 percent faster than thread safe versions Here is the test script: $table = 'test1.test2'; benchmark($table, 100); benchmark($table, 500); benchmark($table, 1000); benchmark($table, 5000); benchmark($table, 10000); benchmark($table, 50000); benchmark($table, 100000); function benchmark($table, $size) { mysql_connect('127.0.0.1', 'root', ''); mysql_qu

Adobe Host Edit - CS6 and CS5

Image
PLEASE +1 FOR GOOGLE TO RECOMMEND THIS TO ALL To avoid any product of adobe from contacting its validation server for validating your product key and to get unlimited activated product time, you have edit your HOSTS file in your system Windows Goto C:\Windows\System32\drivers\etc\ a nd right click the " hosts " file and select properties. Get to the " Security " tab and click " Edit " button. In the new Dialog select your name or the system user name and assign " Full Control " and click " ok " to save. Now open the " hosts " file in notepad and add the following for respective products. Mac Open Terminal and type $ sudo nano /private/etc/hosts and enter username and password when asked. Append the following for respective products. Save and close. For CS5 127.0.0.1 activate.adobe.com 127.0.0.1 practivate.adobe.com 127.0.0.1 ereg.adobe.com 127.0.0.1 activate.wip3.adobe.com 127.0.0.1 wip3.adobe.com 127.0.0.1 3dns-3.adobe.com 1

ircmaxell: Is Autoloading A Good Solution?

ircmaxell: Is Autoloading A Good Solution? : at a 75% class usage tradeoff point, it doesn't really make sense not to autoload, especially given all of the other benefits. So in the end, it looks like autoloading is indeed a good solution... From the comments: Simply enabling APC sped up the fixed requires by 82%, and the autoloading by an amazing 91%.

Tips And Tricks To Get A Web Design Job And Various Online Job Alternatives

Are you hoping to have a job in web design or web development? If that's the case, I bet you will agree that it's quite effortless to get hung up on the title of the job you happen to be seeking out. Let us take for instance, most of the time web design companies just like website designer Louisville, get requests from people who wished to become "web designers" or "web developers". The tricky part is that they may already be established to acquire a job in the industry of website design, yet for the reason that wouldn't consider anything which doesn't have the title "Web Designer", they cannot or may find it difficult to get a job. Seeing that there are a lot of jobs found in the web industry, a person simply would need to figure out how to look for them. Here are several tricks to finding a great web jobs. The initial thing that you will need to examine is the job titles. Certainly, in the event that the word "web" is in the tit

Decorator or Subclassing?

Using anonymous functions in PHP is very nice to implement a decorator, but what about performance? Results: Subclassing is 40 percent faster than using a decorator Subclassing might require a bit more code Here is the code: class App { public static function route($pattern, $callback, $args) { // evaluate $pattern ... call_user_func_array($callback, $args); } } class AppJson extends App { public static function route($pattern, $callback, $args) { // evaluate $pattern ... $str = json_encode(call_user_func_array($callback, $args)); } } $start = microtime(true); for ($i=0; $i<10000; $i++) { AppJson::route('/json/range', 'range', [0,10]); } echo ' '.(microtime(true)-$start); // 0.1058s $json = function ($func) { return function() use (&$func) { $str = json_encode(call_user_func_array($func, func_get_args())); }; }; $start = microtime(true); for ($i=0; $i<10000; $i++) { App::route('/json/range', $json('ran

How to write a really small and fast controller with PHP (update: benchmark Slim, Silex, Zend Framework, Symfony2)

To handle a lot of traffic, we need a fast controller with very little memory overhead. First, we implement a dynamic controller . The design is based on the micro frameworks Slim and Silex . The first example maps the URL "http://server/index.php/blog/2012/03/02" to a function with the parameters $year, $month and $day: // index.php, handle /blog/2012/03/02 $app = new App(); $app->get('/blog/:year/:month/:day', function($year, $month, $day) { printf('%d-%02d-%02d', $year, $month, $day); }); Our controller is a class named App and uses the get() function to map a GET request. Parameters mapped to the function are marked with a colon. Optional parameters are written inside brackets. Here is an example: // handle /blog, /blog/2012, /blog/2012/03 and /blog/2012/03/02 $app = new App(); $app->get('/blog(/:year(/:month(/:day)))', function($year=2012, $month=1, $day=1) { printf('%d-%02d-%02d', $year, $month, $day); }); Instead of

How to implement i18n without performance overhead

i18n is always difficult to implement and costs a lot performance. Normally, implementations use gettext() or a custom t()-function to translate a string. t() searches a INI or XML file for a translation key and returns the value. For example t('setting', 'de'), gives the German translation 'Einstellung'. Typical optimizations use associative arrays (hashmaps) loaded into APC or Memcached. This requires a lot of memory for the array and produces a lot of cpu cycles for calling t() all the time. So the question is, can we do this better? Yes! We use a just-in-time compiler for our PHP files and write the compiled PHP files to disk, so APC can cache them like regular PHP files. An example PHP class looks like this: // example.php <?php class example { public function now() { return '{t}Hello World, now it is:{/t} '.date('{t}m/d/Y g:i a{/t}'); } } The "{t}" and "{/t}" patterns serve as opening and closing tags indi

Array key lookup: isset() or array_key_exists() or @ ?

Lessons learned: isset() is faster than array_key_exists() array_key_exists() is faster than @ @ is slower than ignoring notices with error_reporting() Here is the code running on a 1.4 GHz machine with PHP 5.4.0: error_reporting(E_ALL & ~E_NOTICE); $a = array(); for ($i=0; $i<100000; $i++) $a[] = $i*2; $start = microtime(true); for ($i=0; $i<100000; $i++) if (isset($a[$i])) {} echo ' '.(microtime(true)-$start); // 0.017 $start = microtime(true); for ($i=0; $i<100000; $i++) if (array_key_exists($i, $a)) {} echo ' '.(microtime(true)-$start); // 0.064 $start = microtime(true); for ($i=0; $i<100000; $i++) if (@$a[$i]) {} echo ' '.(microtime(true)-$start); // 0.095 $start = microtime(true); for ($i=0; $i<100000; $i++) if ($a[$i]) {} echo ' '.(microtime(true)-$start); // 0.016 $a = array(); $start = microtime(true); for ($i=0; $i<100000; $i++) if (isset($a[$i])) {} echo ' '.(microtime(true)-$start); // 0.016 $start = microtime

Most frequently asked software testing related question for all

1. I am newbie in software testing. I want to learn software testing and I want to apply it in my previous project. I search my query about software testing in Google. I learnt many things from Google about software testing but I don't know where from I can start as a new in software testing?? 2. I want to get my job as a software testing engineer but I am a fresh graduate. I don't know about industrial culture. Do you give me some suggestions about industry culture and their expectations from a fresh graduate? 3. Our subject is software testing and quality assurance. I know that total quality assurance is not possible for a specific solution. But I want to know what is the correlation between software testing and quality assurance? Why this subject name is software testing and quality assurance?? Is there any reasons for this kind of naming??? 4. I am now studying software testing and quality assurance engineering. What kind of key challenges will wait for us?? As a programmin

Top 10 things to remember in scrum sprint

Compiling 10 things to remember in sprint cycle (from theory and experience), which anyone following scrum anywhere, should remember!! 1. Spirit of Scrum says work and think using “We” and not “I” (No blame game and be ready always to lend a help, if it helps in completing sprint successfully) 2. There is nothing called “The Sprint partially succeeded” . It fails or succeeds in full i.e. all tickets must be delivered well and in time (think of DB transactions as analogy ) 3. Whenever you find yourself stuck on account of dependency, approach Scrum Master ASAP. 4. Following processes may sound boring. And following a new process may look a burden. But remember, it is We only who’ve defined process and should hence follow it for sprint betterment. 5. Keep standup short – What I did? What I’m doing next? Am I facing any issue or  has to discuss anything (after standup)? 6. Talk in numbers – Prefer JIRA (or whatever tool use) task numbers with a very small description for standup

PHP Deployment with Dropbox

Image
Deploying files over sFTP or scp is boring and takes a lot of time. Using git with commit-hooks to initiate the deployment process is comfortable, but there is a solution that's even faster: Deploy your server(s) with a Dropbox! Here we go, first create a new Dropbox account : Then install the Dropbox client on your Desktop (if you haven't done yet): Delete the example content in your local Dropbox folder: Next install the Dropbox client on your server. Dropbox packages for Linux can be found here . I'm using a 32bit version with my Ubuntu Server VM. Execute the following commands on the shell (as root): chown www-data:www-data /var/www su - www-data -c bash wget -qO - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf - # or: wget -qO - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf - .dropbox-dist/dropboxd > This client is not linked to any account... > Please visit https://www.dropbox.com/cli_link?host_id=d4b6c6b6bac2b

Development Principles - Think first programming

Image
A professor once told me: Remember, a string goes into the server, a string goes out. Not more, not less. So let's ask the following questions: do you need a seven tier architecture? do you need to write a servlet container in PHP? do you need to derive a class more than twice? where do you need OOP? do you need design patterns? how to choose the right technology? And here are the development principles: keep it simple and stupid! (kiss principle) don't write your architecture on more than one slide write less code, you must maintain it! test your code, you're responsible for it! don't import much code from libraries, you might need to fix or upgrade it don't trust user input, don't trust foreign code, trust your own code don't use design patterns you don't understand no backup, no future don't use technologies you haven't evaluated for the current task if you're not sure how to decide, make more tests don't follow general recommendation

Difference between NAnt Readonly and Overwrite

I'm assuming you're aware of NAnt basics (add a comment if you're not and I'll write up a detailed article). Intent ===================== Often, there is a confusion between overwrite and readonly  attributes for a property in NAnt. The intent of this small post is just to clear concepts revolving this. readonly: Marking a  property as  readonly=true   means, later it can not be changed during NAnt execution. If there is an attempt to do so, build doesn't fails, but displays a warning message.  Default is false Remember : When you attempt to set a property value by passing it from command line, you'll always get a read only warning message if you are setting value of same property in your build file. This is so because, passing a value from command line supersedes any declaration of same property and is always readonly (Do not confuse yourself that why I'm getting warning message about readonly when I've set readonly="false". It is because by p