Daniel Banck

CTO at weluse • Amateur Chef

Page 2


P7P55D network driver on Ubuntu

I had a big problem with my network load on Ubuntu. Whenever I copied
files over a gigabit network my system suddently freezed. You can check
if you’re affected by this bug if something like link up, link down, link up, link down keeps showing up on dmesg on high network load.

The problem was that Ubuntu loaded the r8169 driver instead of the
correct r8168 one. I’ve found an easy solution to blacklist the wrong
and install the correct driver.

  • Download the lastest driver here.
  • Get the script from Github.

Have a look at the VERSION string inside the script. If the downloaded
driver is a newer one you have to edit the string.

Put the script and the donwloaded and compressed driver into the same
directory and execute the script via sudo ./switchmods. It will
blacklist the r8168 driver and install the new driver modules.

That’s it. Enjoy copying files at high speed with no freezes.

...

Continue reading →


pam_ssh_agent_auth with Ubuntu

You may have come across
pam_ssh_agent_auth which
allows you to forward the sudo authentication to your local ssh agent.

There are some great blog posts about installing / configuring it already, but I wanted to make it even easier. I’ve created a ubuntu package, available from my server ppa.

The installation is pretty straight forward:

sudo aptitude install python-software-properties
sudo apt-add-repository ppa:dbanck/server
sudo aptitude update
sudo aptitude install pam-ssh-agent-auth

After the installation is done, you just have to edit two config files
to enable it.

In /etc/pam.d/sudo replace @include common-auth with auth sufficient pam_ssh_agent_auth.so file=%h/.ssh/authorized_keys.

And in /etc/sudoers add this line:
Defaults env_keep += SSH_AUTH_SOCK

That’s it!

Now connect to your server via ssh -A to forward the ssh-agent. You may clear you cached sudo credentials via...

Continue reading →


POST Data with .net Html Agility Pack

I’m using the Html Agility Pack for getting and parsing HTML pages. It offers many possibilities, including XPath selectors.

Today I had a problem with posting data to a webpage. It’s possible to
call the HtmlWeb Load function with a second “POST” parameter, but
it offers no easy way to add values to be posted.

After a while of searching I came across this solution: add this two
functions to the HtmlWeb class. (You can get the source in download
section, too)

public HtmlDocument SubmitFormValues (NameValueCollection fv, string url)
{
    // Attach a temporary delegate to handle attaching
    // the post back data
    PreRequestHandler handler = delegate(HttpWebRequest request) {
        string payload = this.AssemblePostPayload (fv);
            byte[] buff = Encoding.ASCII.GetBytes (payload.ToCharArray ());
            request.ContentLength = buff.Length;
...

Continue reading →


Github, Windows and TortoiseGit - Part 1 Installing Pulling

This is a guide for all the Windows users (not me) out there. It will explain how to work with a github repository under windows using TortoiseGit.

Let’s get started. At this point you should be a collaborator or owner of a github repository. Download TortoiseGit. Install it like any other program. There are no special settings, just keep on clicking ‘next’.

Now download msysgit. During this installation you have to set some important settings. Please be sure that you set them correctly.

Adjust the PATH environment

Adjust the PATH environment

Choose the SSH executable

Choose the SSH executable

Choose line endings

Choose line endings

After the successful installation of both programs continue with the
generation of private and public SSH-key. To do this you have to start
‘PuTTY Key Generator’ - find it in Start -Programs - TortoiseGit

Just click 'Generate' and move the mouse

Just click ‘Generate’ and move the mouse

After it’s done you see your freshly generated ssh public key. You can
...

Continue reading →


Bug in cherokee

This only affects cherokee < 0.99.20.

If you’re trying to use cherokees ‘Advanced Virtual Hosting’ and a ‘File
exists’ rule it will not work. The rule is not matching any files.
Without the AVHosting the rule is working well.

I already reported this bug and it’s fixed in the latest svn version. So
if you need to work with AVHosting and this rule you better checkout
from svn and compile on your own instead of using any precompiled
packages.

But I guess in further versions the bugfix will be included.

View →


CakePHP and Cherokee

Getting CakePHP working with cherokee is really simple:

First put your CakePHP files into any directory. For me it’s /home/daniel/Web/dcms.

You can delete all the .htaccess files:

/.htaccess
/app/.htaccess
/app/webroot/.htaccess

Add a new virtual host to cherokee, set the document root to the CakePHP
webroot: /home/daniel/Web/dcms/app/webroot. Directory Indexes should be set to index.php.

Add a new PHP rule - with the new wizard it’s really simple - and keep
the default settings. Add a new ‘file exists’ rule and let it match ‘Any File’ and handle it as ‘Static Content’.

Cherokee matching rules

Cherokee handlers

How we need to modify the default rule. Change the handler to
‘Redirection’ and setup the regex like this:

Cherokee handlers default rule

(Internal, ^.\*$, index.php)

That’s it!

Just make sure that the rules are in the correct order (php, any file,
default):

Cherokee rule overview

Just save and access CakePHP via your defined domain.

CakePHP index page

Continue reading →


Using Jinja2 with Django

In the last days I tried to get Jinja2
working with Django. Here I want to
explain a bit about the integration progress.

First we need to install django and jinja2, but I won’t explain it in
here, just use easy_install. After installing you can check if
everything works by importing django and jinja2 inside a python
shell.

If it works we need to create a django project and a example
application. (Go for the django
tutorial
if you don’t know how to do this).

Now we need to tell django to use jinja2 to render templates. The best
way to do this is creating a little lib with function to do this which
one can import into the views. So we create inside our project root a
directory called libs and there an empty __init__.py file and a file
for the jinja2 things. Lets call it jin.py.

Inside this file we want to create a render_to_response function for
jinja2 templates which can be imported...

Continue reading →