Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Tuesday, May 26, 2015

error: The following untracked working tree files would be overwritten by merge

I'm using Git for version control and because the repository is sometimes directly modified for urgent fix to test some theory in the staging server (not the best way for doing things), I’ll occasionally get an error similar to the one below one when doing a git pull:

error: The following untracked working tree files would be overwritten by merge
 [list of file(s) here]
Please move or remove them before you can merge.
Aborting
In my case, I will want to overwrite these files. So I use the following:
git fetch --all
git reset --hard origin/master

This will get the latest repository files without merging and resets the master branch and overwrites the modified ones.

Wednesday, February 4, 2015

Google Maps API HOWTO: Retain zoom and center after refresh using cookies

Q: How do I make Google Maps retain the user's view (zoom level and center point) after an HTTP refresh?

A: You could do the following:

// Use events to load the saved map state any given time
 loadMapState();

// You could use event listeners to keep track of map view changes as zoom change, map finishes loading tile etc
google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
function tilesLoaded() {
    google.maps.event.clearListeners(map, 'tilesloaded');
    google.maps.event.addListener(map, 'zoom_changed', saveMapState);
    google.maps.event.addListener(map, 'dragend', saveMapState);
}   


// Here are the suppoert functions needed to make all this work

function saveMapState() { 
    var mapZoom=map.getZoom(); 
    var mapCentre=map.getCenter(); 
    var mapLat=mapCentre.lat(); 
    var mapLng=mapCentre.lng(); 
    var cookiestring=mapLat+"_"+mapLng+"_"+mapZoom; 
    setCookie("myMapCookie",cookiestring, 30); 
} 

function loadMapState() { 
    var gotCookieString=getCookie("myMapCookie"); 
    var splitStr = gotCookieString.split("_");
    var savedMapLat = parseFloat(splitStr[0]);
    var savedMapLng = parseFloat(splitStr[1]);
    var savedMapZoom = parseFloat(splitStr[2]);
    if ((!isNaN(savedMapLat)) && (!isNaN(savedMapLng)) && (!isNaN(savedMapZoom))) {
        map.setCenter(new google.maps.LatLng(savedMapLat,savedMapLng));
        map.setZoom(savedMapZoom);
    }
}

function setCookie(c_name,value,exdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name) {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i
Source: Stackoverflow
NOTE: If you are using Google API v2 then you just can use map.savePosition()to save the current position of the map and then map.returnToSavedPosition()to restore the saved position . Trying to use these functions in v3 of the API can result in an error "map.savePosition is not a function" or something to that effect.

Tuesday, February 3, 2015

How to Ignore Changes in Tracked Files With Git

If you have added files into your GIT repository and at a later stage realized that you do not want to track changes to these files, here is how to achieve this without using .gitignore.

So you would type the following command:

git update-index --assume-unchanged

To start tracking changes again on that file you need to use the following command:

git update-index --no-assume-unchanged

See the git manual for more info

Tuesday, January 20, 2015

How to init a git repo in an existing staging or production server via SSH

Init the repo
SSH to the server and navigate to the project location
$ rm -fr .git
$ git init
$ git remote add origin your-git-url
$ git fetch
$ git reset --hard origin/master    **

**IMPORTANT NOTE:
git reset --hard
  abandon everything since your last commit; this command can be DANGEROUS.
  If merging has resulted in conflicts and you'd like to just forget about
  the merge, this command will do that.

For pulling future updates from the server:
$ git pull origin master (or whichever branch you are pulling from)

Chitika Ads