PHPでJIS以外の文字を文字化けせずに日本語メールを送る方法
2014年2月21日金曜日
2014年2月20日木曜日
PHPでEメールアドレスのバリデーション
正規表現 PHPのpreg_match色々
ここのコメントより
Eメールアドレスのバリデーション
PHPではfilter_var()関数でメールアドレスのチェックができますので、基本的にこの関数か、この関数をベースにしたライブラリを使うのが良いです。
2014年2月19日水曜日
2014年2月11日火曜日
rails の実行モード
■ コード内でモードを取得
Rails - How do I check developer mode or production mode in code
http://stackoverflow.com/questions/6476832/rails-how-do-i-check-developer-mode-or-production-mode-in-code
Rails.env == "production"
Rails.env == "development"
Rails.env.production?
Rails.env.development?
■ 実行時にオプションで指定する
rake db:migrate RAILS_ENV=test
rails s -e production
2014年2月4日火曜日
2014年1月27日月曜日
mysql5.6のrpmリポジトリ (fedora20)
rpm でfedora20 にmysql をインストール。
Download MySQL Yum Repository
redhat(centos), fedora18, 19, 20 用が用意されている。
rpm -ivh http://dev.mysql.com/get/mysql-community-release-fc20-5.noarch.rpm
yum install mysql-community-server mysql-community-devel mysql-community-client mysql-community-common mysql-community-libs
■ python3用ドライバー
Python 3 の MySQL ドライバ事情
ということなので、
MySQL-for-Python-3 を利用してみる。
pip3 install git+https://github.com/davispuh/MySQL-for-Python-3.git
(warningがいくつも出るね。。。)
Download MySQL Yum Repository
redhat(centos), fedora18, 19, 20 用が用意されている。
rpm -ivh http://dev.mysql.com/get/mysql-community-release-fc20-5.noarch.rpm
yum install mysql-community-server mysql-community-devel mysql-community-client mysql-community-common mysql-community-libs
■ python3用ドライバー
Python 3 の MySQL ドライバ事情
ということなので、
MySQL-for-Python-3 を利用してみる。
pip3 install git+https://github.com/davispuh/MySQL-for-Python-3.git
(warningがいくつも出るね。。。)
python3.4 インストール
python3 の準備。
(fedora20, python3.4)
readline-devel ncurses-devel bzip2-devel openssl-devel zlib-devel xz-devel sqlite-devel
などはyumで入れておく。
scipy を入れる場合は以下も入れておく。
atlas-devel lapack-devel blas-devel
./configure --enable-shared
make
make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig を実行。(上の追加を有効にする)
デフォルトでpipがインストールされるようになったみたい。
/usr/local/bin/pip3
pip3 install lxml (libxml2-devel libxslt-devel が必要)
pip3 install feedparser
pip3 install django
pip3 install uwsgi
pip3 install git+https://github.com/mitsuhiko/werkzeug.git
(リリース前だがver0.10でpython3に対応)
ipython, numpy, scipy, pandas, sklearn も
■ uwsgi の確認
--------------------------------------------------
#coding: utf-8
def application(env, response):
response('200 OK', [('Content-Type', 'text/html')])
html = '''<!DOCTYPE html><html>
<head><meta charset="utf-8"></head>
<body>こんにちは!uWsgi</body></html>'''
return [html.encode('utf-8')]
--------------------------------------------------
■ 残り作業
(1) MySQL-Python
MySQLからmariadb に変わってしまった。。。
(2) zenhan
今まで使ってたけど、python3には未対応?
pip3 install zenhan
---------------------------------------------------------
Downloading/unpacking zenhan
Could not find any downloads that satisfy the requirement zenhan
Some externally hosted files were ignored (use --allow-external zenhan to allow).
---------------------------------------------------------
(fedora20, python3.4)
readline-devel ncurses-devel bzip2-devel openssl-devel zlib-devel xz-devel sqlite-devel
などはyumで入れておく。
scipy を入れる場合は以下も入れておく。
atlas-devel lapack-devel blas-devel
./configure --enable-shared
make
make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig を実行。(上の追加を有効にする)
デフォルトでpipがインストールされるようになったみたい。
/usr/local/bin/pip3
pip3 install lxml (libxml2-devel libxslt-devel が必要)
pip3 install feedparser
pip3 install django
pip3 install uwsgi
pip3 install git+https://github.com/mitsuhiko/werkzeug.git
(リリース前だがver0.10でpython3に対応)
ipython, numpy, scipy, pandas, sklearn も
■ uwsgi の確認
--------------------------------------------------
#coding: utf-8
def application(env, response):
response('200 OK', [('Content-Type', 'text/html')])
html = '''<!DOCTYPE html><html>
<head><meta charset="utf-8"></head>
<body>こんにちは!uWsgi</body></html>'''
return [html.encode('utf-8')]
--------------------------------------------------
uwsgi --http-socket :8000 --wsgi-file wsgi.py
(1) MySQL-Python
MySQLからmariadb に変わってしまった。。。
(2) zenhan
今まで使ってたけど、python3には未対応?
pip3 install zenhan
---------------------------------------------------------
Downloading/unpacking zenhan
Could not find any downloads that satisfy the requirement zenhan
Some externally hosted files were ignored (use --allow-external zenhan to allow).
---------------------------------------------------------
これも確認が必要。
登録:
投稿 (Atom)