Git on Mac

October 12th, 2011 No comments

Two things that I have found really useful when working with Git on a mac:

First autocomplete in terminal. When I started using Git I used the client program Github for mac, but because I found it too buggy i switched to only using the terminal. This also gives you a better understanding of what's going on. But the problem was I could not autocomplete git commands. Luckily this was really simple to add this feature.

Download this script and save it as git-completion.bash

https://github.com/git/git/raw/master/contrib/completion/git-completion.bash

Add the file to your .bash_profile

source ~/git-completion.bash

 

Then make some shortcut alias in .gitconfig

1
[Alias]

1
st = status

1
co = checkout

1
br = branch

1
ci = commit

1
rb = rebase

Remember to restart you terminal (or open a new window).

Another very useful thing is to show you working branch in the prompt. Here you just have to change your PS1 in .bash_profile. There are many ways to do this and some really nice ones are shown here:

http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt

I don't see a reason to put the hostname (computername) in the prompt, so after some modification I ended up with this:

export PS1="\[\033[1;33m\]\u\[\033[01;34m\] \w \[\033[31m\]\`git branch 2> /dev/null | grep -e ^* | sed -E  s/^\\\\\\\\\*\ \(.+\)$/\(\\\\\\\\\1\)\ /\`\[\033[37m\]$\[\033[00m\] "
Categories: Bash, Git, mac Tags: ,

write to file in linux

May 20th, 2011 1 comment

If you want to write to a file in linux you can do the following:

echo "something" > /var/log/test.log

but if the test.log file is only writable by root, then you have to use sudo. 

sudo echo "semothing" > /var/log/test.log

but this also fails because it is only echo that is running as sudo not the actual writing to file.

The way I do this is my using the tee command:

echo 'something' | sudo tee /var/log/test.log

You could also do:

echo "echo 'something' > /var/log/test.log" | sudo sh

but that seems more hacky….

Categories: Uncategorized Tags:

Undefined variable: javascript in CakePHP

April 17th, 2011 No comments

I was trying to make CakePHP dynamically add javascript and css files, but I kept getting the error Undefined variable: javascript. I was sure that I had added the Javascript helper in the app_controller. After some results on google I found out that if you misspell a helper name then CakePHP will throw this error. It has nothing to do with the object $javascript not being defined.

So I changed: 

var $helpers = array('Form', 'Html', 'Javascript', 'Time','Sessions');

to 

var $helpers = array('Form', 'Html', 'Javascript', 'Time','Session');

Session is not in plural…

Categories: CakePHP, PHP Tags:

Backspace in nano

April 13th, 2011 No comments

If backspace in nano does a forward delete instead of deleting the character to the left, then open the file /etc/nanorc and comment out the line set rebinddelete.

This should fix the "problem".

Categories: Uncategorized Tags:

Quiz

January 12th, 2011 No comments

We found a small bug in our codebase the other days, which led to a funny discussion about how PHP acts in different situations.

Try look at the following example. What will $i be?

$i = 10;
$i = $i + 2 + $i = $i + 5;
echo $i;

Give an answer before you plot it in the console :)

Ruby will give the same answer:

i = 10
i = i + 2 + i = i + 5
puts i

Here is another one:

$d = 0;
$d = 2 + $d == $d = $d + 2;
echo $d;
Categories: PHP, ruby Tags:

Hiring Software Developer

January 12th, 2011 No comments

We are hiring a new Software Developer to our team in London. You can read about the position here:

http://www.footballradar.co.uk/job_developer.html

Categories: Uncategorized Tags:

February 7th, 2010 1 comment

Grooveshark.com had some problems this morning, but the error page was funny.

It took me a second to find the text after "Going down for a bit" :)

Categories: Uncategorized Tags:

Twitter

August 27th, 2009 No comments

 Because of curiosity I have now signed up at twitter. I don’t know how much I will use it, but who knows. First impression is that it is exactly like facebook status messages. The main difference, as I see it, is the possibility of showing what people are saying (sorry twittering) about a certain word. This feature is not available on FB.

After spending a few more minutes I experienced something that I haven’t seen on FB…. SPAM!! I suddenly had 2 followers, but when I saw that it was "toyskatsfac" with the message "COME LOOK AT MY NEW NUDE PIX http://is.gd/2Crhs" and "Sabrina3w29" with the message "any cute single guys? comment me at http://xurl.jp/xb3a" I knew that it was SPAM..

So 5 minutes after I signed up I had to deal with SPAM. I can block the people, but it leaves a negative impression of the site. Hope it is getting better.

Follow my tweets on www.twitter.com/johanlaidlaw (If there will come any)

 

 

Categories: Uncategorized Tags:

Travel blog

March 29th, 2009 No comments

I’m leaving for a 5 month adventure on tuesday. The trip starts at Venezuela and ends in Kenya. The trip can be followed at www.johanlaidlaw.dk/into-the-wild 

Categories: Uncategorized Tags:

New phone

February 8th, 2009 No comments

Depending on the Android market and the upcoming phones supporting Andriod, I think I have found my next mobile phone. The Iphone 4G is a beauty. This is not an apple release and therefore i’m not sure how trustworthy the design image and the facts are. What I do know is that the titanium and glass design would make a perfect match with my MB Pro. Judge for you self.

http://i.gizmodo.com/5145151/iphone-4g-concept-is-a-macbook-in-a-phone

And yes, square is the new round…

 

Categories: apple, mac, tech Tags: ,