# apt-get install oss-compat
# apt-get install alsa-oss
# modprobe snd_pcm_oss
2014年3月30日 星期日
2014年3月28日 星期五
Execute Python code in Jinja Template
controller.py
def clever_function(): return u'HELLO' app.jinja_env.globals.update(clever_function=clever_function)
view.py
{{ clever_function() }}
References :
Call a python function from jinja2 - Stack Overflow
2014年3月25日 星期二
Deploy a project using Git push
Server :
Client :
References :
php - Deploy a project using Git push - Stack Overflow
$ git init
$ git config receive.denyCurrentBranch ignore
$ mv post-update .git/hooks
Client :
$ git remote add prod ssh://git@deploy-server:22/var/www/myproject
References :
php - Deploy a project using Git push - Stack Overflow
Automated git deployments from Bitbucket
Administration -> Hooks -> POST -> Add hook
References :
Pixel Acres » Blog Archive » Automated git deployments from Bitbucket
References :
Pixel Acres » Blog Archive » Automated git deployments from Bitbucket
mod_wsgi automatic reload on source code change
Adding the WSGIScriptReloading
directive meant that any time I made changes to my application files, I could simply $ touch flaskTest.wsgi
and the app would restart with changes applied.
# vi /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80> ServerName flasktest.subdimension.co.uk WSGIDaemonProcess flaskTest user=flask group=www-data threads=5 home=/<redacted>/flaskTest WSGIScriptAlias / /<redacted>/flaskTest/flaskTest.wsgi <Directory /<redacted>/flaskTest> WSGIProcessGroup flaskTest WSGIApplicationGroup %{GLOBAL} WSGIScriptReloading On Order deny,allow Allow from all </Directory> </VirtualHost>
$ touch
/<redacted>/flaskTest/flaskTest.wsgi
References :
Deploying Flask to Apache » subdimension
2014年3月24日 星期一
linux 監視檔案更改
# apt-get install inotify-tools # inotifywait -rme modify,attrib,move,close_write,create,delete,delete_self /
* 如果一次監視太多可能會出錯,將 / 改爲 /home 或更小範圍的其他位址
2014年3月20日 星期四
Linux run program using proxy
# apt-get install proxychains
# vi /etc/proxychains.conf
or
$ vi /home/user/.proxychains/proxychains.conf
socks5 127.0.0.1 1234
$ proxychains curl icanhazip.com
可搭配 ssh tunnel
$ ssh -D 8080 user@myhost.com
References :
How to run apt-get (wget, whois, etc.) via SOCKS Proxy using Proxychains | SwitchRoot.com
# vi /etc/proxychains.conf
or
$ vi /home/user/.proxychains/proxychains.conf
socks5 127.0.0.1 1234
$ proxychains curl icanhazip.com
可搭配 ssh tunnel
$ ssh -D 8080 user@myhost.com
References :
How to run apt-get (wget, whois, etc.) via SOCKS Proxy using Proxychains | SwitchRoot.com
2014年3月18日 星期二
SQLAlchemy 沒有主鍵 錯誤
sqlalchemy.exc.ArgumentError: Mapper Mapper|FooTable|foo_table could not
assemble any primary key columns for mapped table 'foo_table'
SQLAlchemy 不允許沒有定義主鍵,若是複合主鍵,則需要在多個欄位加上 primary_key=True。
References :
MooGoo's Blog: [SQLAlchemy] 不用primary key的table
SQLAlchemy0.6.5文檔-----用元數據定義數據庫_StackDoc
SQLAlchemy 不允許沒有定義主鍵,若是複合主鍵,則需要在多個欄位加上 primary_key=True。
References :
MooGoo's Blog: [SQLAlchemy] 不用primary key的table
SQLAlchemy0.6.5文檔-----用元數據定義數據庫_StackDoc
2014年3月17日 星期一
資料外洩防護 DLP 軟體
Windows 查詢資料是否被復制:
USB 型號記錄 (Registry)
第三方軟體:
檔案操作記錄:
Windows Explorer Tracker存取限制:
資料夾護衛 Folder Guard
Flask Application and Request context
Application context
References :
In Flask we Trust
Request context
- flask._app_ctx_stack
- flask.current_app
- flask._request_ctx_stack
- flask.g
- flask.request
- flask.session
References :
In Flask we Trust
2014年3月12日 星期三
Jinja Template include file
Include Files
Requiring Files
{% require %} works like {% include %} but doesn't return the output.
References :
Reuse Parts | Jinja Documentation
Hello World
{% include "parts/introtext" %}
Requiring Files
{% require %} works like {% include %} but doesn't return the output.
{% require "myblocks" %} {% require "parts/introtext" as introtext %}Hello World
{% call "divbox", "intro", introtext %}
References :
Reuse Parts | Jinja Documentation
CentOS pip install MySQL-python
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-HGn8ZB-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/MySQL-python
Storing debug log for failure in /root/.pip/pip.log
Storing debug log for failure in /root/.pip/pip.log
# yum install gcc python-devel mysql-devel
2014年3月11日 星期二
Flask session expiration
from datetime import timedelta
app.config['SECRET_KEY'] = 'random'
app.permanent_session_lifetime = timedelta(seconds=60*60*10) # session expire time
2014年3月10日 星期一
2014年3月9日 星期日
datetime format
RFC3339
2008-09-08T22:47:31-07:00
RFC2445 (iCalendar)
20121211155343
ISO8601
2008-12-19T16:39:57.67Z
ATOM = "Y-m-d\TH:i:sP";
COOKIE = "l, d-M-y H:i:s T";
ISO8601 = "Y-m-d\TH:i:sO";
RFC822 = "D, d M y H:i:s O";
RFC850 = "l, d-M-y H:i:s T";
RFC1036 = "D, d M y H:i:s O";
RFC1123 = "D, d M Y H:i:s O";
RFC2822 = "D, d M Y H:i:s O";
RFC3339 = "Y-m-d\TH:i:sP";
RSS = "D, d M Y H:i:s O";
jQuery prop('checked') vs. is(':checked') 速度比較
$el.prop('checked');
$el.is(':checked');
$el.attr("checked");
$el[0].checked;
References :
2014年3月4日 星期二
2014年3月3日 星期一
2014年3月2日 星期日
nvidia brightness control on ubuntu 調整螢幕亮度
# vi /etc/X11/xorg.confSection "Device" Identifier "Card2" Driver "nvidia" BusID "PCI:1:0:0" Option "RegistryDwords" "EnableBrightnessControl=1" EndSection
if no /etc/X11/xorg.conf
# X :1 -configure# mv xorg.conf.new /etc/X11
boot with argument acpi_backlight=vendor
亮度調整
$ xbacklight -dec 20
$ xbacklight -inc 20
References :
NVIDIA - ArchWiki
訂閱:
文章 (Atom)