dracoblue.net

Run Jekyll as Upstart/Monit Service

When using jekyll to generate a static page, I wanted to have jekyll running as a service (by using upstart and monit).

Usually you launch jekyll with the --watch parameter and it will refresh the page continously.

Setup a upstart file called /etc/init/jekyll.conf.

script
    export LANG="en_US.UTF-8"
    exec start-stop-daemon --make-pid --start --pidfile /var/run/jekyll.pid --chdir /home/dracoblue/live/ --chuid dracoblue:dracoblue --exec /usr/bin/jekyll -- build --watch
end script

It's very important to have export LANG="en_US.UTF-8" in this definition, because otherwise jekyll uses US-ASCII and you can't get rid of messages like:

Liquid Exception: invalid byte sequence in US-ASCII in
Continue reading ...

In jekyll, monit, ubuntu, upstart by DracoBlue @ 03 Dec 2013 | 213 Words

bash-tip: avoiding subshells with HERE-documents

While I was working on toolsapi-shell client, I ran into a quite common bash problem.

#!/bin/bash
POS=0
echo "POS before: $POS"
ls | while read line
do
  # do handling for each line (skipped here)
    echo "current POS: $POS"
  let 'POS += 1'
done
echo "POS after: $POS"
# Result:
#  POS before: 0
#  current POS: 0
#  current POS: 1
#  current POS: 2
#  POS after: 0

This is not what one or another expects here.

Continue reading ...

In bash by DracoBlue @ 25 Aug 2013 | 325 Words

Installing php apd on php 5.3.10

Today I wanted to extend the phpdebugtoolbar to allow tracing for good old mysql_query commands. This can be possible by using the

rename_function-method, which is provided by the apd pecl extension. It's a pitty that this extension cannot be compiled for php >= 5.3 without any patch. So here the step by step guide to get it up and running on a php 5.3 or later. 1. Download apd-1.0.1.tar.gz from pecl.php.net. 2. Extract the files 3. Patch the code

diff --git a/php_apd.c b/php_apd.c
index 6707e02..8bfafb5 100644
--- a/php_apd.c
+++ b/php_apd.c
@@ -964,7 +964,7 @@ ZEND_DLEXPORT void onStatement(zend_op_array *op_array)
 int apd_zend_startup(zend_extension *extension)
 {
        TSRMLS_FETCH();
-       CG(extended_info) = 1;  /* XXX: this is ridiculous */
+       CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
        return zend_startup_module(&apd_module_entry);
 }
  1. Run

phpize to configure the extension. 5. Run make to build the extension 6. Run sudo make install to copy the .so to the necessary location 7. Add this line to your php.ini (the folder may be different on your system)

zend_extension=/opt/local/lib/php/extensions/no-debug-non-zts-20090626/apd.so

That's it. If you receive the error message, that apd.so is not a valid extension, you must use "zend_extension=" and not "extension=" to configure the extension properly! Call

$ php --version
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Advanced PHP Debugger (APD) v1.0.1, , by George Schlossnagle
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

and the Advanved PHP Debugger info appears.

In open source, php by DracoBlue @ 26 Apr 2012 | 258 Words

Install pandoc 1.9 on ubuntu lucid/oneric

Don't install pandoc with apt-get. Follow those instructions to get the latest version, You need haskell-platform. Don't install haskell with apt-get, too. Use this guide

how to install haskell on ubuntu. As soon as you are done, you can install pandoc with this:

$ cabal update
$ cabal install pandoc

Remember to do this NOT with sudo, because you want to have cabal locally available with the current user. But if it fails with:

Resolving dependencies...
cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however
syb-0.1.0.2 was excluded because json-0.5 requires syb >=0.3.3

you did accidently installed haskell-platform with apt-get. Do

$ sudo apt-get remove haskell-platform

and follow the link from the beginning of this post!

In ubuntu by DracoBlue @ 10 Mar 2012 | 135 Words

Assertions and No-Test-Framework in PHP

When I was writing the tests for

Craur, I wanted to try a new way (no phpunit this time) to write tests in php. Since php already has a assert($assertion) method, I imagined that it might be a good start to test without an extra test framework. A simple

assert(false)

raised a warning. Nice! So I made the following approach:

tests/
    my_test_file.php
    another_test.php

Whenever I want to launch the tests, I just go into the tests folder and launch php $file_name for all of them. If the exit code is different to 0 -> the test failed. It's a pitty, bit

assert($assertion) does not raise an exception or something like this. Great for other use cases, but in mine this was really an issue. So I wrote this small wrapper script bootstrap_for_test.php. It registers a new AssertionException class for all kind of errors and as ASSERT_CALLBACK! Now even a notice or a warning make the test fail. Great! Now a simple test looks like this:

<?php
include('./../bootstrap_for_test.php');
assert(2 == 3);

To have the tests run at once, I wrote a little

run_test.sh script. It runs every test and returns the script with an exit code different to 0, if one of the tests fails.

All integrated with Travis CI and Craur is tested!

In open source, php by DracoBlue @ 05 Mar 2012 | 240 Words

Page 10 - Page 11 - Page 12

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About