Tuesday, March 20, 2012

Jenkins + git + Heroku on mac

To automate the deployment and testing of my brand new Heroku backed Django app, I wanted to setup a Jenkings CI system on my home macmini.

That was not wuite as easy as I has thought it was.

Getting it running was easy, just use the installer. And there is a git plugin, sweet. But getting that to work was a pain.

When ever I tried to fetch the project for heroku git repo, I would end up with weird errors. For some reason Jenkins wanted to read .ssh keys from /etc/root, write Heroku credentials to my own home directory etc.

After poking around a bit I found out that the default installation of Jenkins runs it on user 'daemon'. This user does not have it's own home directory. Instead is uses root's home. Which is baaad, m'kay.

So, first step wast to reinstall Jenkins so that it would NOT run it with daemon user. Key to it is to select "Customize" during the installation process and select the option to create jenkins user. This seems to fix the problem, the jenkins is now running with it's own account. Awsum.

But still no luck.

Even though I created the ssh keys, the Jenkins does not seem to find them, and git keeps giving "status code 128: Host key verification failed." error. Hmm.

What I was missing was that the keys had to be added to heroku. For some reason I thought that "heroku login" owuld add them there, but obviously not (why would it). To make it work I did this as jenkins user:

heroku keys:add

But still nothing, same error. Wtf.

It turned out that actually the error was not about the ssh keys at all, but the missing server RSA fingerprint from known hosts. So, after I tried to clone the repository from shell (as jenkings user) the error went away!

...and was replaced with another one:

"fatal: empty ident not allowed"

It seems that Heroku requires that you set email and username for git (although it did not require that from commandline..)

But still nothing!

It seems that the jenkings for some unknown reason does not use the correct home path (/Users/Shared/Jenkins/Home), instead is leaves the /Home out. Then I created a symlink to .gitconfig on /Users/Shared/Jenkings...

sudo -s -u jenkins
cd /Users/Shared/Jenkings
ln -s Home/.gitconfig

And it worked! Yatzy!

Wednesday, January 11, 2012

Django static files on Heroku

After completing Django-Heroku Hello World, I realized that the static files were not served properly. I found this and after modifying urls.py like this it started working. Great!

Monday, August 23, 2010

RHEL is hell

http://www.cyberciti.biz/faq/howto-install-c-cpp-compiler-on-rhel/

Thursday, August 12, 2010

Splitting strings in shell script

Nice way to pass parameters to a script is to put them in a properties file and then read the file in the script and do something with each parameter in the file. But often it is neccessary to pass more than one parameter for each line. One way to do this is to use some kind of separator between the parameters and split each line in the script using the separator. Here is one way to do it.

Example input file:

foo:2
bar:109
baz:23


To read this file, we can use script like this:

#!/bin/sh
for LINE in `cat input_file.txt`
OLDIFS=$IFS
do
IFS=":"
arr=($LINE)
echo "First: ${arr[0]}"
echo "Second: ${arr[1]}
done
IFS=$OLDIFS


The output should be:

First: foo
Second: 2
First: bar
Second: 109
First: baz
Second: 23

Thursday, August 13, 2009

Amazon sells virtual servers

You can actually buy (or rent) virtual servers from Amazon!
http://aws.amazon.com/ec2/

Friday, September 19, 2008

I missed the party!

Not only did I not get to go to the DjangoCon (and miss the official party), I also missed the local shadow party also. Damn.

Sunday, October 7, 2007

Unslunging the nlsu2

I finally got myself a nice little linux box. Or, actually it is a NAS adapter, a small box that can turn your USB drive to a networked NAS station. Nice thing about it is that it runs Linux and there is a community of hackers that provide an alternative firmwares for it. So, with a little tweaking you can get it running pretty much any software you want.

Well, now after reading the wiki and other instructions for a day, it seems that "little tweaking" is a relative term. For example, I would like to try to use a USB flash stick as the only "hard drive" for the system. However, to flash the new firmware all the discs should be formatted to ext3 file system with the NSLU2. But it won't format any flash drives. Duh. And the instructions for unslung (one of the alternative firmwares) explicitly says that the instructions should be followed step by step, no improvising. But there is no instructions for this case. And I know there are systems running with only flash drives.

And I don't have a cross-over ethernet cable that is needed if I wanted to connect the slug directly to my computer. And that is needed if I ever wanted to telnet to the box in recovery mode, let say, if I failed the flash and made a brick out of my brand new slug.

Well, I guess nothing can go wrong...

(Edit): And nothing did go wrong! I now have a nice little linux server on my desktop!



For some reason the package feed of ipkg is missing, so I can't really install any cool stuff (like mandatory ssh daemon) on it yet.

Sunday, April 15, 2007

Google tech talk: Python for programmers

There is an interesting video at Google video. As a part of the Google Speaker Series, Alex Martelli held an lecture about Python aimed to programmers. Check it out.

Saturday, April 14, 2007

Rich internet applications

For a while I have been convinced that the future of the so called "office applications" is the online world. I have been using the gmail for years now, and my main office suite is the Google apps with the Google notebook application.

At first these were not so hot. Gmail had only the very basic functionality and the spreadsheet & docs applications were quite slow, atleast on my not-so-state-of-the-art computer. But even then I was ready to move most of my text editing, spreadsheets etc. to these applications that run inside the browser. And they have come a long way since then. I actually did all my esseys for the Sociology course with Google notebook (it is much lighter app compared to the actual texteditor, Google docs, and since I did not need any fancy formating I was happy with a basic text editor that the notebook application provides).

Why? Well, I use several computers at home, work, public libraries etc. Quite often I have ran into the same problem: I don't have my work files when I need them. Or, if I do have them on a memory stick or CD, I end up having the several versions of the same files. Same goes with bookmarks, emails and stuff. With the online applications I now have all the documents available where ever I am (if I only have the Internet connection available) and I never have to worry about having the right version of the office suite on the particular computer I am using.

About the rich internet applications, I ran in to an interesting article about the Java, Javascript, AJAX and Flash. The article discusses about the reasons why Java (as applets) has not become the main platform for rich internet applications implementation on client side, why javascript is so popular and why it is just a compromise. The reasons are actually dead on and exactly the same as I have been thinking about, but what comes as a suprice to me is that the Flash is being used more and more as a platform to implement real applications to internet. i personally have no experience of creating anything with Flash, and I have always considered it as a multimedia show platform that can be used to implement rodimentary games at best. But it seems that there is some real potential in Flash. Atleast after seeing what has been dome with Gliffy. I think that could well be the next addition to my "online office suite".

Gliffy is a drawing tool, like MS Visio, implemented fully with Flash. You can create your own drawings, publish them to the internet, save as images etc. And as gmail, google docs etc, IT JUST WORKS! No installation needed (I already have Flash installed, as 99,9% of the modern computers do), quick registeration (took 15 seconds max) an vĂ³ila, I was on my way creating my first online class diagram.


This is what I managed to create on the first try with Gliffy

Saturday, February 3, 2007

I do code!

Ok, so this is my 2nd blog so far. I decided to start a new one in english, were I would store some how-to's and other stuff related to coding (python, java etc.) in english, since my original blog is in finnish and I really don't like to mix two languages on same blog... And it is clearer to keep this stuff in a separate blog anyway.