pyenv Quick Start (Utunbu 14.04)

installation Requirements $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm install pyenv $ cd ~ $ git clone git://github.com/yyuu/pyenv.git .pyenv $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(pyenv init -)"' >> ~/.bashrc install pyenv-virtualenv $ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc $ exec $SHELL Common Usage (Command Reference) List all available versions $ pyenv version -l Install python2....

December 10, 2014 · 2 min · oopsmonk

Web dev example : JSON & jQuery Mobile & Bottle

Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. jQuery Mobile base on jQuery for mobile device. jQuery vs. jQuery Mobile vs. jQuery UI Install bottle: $ sudo apt-get install python-setuptools $ easy_install bottle Demo server deployment file structure: BottlejQuery ├── bottleJQuery.py └── index.html run command: $ ./bottleJQuery.py connect to server: http://localhost:8080/bottle Building simple web server use bottle bottleJQuery.py #!/usr/bin/env python from bottle import route, static_file, debug, run, get, redirect from bottle import post, request import os, inspect, json #enable bottle debug debug(True) # WebApp route path routePath = '/bottle' # get directory of WebApp (bottleJQuery....

August 7, 2013 · 4 min · oopsmonk

Sending HTML Mail Using SMTP With Authorization

Here is a text/plain MIME type parts in official exmaple code. I remove it from my sample code, because it’s not show up in mail at Office Outlook 2010. #!/usr/bin/env python """ File name: sendMail.py Python send HTML mail using SMTP with authorization Usage : ./sendMail.py to@gmail.com Subtitle [ FilePath | txt ] """ import smtplib import sys,traceback from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from time import gmtime, strftime #log file location log_path = "....

July 31, 2013 · 2 min · oopsmonk

Nginx Error - 413 Request Entity Too Large

nginx version: nginx/1.1.19, OS: Ubuntu12.04 Default nginx accepted body size limitation is 1MB. You can add client_max_body_size in nginx.conf. This parameter can put in http, server and location sections of configutation file. Enlarge body size to 10MB client_max_body_size 10M Or just disable it client_max_body_size 0 For example enlarge body size to 10MB Add to http section: $ sudo vi /etc/nginx/nginx.conf http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 10M; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime....

June 5, 2013 · 1 min · oopsmonk

Web Micro Framework Battle

WSGI Micro Framworks 這陣子一直在找適合的Micro Framwork玩第一次的Web Application. 最後選擇用Bottle, 原因是: Single file module, no dependencies with other library. Document 但是好不好用又是另一回事, 用了就知道..XD 以下是由WSGI.org列出的Micro Framwork: bobo Bobo is a light-weight framework. Its goal is to be easy to use and remember. Bottle Bottle is a fast and simple micro-framework for small web-applications. It offers request dispatching (Routes) with url parameter support, Templates, key/value Databases, a build-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines....

May 27, 2013 · 1 min · oopsmonk