Discourse with Docker on port 80

Discourse can cause you trouble if you have it running(listening) on a non-standard port inside the Docker instance. (the feed, google auth return url have the port and host info in them) (assuming you would like to serve requests from a standard http(s) port).

To make it work smoothly, I had to make it listen on standard port (80 in my case).
This is what I ended up doing:

Nginx(hostip:80) -> Nginx(dockerinsideip:80)

This method also extends to having multiple docker instance for different sites.
This is my nginx config on the host:

server {
    #where discourse sits
    server_name forum.mydomain.com;
    location / {
        #this is also important for discourse to work as expected
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        #my docker instances internal ip

And, I removed http port mappings on my app.yml file.

missing scheme in email body url

Some mail service providers (Yahoo Mail exhibits this at the moment), do not like links that do not have a scheme(http/https for instance) and will make the link non-clickable by removing the href. The fix is simple:

<!-- link is not clickable -->
<a href="www.google.com">Google</a>
<!-- link is clickable -->
<a href="https://www.google.com">Google</a>

how to not run a cron job between certain datetimes

Say, I have a cron job entry and do want the job to run between 2013-02-01 9PM (Feb 1st 2013) and 2013-02-02 11AM (Feb 2nd 2013), this is one possible solution (in crontab).

* * * * * [ $(/bin/date "+\%Y\%m\%d\%H") -lt 2013020109 -o $(/bin/date "+\%Y\%m\%d\%H") -gt 2013020211 ] && /PATHTOMYSCRIPT/myscript

rsync only certain files

Create a file on on the origin server and use the –files-from option

cd /
rsync -anvi --files-from=/tmp/only_these_files . to-server:/
cat /tmp/only_these_files

WordPress + Nginx + Permalinks Rewrite rules

The following works for me:

  location /blog/ {
          index  index.php;
          # WordPress pretty URLs: (as per dominiek.com)
          if (-f $request_filename) {
          if (-d $request_filename) {
          rewrite ^/blog/(.+)$ /blog/index.php?q=$1 last;
          # Enable nice permalinks for WordPress: (as per Yawn.it)
          error_page  404  = /blog/index.php?q=$uri;

I have my blog here: http://www.trk7.com/blog/
and my permalink structure is: /%postname%/

Bella donna

Bella donna won’t be tamed

Belluci, however, is unconcerned about what her children might think of her movies. ”If you are scared about what people think or what you represent or what your image can be, then you are not free any more in your choices. That can be dangerous for your art. I think it is important to feel free in your passion. I am a woman, I am a mother but when you are an actor, you have to still be wild.”

Monica Bellucci is truly the work of God (or my imagination ;)). When she says something like that, I cannot but only love her more. Her roles in various films backs up her words. I would have loved to hear that when she said that. Then, I would have known if it were scripted or did she think deeply before coming up with those words – any pauses between the words and so on.

Monica doesn’t strike me to be a crazy person – married for 11 years and with two kids – my guess is that she truly believes in what she says.

At 47, all I can say is: Go bella!

Backgrounded PHP jobs in ‘STOPPED’ state

This could be specific to the PHP package from Ubuntu. Please consider the following a disclaimer.

$ php -v
PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May  2 2011 23:00:17) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
$ cat /etc/lsb-release 

I have a file with the following contents:

$ cat stdin.php
echo microtime(), "n";

and I was doing something like this (backgrounds the script. I was using a slightly modified version to make concurrent SOAP requests)

$ for i in `seq 1 2`; do echo $i; sleep 2s; php /tmp/stdin.php &gt;&gt; /tmp/k7.out & done
$ jobs
[1]-  Stopped                 php /tmp/stdin.php &gt;&gt; /tmp/k7.out
[2]+  Stopped                 php /tmp/stdin.php &gt;&gt; /tmp/k7.out

There are a few threads on the Internet relating to the issue and there are a few solutions.
First let us kill the ‘STOPPED’ jobs

$ kill %1
$ kill %2
[1]   Terminated              php /tmp/stdin.php &gt;&gt; /tmp/k7.out
$ jobs
[2]+  Terminated              php /tmp/stdin.php &gt;&gt; /tmp/k7.out

One of the solutions that worked for me was by supplying something to STDIN (perhaps STDIN was blocking, but then again, stream_set_blocking (STDIN, 0) wasn’t of much help).

$ for i in `seq 1 2`; do echo $i; sleep 2s; php /tmp/stdin.php &gt;&gt; /tmp/k7.out &lt; /dev/null & done

and you could simulate arguments

$ for i in `seq 1 2`; do echo $i; sleep 2s; echo arg1 arg2 | php /tmp/stdin.php &gt;&gt; /tmp/k7.out & done
$ tail -f k7.out
0.82262900 1316606606
array(2) {
  string(4) "arg1"
  string(4) "arg2"
0.83546500 1316606608
array(2) {
  string(4) "arg1"
  string(4) "arg2"