Dienstag, 14. Februar 2012

How to access a remote git repository in your local network?


I don't always want to push my changes to my online repository, just to pull them
an instant later when I switch the machine I'm working with.

So how to access a git repository on a machine in the same network?
(I'm working on Mac OS but this should be applicable for Linux as well.)

First make sure ssh is enabled and the user you log in with, has access to the directory
where the remote repository is located.

Then run

git pull git+ssh://USER@IP_OF_REMOTE_MACHINE/PATH_TO_REPO BRANCH

e.g.

git pull git+ssh://fred@fred-air.local/~/my/repo master

Maybe you'll get following exception:

bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

This stackoverflow thread pointed me into the right direction.
http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly

In my case I had to edit the .bashrc on the remote machine located
in the home directory of the user I logged in with.

I added git-upload-pack located in /usr/local/git/bin to the PATH and it worked like
a charm.

Donnerstag, 1. Dezember 2011

How to implement and call nested methods on a jQuery plugin

Hello whatever,
after I wrote nearly a page on this damn blog my chrome tab simply crashed. Thx a lot. So here is the short version:
  • First official post
  • Why did I start a blog and why on this platform --> Read here
  • Wrote my first jQuery plugin for a customer
  • the way calling methods, described in plugin authoring guidelines, didn't suit my needs
  • wanted to be able to call nested methods
To make a call like this 
$('#someElement').myPlugin('util.someMethod');

I ended up with this:

var methods = { 
   util : {
      someMethod : function() {
         //do something
      }
   }
}

$.fn.myPlugin =  function(method){ 
    //calling nested methods
    var m = '';
    if (method.indexOf('.') > -1) {
        var objArray = method.split('.');
        var m = methods[objArray[0]];
        for (var i=1; i < objArray.length; i+=1) {
            m = m[ objArray[i] ];
        }
        return m.apply( this, 
           Array.prototype.slice.call( arguments, 1 ));
    } 
    //default way
    else if ( methods[method] ) {
       return methods[ method ].apply( this, 
                 Array.prototype.slice.call( arguments, 1 ));
      }       
      else {
       $.error( 'Method ' +  method + 
                 ' does not exist on jQuery.myPlugin' );
    }           
 };
Comments and improvements welcome.
Did I mention that I'm angry because the damn page crashed?

The Blog title is "work in progress". ;)

Thank you D. Schopper for helping me with this solution.