Wednesday, November 19, 2014

private docker registry push issue: Invalid registry endpoint

I ran into the problem during pushing an image to my private docker registry. It's the first time pushing after I upgrade my docker client to v1.3.1

2014/11/19 15:55:06 Error: Invalid registry endpoint https://docker.xxx.com/v1/: Get https://docker.xxx.com/v1/_ping: dial tcp 184.72.217.171:443: i/o timeout. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry docker.xxx.com` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/docker.xxx.com/ca.crt

Since I'm running docker via boot2docker, docker instance actually is managed by boot2docker. I have to add parameter --insecure-registry to somewhere in the boot2docker virtual machine.

Here's the official solution: (https://github.com/boot2docker/boot2docker#insecure-registry)

Insecure Registry
As of Docker version 1.3.1, if your registry doesn't support HTTPS, you must add it as an insecure registry.
$ boot2docker init
$ boot2docker up
$ boot2docker ssh
$ echo 'EXTRA_ARGS="--insecure-registry <YOUR INSECURE HOST>"' | sudo tee -a /var/lib/boot2docker/profile
$ sudo /etc/init.d/docker restart

Wednesday, November 5, 2014

USCIS case monitoring app

I created an USCIS case tracking application on Google App Engine recently.

http://case-monitoring.appspot.com/

For those who are waiting for their USCIS case decisions, whatever it's a visa case or an immigration case, the application can track it as well.

Due to the resource quota on Google App Engine, the tracking app refreshes your case status every 6 hours and each user is able to track up to 2 cases.
Once your case got an update, you will get an Email notification.

You will be asked to login with Google account, no private data will be stored except your email address which is used for notification purpose.

Wish all your USCIS cases get approved ASAP

Tuesday, April 8, 2014

patch for openssl heartbleed bug on Ubuntu

Install update


apt-get update
apt-get install openssl libssl1.0.0

Check libssl version

root@hydrausdev:~# dpkg -l|grep libssl
ii libssl-dev 1.0.1-4ubuntu5.12 SSL development libraries, header files and documentation
ii libssl-doc 1.0.1-4ubuntu5.11 SSL development documentation documentation
ii libssl1.0.0 1.0.1-4ubuntu5.12 SSL shared libraries

Restart Nginx/Apache



Verify

by online tool: http://filippo.io/Heartbleed/

Friday, March 28, 2014

Install MySQL library for python on MacOS

Both clang and gcc in latest xcode command line tool have some problem while compiling MySQL-python
An error say "unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]"

Here's the problematic gcc and clang version
ffmb13:~ fanfei$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

ffmb13:~ fanfei$ clang -v
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

To work around the issue, we can set environment variable ARCHFLAGS during the compiling.
brew install mysql
su
export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
pip install MySQL-python

Wednesday, January 8, 2014

form label missing in Django 1.6?

You may used the monkey patch to add attrs during the form rendering.

e.g. add attribute "class" for all form labels, as this article said.
http://ask.make-money-article.com/que/2028404
def add_control_label(f):
    def control_label_tag(self, contents=None, attrs=None):
        if attrs is None: attrs = {}
        attrs['class'] = 'control-label'
        return f(self, contents, attrs)
    return control_label_tag

BoundField.label_tag = add_control_label(BoundField.label_tag)
If you had used this "solution" in your application, you may find the field names(control labels) are missed in admin site since Django 1.6, a form without label.



This is because the function .label_tag you hooked had been changed! Now, it receives an additional parameter label_suffix

Django 1.5
https://github.com/django/django/blob/1.5.5/django/forms/forms.py#L498
def label_tag(self, contents=None, attrs=None):
Django 1.6
https://github.com/django/django/blob/1.6/django/forms/forms.py#L515
def label_tag(self, contents=None, attrs=None, label_suffix=None):
So, you have to either add label_suffix in control_label_tag or use variable arguments like following slice.
def add_control_label(f):
    def control_label_tag(self, contents=None, attrs=None, *args, **kwargs):
        if attrs is None: attrs = {}
        attrs['class'] = 'control-label'
        return f(self, contents, attrs, *args, **kwargs)
    return control_label_tag

BoundField.label_tag = add_control_label(BoundField.label_tag)