Workflow publishing blog post with hugo

  • February 20, 2015

I’ve added some functions in my shell to make it even more convenient to write/edit/publish articles with hugo (just a self reminder)

so that now I have

  • new_blog_post name-of-your-blog-post
  • publish_blog
  • edit_last_blog_post

that can be run from anywhere in my terminal

export BLOG_ROOT=~/git/perso/blog
export BLOG_THEME=hyde
export GITHUB=git@github.com:allan-simon/blog.git

function new_blog_post {
    cd $BLOG_ROOT
    LAST_BLOG_POST=$(hugo new posts/$1.md | cut -d " " -f 1) ;
    export LAST_BLOG_POST ;
    $EDITOR $LAST_BLOG_POST
    cd -
}

function publish_blog {
    cd $BLOG_ROOT;
    hugo --theme="$BLOG_THEME" --buildDrafts && \
    git add -A &&  \
    git commit -m "Updating site" && \
    git push origin master && \
    git subtree push --prefix=public $GITHUB gh-pages --squash  && \
    echo "published"
    cd $BLOG_ROOT
}

function edit_last_blog_post {
    $EDITOR $LAST_BLOG_POST
}

Read More

Functionnal tests in symfony2 with authentication

  • February 20, 2015

Let’s say you have your symfony2 website, all setup correctly with its set of functionnal tests using phpunit, and now you start to have pages that only authenticated users can access to. My first solution was to create a client, make it load the login form, submit some valid credentials and then load the actual page to test. It was working fine as the client has a storage for cookie, it is acting like an actual browser in that case.

The problem was that the time to execute the test was much longer, which started to become a problem has the test suite was growing.

The first trick is to follow them method adviced by symfony, which is for the test environnement to enable the HTTP Basic Authentication method. For those who doesn’t know, the HTTP standard comme with a method to authentify a user-agent by directly sending the username/password in the HTTP header (which goes along the fact that HTTP is aimed to be stateless)

Read More

Solve composer github api limitation

  • February 10, 2015

Could not fetch X enter your GitHub credentials to go over the API rate limit

The problem is that composer is retrieving nearly all the packages from github using the anonymous access github API. In order to solve it you need to generate a token

  1. you need a github account (or ask a friend)
  2. go on your setting page here
  3. click on Generate new token

now two possibilities

Read More

Install docker on ubuntu 12.04

  • February 10, 2015

This article is a shameless summary from http://compositecode.com

the steps are:

  • Updating your kernel to 3.8+ (requires a reboot)
  • Add the docker repository
  • Installing the package
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo reboot
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker

And now you should be able to get docker working

Read More

postgresql display one column per line

  • February 10, 2015

Problem : displaying a table with a lot of columns

You always got that table with a dozens of columns of type text and for which the normal tabular output does not work nicely and you end up with something like

 articleid | plop | pouet | prout | tagada |  id   | newsid  | newstype |                                                          title                                                          | something | something | something | something | something | something | something | something |      something       |      something       | something | something | something | something |          something          |    something    |                                                                                                                                                                                                                                                                                                                 something                                                                                                                                                                                                                                                                                                                 |            something            
-----------+-------+-------+-------+-------+-------+---------+----------+-----------------------------------------------------------------------------------------------------------------------------+------------+-------------+-----------+------------+-----------------+---------+--------------+---------+---------------------+---------------------+---------------+-------------+-----------+------------+---------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------+------------+--------------------------------+--------------+----------------------+------------------------------------------------------------------------------------+--------------+-----------+----------+----------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------+-----------+-------+------------
   1000163 |     0 |     0 |     0 |     0 |   141 | 1000147 |       10 | blablabla                                                                                           |          3 |           4 |        22 |    1000163 |               0 | 1000163 |          184 |   10028 | 2014-06-30 23:36:00 | 2014-06-30 23:36:00 |             0 |           0 |         0 |          0 |                           |           |          

Read More

A new Blog this time on github and statically generated

  • February 9, 2015
It has been a long time since I last did a blog the biggest reason behind were: it’s hard to maintain a server and a blog platform most common web plateforms are blocked in China the other plateforms does not fit my geeky needs non-self hosted platform make it hard to have easy backup of your data So here we are, after reading comments on HackerNews I’ve found the project Hugo which permits you to create a static blog the advantages I see to it Read More