Seeing changes and diffs introduced by particular revision in mercurial

How to get changed files by revision in mercurial?
Here is a simple tricto see the diffs of files by revision in mercurial (hg)

Say if you want to see the changes by revision number 8976 then

to see the changed files :

hg status –change 8976

and to see the diff

hg diff –change 8976

error image

403 You are not allowed to access this page – yii error when accessing gii

403 you are not allowed yii error

403 you are not allowed is the error I got while using the young php framework YII. So far I am enjoying the yii framework. But, before I start to evangelize about it, I have to get some muscles on it.

Do you the different types of posts

I stumbled upon the above error when I start new project. The fix is on the ip filer of the main.php in the protected/config folder.

More on the fixing 403 you are not allowed error

On the config where there is a 'gii' => array(..), there is a ipFilters where you can list your own.

If not provided, local host will be the default and there should not be any problem, so one solution can be to have empty array for ipFilters.

Another is providing $_SERVER[‘REMOT_ADDR’] provided you are using it knowing the risk.

[: too many arguments error in bash script

You are writing shell script and got too many arguments error

While writing bash script, if you got this error, check where you are making expression test like in

if [ $somevar = "value"]; then
..

if the $somevar is something you are getting it from another command [ say grep or ls] which happen to return a lot of results that are separated by space or something you end up having it being

if [file1 file 2 file 3 = "value"]; then

The easiest solution for this is to enclose the variable in double quote like

if [ -n  "$somevar"]; then
some more commands goes here

Click here to see more on bash

Recommended: Solving Algorithms

Given array of numbers, find k complementary numbers – those which would add up to k. Here is how to solve it

How would you find three numbers that would add to number T from the list of numbers? Compare your solution with this one

With limited memory, and lots of storage, find the missing numbers from a file containing billion numbers in efficient way. Check the attempted solution for it

Simple bash script for searching keyword in the given directories linux

I find myself using grep over and over again for searching some keyword in the same directories. I write this, very simple and almost single usage script to accomplish the task

#! /bin/bash

# Find the given keywork in the given directories #

if [ $# -lt 1 ]; then
    echo $"No Keyword is provided"
    echo $"Usage: ./search_keyword.sh needle"
    exit
fi

keyWord=$1

#list where you would want to look inside the directory

directories="dir1 dir2 dir3 dir4 dir5"
for directory in $directories
do
    if [ -d $directory ]; then
        echo $"Serching in $directory"
        grep -ir --color $keyWord $directory
    else
        echo $"#### Directory $directory does not exist ####"
    fi
done

Getting the difference between two branches in mercurial

How to find the difference between branches in hg

Distributed revisioning systems would allow multiple branches which could be local to your computer or in the remote ones.

One aspect of working in distributed revision systems is the ability to see the diff between the branches and make a decision off of that.

Let’s say you have branch named branch-one and the other being default repo.

If you want to know what difference is there between the two branches in mercurial, say what is in the branch-one but not in the default do:


hg log -r "'branch-one' - default"

There are also a couple of predicates that you can assign – just search with “hg revsets”

Checking if the array contains same type variables like all numeric in php

I was in need of checking if the given array is all numeric or not. A colleague suggested with snippet the use of array_reduce – here the implementation

$numbers = array(1,22, 7, 34, 20);
$all_numbers = array_reduce($numbers, function($val1, $val2){
   return $val1 && is_numeric($val2);
}, TRUE);

Should do the trick.
zaTisIT!!

Newer version of mysql exists error while installing on Mac OS

I was reinstalling my mac machine and wanted to install my goodies [PHP, Apache, MySQL] on it and I come up with the newer version error when i try to install mysql.
here is what I gather from different sites and blogs:
Go to the terminal and issue these commands
sudo rm /usr/local/mysql*
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf
sudo rm -rf /var/db/receipts/com.mysql.*

This has taken care of the error for me

Number of rows that would have been returned in case of Limit in mysql

The thing is, you would have sql that have LIMIT appended at the end like

select * from sometable limit 25

but what if you wanted to know how many rows would have been returned if it was not limited?
the trivial approach is

select count(*) from sometable

and then issuing query with limit on it.
This is slower solution.
here is the way to do it in a better way

select sql_calc_found_rows * from sometable limit 25;
select found_rows();

Right after execution the select with sql_calc_found_rows, we would get the ‘would have been’ value on the second query.