All posts by danielk

Monitor Varnish traffic with hits and misses

Just a small one-liner to monitor traffic going through varnish. Hits and misses are coloured to you can easily see what goes to your backend and what doesn’t. Bot traffic is also coloured 🙂

varnishncsa -F '%s %h %{Varnish:hitmiss}x %D %l %u %t "%r" %b "%{User-agent}i"' | GREP_COLOR='01;31' egrep --line-buffered --color=always 'miss|
 | GREP_COLOR='01;32' egrep --line-buffered --color=always 'hit|
 | GREP_COLOR='01;33' egrep --line-buffered --color=always '^.*css.*$|^.*\/img.*$|^.*font.*$|^.*js.*$|
 | GREP_COLOR='01;35' egrep --line-buffered --color=always '^.*bot.*$|

Couchbase php stub file

I have been working with Couchbase for a while and was constantly referring to the Couchbase SDK PHP Documentation for the usage of functions. There was no class definition available in my Zend Studio IDE for auto-completion. Which kinda annoyed me.

Since i have been using composer for all my libraries at tried looking on Packagist for a Couchbase stub file. Unfortunately i could not find one. Then i remembered seeing one in the PECL Couchbase package. I could of course put this into my project so that my IDE would pick it up for auto-completion, but that would not be very social of me. Of course ‘Sharing is Caring’.

I added a github repository, created a composer.json file and added it to packagist. To include it in your project just add the following line to your composer.json file require section.

"danielkraaij/couchbase-php-stub": "dev-master"

Then run composer update, refresh your project in your IDE and your good to go.

 

 

Subversion Progressbar in bash

For a project i am doing i needed to checkout a subversion repo from within an installer. This ofcourse is not that hard, but i wanted something extra.
I was searching for a way to show a progressbar when doing a svn checkout (svn co) and could not find a sollution for it. So i came up with the following sollution.

First, i needed to know how many files i was going to checkout of the subversion repository. To get this number i’m going to use the following bash statement.

n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)

Great, ‘$n’ now contains a number of files in my project, we can use that number to calculate the percentage. But to do that i needed to know how far the checkout is.

Subversion will output each file on a new line. We could pipe that into a while loop and keep track of the progress.

n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)
i=1
while read line filename
    do
    counter=$(( 100*(++i)/n))
    echo -e "($counter %)\n"
    echo -e "filename: $filename \n"
done < <(svn co svn://svn/project/trunk /var/www/project)

The script above prints a percentage for each line.

Now let’s put all this into a dialog.

dialog --backtitle "Subversion Installer" --title "SVN Checkout" --gauge "Getting total file count" 7 120 < <(
	n=$(svn info -R svn://svn/project/trunk | grep "URL: " | uniq | wc -l)
	i=1
	while read line filename
		do
		counter=$(( 100*(++i)/n))
		echo "XXX"
		echo "$counter"
		echo "filename: $filename"
		echo "XXX"

	done < <(svn co svn://svn/project/trunk /var/www/project)
)

if you run this you’ll get a nice process indicator. Yay!

 

Facebook Group for ‘Kraaij’

A while ago i created a facebook group for my lastname ‘Kraaij’. Since then the group gained 19 members. That may not be much, but then again, there are not many people with that exact last name.

There are however some interesting posts. like our family weapon for example.

https://www.facebook.com/photo.php?fbid=2266987443483&set=gm.261600023859495&type=1&theater

And this post revealed some nice and old images.

467262_10150751683547137_329061196_o

We also learned that overtime our last name changed from Kraai to Kraaij or other variations like Kraay.

Interested? just take a look on our Facebook Group page.

 

The following signatures couldn’t be verified because the public key is not available

When running a ubuntu or debian based distro, it is sometimes required to do same manual updating with the apt-get tool . I run the following command almost on a daily basis on my desktops and servers.

Continue reading The following signatures couldn’t be verified because the public key is not available

Hello world!

Finally, i created a blog just for myself and all things around me… This has been spinning around in my mind for a very long time. And today i felt the need to create one. The domain name was already in my possession for quite some time. Hopefully i’ll be posting some nice stuff here in the future 🙂