Enabling mcrypt for php >= 5.4 in Ubuntu 13.10

http://fmindesign.in/research-paper-on-drunk-driving/ Ubuntu 13.10 (Saucy) comes with PHP 5.5.3 and does not enable mcrypt by default. I am currently working on a personal project that requires to use mcrypt to encrypt and decrypt data. So I will need to enable it manually.

page To enable mcrypt is easy, simply following the steps below:

http://kirehalli.com/?p=high-school-senior-research-paper $ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/ $ sudo php5enmod mcrypt $ sudo service apache2 restart

Double Space Essay What “php5enmod” does is simply enabling a PHP5 module by creating a symbolic link from conf.d directory to the real config file under “mods-available”.

http://fionadalwood.com/taking-a-stand-essay/ So, after we run “php5enmod mcrypt” command, the following files will be created:

http://www.jsira.com/where-to-buy-college-papers.html /etc/php5/apache2/20-mcrypt.ini /etc/php5/cli/20-mcrypt.ini

term paper gold is associated with which are symlinks to

best man speech writing services /etc/php5/mods-available/mcrypt.ini

help on thesis The prefix “20” is the priority of module, and the default is 20 when you run “php5enmod” command.

http://sinarsehat.com/cheap-essay/ If you don’t need the mcrypt module for the command line, you can simply remove the symlink under /etc/php5/cli/20-mcrypt.ini.

Paper Writing Paper Writing Paper Writing Hope this helps.

The Meaning of GMT+11 in PHP

follow url Do you ever need to work with Time Zone info in your code? If no, you are lucky, if yes, then you might have encountered the strange interpretations of “GMT+11” in PHP.

http://aaryansblog.com/?p=school-discovery-comhomeworkhelpbjpinchbeck In common sense, either “UTC+11” or “GMT+11” would mean the GMT time + 11 hours, which will be the Standard Australian Eastern time in the daylight savings. However, if you ask PHP, you will get different result:

see url <?php date_default_timezone_set('Etc/GMT+11'); print 'GMT+11: '.date('Y-m-d H:i:s')."\n"; date_default_timezone_set('Etc/GMT-11'); print 'GMT-11: '.date('Y-m-d H:i:s')."\n"; date_default_timezone_set('UTC'); print 'UTC time: '.date('Y-m-d H:i:s')."\n";

buy dissertation cheapest Will give you the following result:

http://www.nbinflatables.com/i-love-to-do-my-homework-poem/ i love to do my homework poem GMT+11: 2013-12-18 13:14:53 GMT-11: 2013-12-19 11:14:53 UTC time: 2013-12-19 00:14:53

I am in Australia, and my “date” tells me:


dhcp-105:~ ericlin$ date
Thu Dec 19 11:15:12 EST 2013

You can see that my time actually matches with “GMT-11”, not “GMT+11”, surprise, right?

So be careful when you need to use time zone strings in PHP, give it a second though or you will face problems.

Getting Command Output via SSH2 Functions in PHP

Running command and getting the output via ssh2 is not as straightforward as running command directly using function exec(), it requires a few function calls using “stream”.

The following code illustrates how to do it:

// get connection
$conn = ssh2_connect($host, $port);

// login via pub-private keys
ssh2_auth_pubkey_file($conn, $username, $publicKey, $privateKey);

// run command via ssh2
$stream = ssh2_exec($conn, 'php -v');
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);

// get the output
echo stream_get_contents($stream_out);

This is simply for my personal note for future reference, but hopefully it can also help who might be looking for solutions for this.

Find All Possible Combination Of An Array In PHP

Today, one of the tasks involved at work required me to solve the problem outlined in the title of this post.

For example, given an array of (‘red’, ‘blue’, ‘green’), we want to return the following:

red 
blue 
red blue 
green 
red green 
blue green 
red blue green

Initially my first impression was to use recursive function call, but it turned out to be quite complicated. After googling, Tom Butler has a very simple solution. I have modified it so that it will return an array of combinations:


public static function getQuestionCombinations($array)
{
$return = array();

$num = count($array);

// The total number of possible combinations
$total = pow(2, $num);

// Loop through each possible combination
for ($i = 0; $i < $total; $i++) { //For each combination check if each bit is set $data = array(); for ($j = 0; $j < $total; $j++) { // Is bit $j set in $i? if (pow(2, $j) & $i) { $data[] = $array[$j]; } } if($data) { $return[] = $data; } } return $return; } [/code] Tom has already explained in this post about the idea behind the function. This saved me heaps of time.

PHPStorm – My One Month Trial

Last month I downloaded Jetbrain’s PHPStorm IDE and tried it for nearly a month. The main reason for the trial is that Eclipse simply doesn’t meet what I need. It is a great IDE offering lots of features, but it is slow and crashes often. I have been suggested through the LinkedIn discussion that lots of people love PHPStorm, even though it is a commercial product. So I decided to give it a try and ask my boss to pay for it if it meets what I need :).

boys state essay help Pros:

1. Speed – Even though PHPStorm is based on Java as well, its performance is much better than Eclipse. The indexing is not lightening fast, but faster enough to make me happy. The autocompletion is really handy at reasonable performance.

2. Inline diff – It immediately shows the diff you have made to a file by simply click on the icon next to the line number bar, and allow you to undo or copy the old text if you wish. Eclipse lacks this feature but Netbean does.

3. Class search + File search – I guess the main reason for them to break search into class and file is the performance, so when you are search classes, all other ordinary files can be skipped, and it is fast. Eclipse’s open file feature is not bad either.

4. PHPStorm’s SVN support is quite good, from what I can see anyway, although I don’t use this feature much. I am more of a command line user when it comes to managing svn files, some how I feel more comfortable do these stuff on a shell :).

5. Smart SQL support and syntax highlighting – not just php syntax. PHPStorm is smart enough to figure out whether a given string is SQL query or not and highlight it accordingly.

6. It tells you when there are unused variables in your code. If a variable is not used in the current function, it will be highlighted as grey:

 

go Cons:

1. PHPStorm is Java based, which makes it another memory hungry IDE:

I just used a few hours and it jumped to more than 400M already. And sometimes it actually jumped to more than 700MB of memory usage and I am certain that once you are in the debugging mode, the memory usage will be much higher.

2. It is hard to work on two or more different projects under PHPStorm, as it doesn’t allow you to show more than one projects at a time. You will have to keep switching back and forward:

Update: You can actually open more than one projects in different windows

3. When you have lots of files open, it is hard to see which file you are currently on in the tab section, the color chosen is really poor:

Update: PHPStorm 3 has slightly better tab colors:

4. Well, it is commercial and you have to pay. It cost $200 for commercial use and $100 for personal.

http://noordinarycamps.org/custom-blog-page-thesis-theme/ Conclusion:

So far I quite like PHPStorm compared with Eclipse. The performance  + SVN integration with inline diff are the key winner. I am certain that there are still lots of great features out there that are yet to be discovered. I will certainly persuade my boss to pay for the license as I will get performance gain out of this IDE.

Inspired by – Rich’s PHPStorm – my week’s trial