plasticboy.de

About the art of building metaphoric solutions to real world problems.

Archive for the ‘Programming’ Category

I had to set up a source code repository for my personal coding projects. In the recent years I had some very good experiences with subversion. While in use I never saw any big trouble and it worked like charme. But the time is right to jump on the hype and use one of the distributed version control systems now.

My decision was to use git this time and give it a try. I don’t know what to expect but let’s roll.
By the time this tutorial was written, gitosis was not in the ubuntu repositories, so I had to install it manually.
After the installation was done, I was stunned how fast it was over.

But see for yourself:

Step 1
First we need to get git on our machines.

sudo apt-get install git-core

You need to do this on every machine – client and server.
From now on we can start to use all git commands. But what we really want is a server installation, so it’s not over now.

Step 2
All following steps are done on the server.
Log into your server using ssh.
In the end we will have a service running git.So it is a good idea to create a system user for that task:

sudo adduser \
    --system \
    --home /home/git \
    --shell /bin/sh \
    --gecos 'git system user' \
    --group \
    --disabled-password \
    git

Step 3
Also install the python set up tools for the compilation and installation of gitosis.
Yet again, another call for apt:

sudo apt-get install python-setuptools

Step 4
Now we have everything together to install gitosis. For the installation we do our first clone of the sources and immediately install them:

mkdir ~/tmp
cd ~/tmp
git clone git://eagain.net/gitosis.git    #here we fetch the sources
cd gitosis
sudo python setup.py install

Now gitosis is installed.

Step 5
In the end you have two choices:
If you use ssh logins via keyfile, then you can use the following command to fire up gitosis:

sudo -H -u git gitosis-init < ~/.ssh/authorized_keys
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

if you don’t have ssh via keyfile use this:

sudo -H -u git gitosis-init
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

You’re done!

You can validate your installation if you run following command on your client:

cd ~/tmp
git clone git@YOUR_SERVER:gitosis-admin.git
cd gitosis-admin
  • 0 Comments
  • Filed under: Programming
  • javascript

    My current project involves some jQuery code.
    I needed to alternate the background color for a html table with subtables and i wanted to do it in javascript.

    So if your table looks something like this, use my Javascript code to color the rows:

    <table>
       <tbody class="Alternate">
            <tr><td>I'm a row</td></tr>
            <tr><td><table><tr><td>I'm a subtable for whatever purpose...</td></tr></table></td></tr>
            <tr><td>I'm a row</td></tr>
            <tr><td><table><tr><td>I'm a subtable for whatever purpose...</td></tr></table></td></tr>
            <tr><td>I'm a row</td></tr>
            <tr><td><table><tr><td>I'm a subtable for whatever purpose...</td></tr></table></td></tr>
            <tr><td>I'm a row</td></tr>
       </tbody>
    </table>
    

    Here’s the the JavaScript.
    It’s a one liner, but i wrapped it for better readability

    	//Nice trick to get zebra tables with subtables
    	$("tbody.Alternate > tr").filter(function (index) {
                      return index%4==0;
    				  }).addClass("Dark");
    

    Finaly the CSS.

    .Dark {background-color: green;}
    
  • 0 Comments
  • Filed under: Programming
  • I’ve seen this video linked on reddit today.
    As some of you know, I am totaly into machine vision these days and this 3d tracing software that imediately caught my attention.

    Think about putting your face into your favorite video game – the term “Headshot” needs to be redefined then.

    I installed Java 6 on a Strato V-Server today that a default installation of Ubuntu 8.04 LTS.
    Per default, the multiverse packages are all disabled, so you need to edit the file /etc/apt/sources.list to make it look like this:

    # See sources.list(5) for more information, especialy
    # Remember that you can only use http, ftp or file URIs
    # CDROMs are managed through the apt-cdrom tool.
    
    deb ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy main restricted universe multiverse
    deb-src ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy main restricted universe multiverse
    
    deb ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy-updates main restricted universe multiverse
    deb-src ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy-updates main restricted universe multiverse
    
    deb ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy-security main restricted universe multiverse
    
    deb-src ftp://ftp.stratoserver.net/pub/linux/ubuntu hardy-security main restricted universe multiverse
    

    Then don’t forget to run

    sudo apt-get update
    sudo apt-get upgrade
  • 0 Comments
  • Filed under: Linux, Programming
  • First be sure that the file you want to read is JSON syntax.

    Then it’s a shot “with the bullet though the back into the eye”, as we say in germany:

       // Getting gile myFile.json file
       var file = Mojo.appPath + 'myFile.json',
       fileFromAJAX = new Ajax.Request(file, {
         method: 'get',
         parameters: '',
         evalJSON: 'force',
         onSuccess: this.fileReadCallback.bind(this),
         onFailure: this.fileReadErrorCallback.bind(this)
       });
    
    MainAssistant.prototype.fileReadCallback = function(transport) {
       var resp = transport.responseJSON;
       this.myVar = resp.myVar;  //Here you can access your variables in your json file.
    };
    

    That’s it.
    I hope they will change this in future versions of WebOS.

  • 0 Comments
  • Filed under: Programming
  • Simple, fast and good:

    DELETE
    FROM MyTableWithDuplicates
    WHERE
    rowid not in
    (
    SELECT min(ROWID)
    FROM MyTableWithDuplicates
    GROUP BY Col1, Col2, Col3  --you may enter all columns here you want to check.
    );
  • 0 Comments
  • Filed under: Programming
  • Yet another mystery solved..
    I got the very annoying error message that my disk space in C:\Windows\$NtServicePackUninstall$ is full.
    But there was more than enough disk space on my fresh installation of Windows XP on from a bootable USB stick.

    There is a workaround that was originally only intended for iMac Users who switch to the dark side :-)
    But it works pretty well for Lenovo Ideapads (and mybe some other Netbooks that run into this message).

    Before you install Windows Service Pack 3 follow these steps then:

    Step 1:
    Press “Win”-Key + “R” (alternatively Start -> run) and enter “regedit” and press enter. This will bring up your registry editor. Be aware that this is the moment where you can do serious damage to your windows software installation. So don’t mess around if you don’t know what you do.

    Step 2:
    Navigate to
    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup

    Step 3:
    In the right pane, click right mouse button and “New String” or (“Neue Zeichenkette” for Germans).
    Name it “BootDir” and give it the value “C:\

    Step 4:
    Close regedit and retry installing Service pack 3.
    It should work now.

    Please drop me a comment if I could help you.

  • 0 Comments
  • Filed under: Programming
  • These steps are for ubuntu users. the paths may differ for other linux distributions but i think the steps are the same.

    Be sure to have installed Ogre3D and code::blocks on ubuntu before you proceed. The ogre3d wiki is a good start if you search for installation how-to’s.

    Step 1:

    Open Code::Blocks and create an ogre3D project with the wizard.

    Step2:

    After creation right click the project in your workspace and choose the “Project Build Options“.

    Go to the  “Linker Settings” tab and change the libOIS and libOgre paths according to my screenshot:

    codeblocksogresettings

    Step 3:

    Goto the “Search directories” tab and in the “compiler” subtab add the path to the ExampleApplication.h file.

    in my case it’s

    /home/myuser/Development/lib/ogre/Samples/Common/include

    You should be able to compile your project now. :-) )

    Step 4:

    Now we need to make sure, that the the run command also works on our small project.

    Therefore we need to change the execution path of our project’s binary.

    This can be done by right-clicking  the project in the workspace again but this time select the “Properties…” option.

    Switch to the “Build targets” tab and alter the parameter for “Execution output dir:” to your ogre3d installations sample folder.

    In my case this is

    /home/myuser/Development/lib/ogre/Samples/Common/bin

    Now you can run the project.

    That’s it. Happy coding.

  • 2 Comments
  • Filed under: Linux, Programming
  • I use http://www.box.net as my online storrage and backup solution. The service is very easy to use and very well developed. You can upload files and share them with people you invite – all within your browser.

    And best of all: The basic account is free and gives you 1GB of storrage space.

    But what most people don’t know, box.net offers a WebDAV service. You can easily integrate the Service into your file explorer. This is easy on linux but bothered me for a few days on Windows Vista.

    And guess what: Without a little patch it’s even impossible to use secured WebDav with your Windows Vista installation if you don’t have either Microsoft Office or IIS installed.

    1. So first thing you have to do if you run Vista is get the patch at http://www.microsoft.com/downloads/details.aspx?FamilyId=17C36612-632E-4C04-9382-987622ED1D64&displaylang=en  
      YOU DON’T NEED THAT PATCH IF YOU HAVE WINDOWS XP!
    2. After installation open your file explorer right click “Computer”.
    3. Select “Map Network Drive
    4. Enter https://www.box.net/dav
    5. After that you’re asked for login and password
    6. Done. You can select the folder in your explorer now.

    As you see. Easy as usual on windows :-P

  • 0 Comments
  • Filed under: Programming
  • Yes, it is possible and it’s not that hard as you may think:

    sudo apt-get remove cabextract
    sudo apt-get install cabextract
    ./ies4linux

    try running this command that actually worked for me:

    ./ies4linux –no-gui
  • 2 Comments
  • Filed under: Linux, Programming

  • Recent Comments

    Links


    Add to Technorati Favorites

    Archives