Using Bootstrap-DateRangePicker As A Timepicker
Here's the jsfiddle: http://jsfiddle.net/d8uomdjv/It seems like the author is opposed to adding this sort of functionality: https://github.com/dangrossman/bootstrap-daterangepicker/issues/295
re.match vs re.search - Python
http://stackoverflow.com/a/180993/1364191- re.match - If zero or more characters at the beginning of string match the regular expression pattern.
- re.search - Scan through string looking for a location where the regular expression pattern produces a match
New Machine Setup For Flask Development On Ubuntu
Here are the commands I use when I bring up a new Ubuntu server for flask development:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get update && time sudo apt-get dist-upgrade | |
| sudo timedatectl set-timezone America/Chicago | |
| apt-get install git fail2ban htop nano | |
| mkdir -p .ssh | |
| nano .ssh/authorized_keys | |
| eval `ssh-agent -s` | |
| ssh-add ~/.ssh/id_rsa | |
| apt-get install python-setuptools | |
| easy_install pip | |
| pip install virtualenvwrapper | |
| sudo mkdir ~/virtualenvs | |
| sudo sh -c "echo 'WORKON_HOME=~/virtualenvs' >> /etc/environment" | |
| for line in $( cat /etc/environment ) ; do export $line ; done | |
| mkdir -p $WORKON_HOME | |
| sudo sh -c "echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc" | |
| bash | |
| mkvirtualenv default | |
| apt-get install python-dev |
MySQL Performance LXC Container vs Host
I have a linux virtual container (LXC) and the server hosting the container running the same version of MySQL with the same database.I tried running some select queries on both of the both the virtual container and host for benchmark purposes. My conclusion? MySQL read performance inside and outside the LXC container is the exactly the same.
WHMCS Cronjob Error
If you get the following error while you try to run the WHMCS cronjob from the command line:Site error: the file <b>/var/www/accounts/admin/cron.php</b> requires the ionCube PHP Loader ioncube_loader_lin_5.3.so to be installed by the website operator. If you are the website operator please use the <a href="http://www.ioncube.com/lw/">ionCube Loader Wizard</a> to assist with installation.
You need to add your the ioncube zend extension to the CLI php.ini too: /etc/php5/cli/php.ini
Sendmail/STARTTLS verify=FAIL
Oct 19 14:04:34 Billing sm-mta[17583]: STARTTLS=client, relay=aspmx.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-RC4-SHA, bits=128/128
If you see those errors in your mail.log and your emails are failing to send, you need to add your ssl cert from apache to the sendmail config in /etc/mail/sendmail.cf:
# CA directory
O CACertPath=/etc/apache2/ssl
# CA file
O CACertFile=/etc/apache2/ssl/example.ca-bundle
# Server Cert
O ServerCertFile=/etc/apache2/ssl/example.cert
# Server private key
O ServerKeyFile=/etc/apache2/ssl/example.key
Securing External LDAP Connections
https://help.ubuntu.com/community/SecuringOpenLDAPConnectionsI was getting the following error when I tried testing with openssl:
error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177
The solution? It turns out that /etc/default/slapd needs to be configured to use /etc/ldap/ldap.conf using the following:
SLAPD_OPTIONS="-f /etc/ldap/slapd.conf"
Adding Virtualhost In Apache For Port
Say we wanted to route the <your-domain>.com:8072/misc to /var/www/misc...Add the following to /etc/apache2/ports.conf:
NameVirtualHost *:8072
Listen 8072
Add a file that describes your site to /etc/apache2/sites-available with this:
<VirtualHost *:8072>
ServerName <your-domain>.com
DocumentRoot /var/www/misc/
</VirtualHost>
Run this command: sudo a2ensite misc
And restart apache: sudo service apache2 restart
Deploying Nginx + Gunicorn + Flask
Why use both Nginx and Gunicorn?: http://serverfault.com/a/220047Simple explanation: http://prakhar.me/articles/flask-on-nginx-and-gunicorn/
Nginx SSL configuration: https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins
The thing I spent the longest on was getting supervisor to work. Gunicorn kept giving me "gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>", because I was missing the "directory" parameter. I needed to tell supervisor which directory to start from.
[program:my_app]
command=/<path>/venv/prod/bin/gunicorn -w 8 main:app -b 127.0.0.1:8080
user=me
autostart=true
directory=/home/me/my_dir/
stdout_logfile=/home/me/my_dir/gunicorn_supervisor.log
stdout_logfile_maxbytes=20MB
redirect_stderr=true
You will need to create an upstart script to get supervisor to run when the system starts: http://serverfault.com/a/96500