mac 隠しファイル表示・非表示
隠しファイルを表示する
ターミナルで下記コマンドを実行する
defaults write com.apple.finder AppleShowAllFiles true killall Finder
隠しファイルを非表示する
ターミナルで下記コマンドを実行する
defaults write com.apple.finder AppleShowAllFiles false killall Finder
python PrototypeStore
-- coding: utf-8 --
class PrototypeStore(dict): """ x.prototype.XXXの値を保存するためのクラス """ def setattr(self, name, value): self[name] = value
def __getattr__(self, name):
return self[name]
class PrototypeMeta(type): """ Prototypeメタクラス(クラス生成時に呼ばれる) """ def new(metacls, cls_name, bases, attrs): cls = type.new(metacls, cls_name, bases, attrs) cls.prototype = PrototypeStore() return cls
class Prototype(object): metaclass = PrototypeMeta
def __getattr__(self, name):
if name == 'prototype':
getattr(self.__class__, name)
else:
try:
getattr(object, name)
except AttributeError:
return self.__class__.prototype[name]
class TestClass(Prototype): def init(self): pass
first = TestClass() # オブジェクトを作る first.prototype.x = 7 # 'x'をprototypeに割り当てる second = TestClass() # firstと同じTextClassからインスタンスを作る print second.x # first.xと同じオブジェクトを指しているので7になる first.x = 9 # first(インスタンス)の'x'アトリビュートに代入 print first.x # これは7でなく9を返す del first.x # インスタンスのアトリビュートを消去 print first.x # prototype.xの返す7になるはず
Expressのインストール
expressのインストール
$ npm install -g express
expressのテンプレート作成
$ express -t ejs ExpressSample
ここでExpressのサンプルプログラムが作成されるが、実行に必要なモジュールがインストールされていないので以下のコマンドでインストールする。
$ cd ExpressSample && npm install
サンプルプログラムの実行
以上でプログラムが実行できるようになったので実行してみる!
$ node app.js
ブラウザを開き http://localhost:3000/
centos6.3にvirtualenvのインストール
[root@devcacom ~]# sudo easy_install virtualenv Searching for virtualenv Reading http://pypi.python.org/simple/virtualenv/ Best match: virtualenv 1.11.6 Downloading https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.6.tar.gz#md5=f61cdd983d2c4e6aeabb70b1060d6f49 Processing virtualenv-1.11.6.tar.gz Running virtualenv-1.11.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-N3mAZl/virtualenv-1.11.6/egg-dist-tmp-czcAiE warning: no previously-included files matching '*' found under directory 'docs/_templates' warning: no previously-included files matching '*' found under directory 'docs/_build' Adding virtualenv 1.11.6 to easy-install.pth file Installing virtualenv script to /usr/bin Installing virtualenv-2.6 script to /usr/bin Installed /usr/lib/python2.6/site-packages/virtualenv-1.11.6-py2.6.egg Processing dependencies for virtualenv Finished processing dependencies for virtualenv [root@devcacom ~]# virtualenv --help Usage: virtualenv [OPTIONS] DEST_DIR Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity. -q, --quiet Decrease verbosity. -p PYTHON_EXE, --python=PYTHON_EXE The Python interpreter to use, e.g., --python=python2.5 will use the python2.5 interpreter to create the new environment. The default is the interpreter that virtualenv was installed with (/usr/bin/python) --clear Clear out the non-root install and start from scratch. --no-site-packages DEPRECATED. Retained only for backward compatibility. Not having access to global site-packages is now the default behavior. --system-site-packages Give the virtual environment access to the global site-packages. --always-copy Always copy files rather than symlinking. --unzip-setuptools Unzip Setuptools when installing it. --relocatable Make an EXISTING virtualenv environment relocatable. This fixes up scripts and makes all .pth files relative. --no-setuptools Do not install setuptools (or pip) in the new virtualenv. --no-pip Do not install pip in the new virtualenv. --extra-search-dir=DIR Directory to look for setuptools/pip distributions in. This option can be used multiple times. --never-download DEPRECATED. Retained only for backward compatibility. This option has no effect. Virtualenv never downloads pip or setuptools. --prompt=PROMPT Provides an alternative prompt prefix for this environment. --setuptools DEPRECATED. Retained only for backward compatibility. This option has no effect. --distribute DEPRECATED. Retained only for backward compatibility. This option has no effect. [root@devcacom ~]# sudo pip install virtualenvwrapper sudo: pip: command not found [root@devcacom ~]# yum install pip Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors epel/metalink | 6.7 kB 00:00 * base: www.ftp.ne.jp * epel: mirror.premi.st * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Zend | 951 B 00:00 Zend_noarch | 951 B 00:00 base | 3.7 kB 00:00 epel | 4.4 kB 00:00 epel/primary_db | 5.2 MB 00:53 extras | 3.3 kB 00:00 extras/primary_db | 19 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 4.5 MB 00:12 Setting up Install Process No package pip available. Error: Nothing to do [root@devcacom ~]# yum install python python-devel --enablerepo=epel Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * epel: mirror.premi.st * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package python.i686 0:2.6.6-29.el6_2.2 will be updated --> Processing Dependency: python = 2.6.6-29.el6_2.2 for package: python-libs-2.6.6-29.el6_2.2.i686 ---> Package python.i686 0:2.6.6-52.el6 will be an update ---> Package python-devel.i686 0:2.6.6-52.el6 will be installed --> Running transaction check ---> Package python-libs.i686 0:2.6.6-29.el6_2.2 will be updated ---> Package python-libs.i686 0:2.6.6-52.el6 will be an update --> Processing Dependency: libz.so.1(ZLIB_1.2.0) for package: python-libs-2.6.6-52.el6.i686 --> Processing Dependency: libssl.so.10(libssl.so.10) for package: python-libs-2.6.6-52.el6.i686 --> Processing Dependency: libcrypto.so.10(libcrypto.so.10) for package: python-libs-2.6.6-52.el6.i686 --> Running transaction check ---> Package openssl.i686 0:1.0.0-25.el6_3.1 will be updated --> Processing Dependency: openssl = 1.0.0-25.el6_3.1 for package: openssl-devel-1.0.0-25.el6_3.1.i686 ---> Package openssl.i686 0:1.0.1e-16.el6_5.15 will be an update ---> Package zlib.i686 0:1.2.3-27.el6 will be updated --> Processing Dependency: zlib = 1.2.3-27.el6 for package: zlib-devel-1.2.3-27.el6.i686 ---> Package zlib.i686 0:1.2.3-29.el6 will be an update --> Running transaction check ---> Package openssl-devel.i686 0:1.0.0-25.el6_3.1 will be updated ---> Package openssl-devel.i686 0:1.0.1e-16.el6_5.15 will be an update ---> Package zlib-devel.i686 0:1.2.3-27.el6 will be updated ---> Package zlib-devel.i686 0:1.2.3-29.el6 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================== Installing: python-devel i686 2.6.6-52.el6 updates 171 k Updating: python i686 2.6.6-52.el6 updates 74 k Updating for dependencies: openssl i686 1.0.1e-16.el6_5.15 updates 1.5 M openssl-devel i686 1.0.1e-16.el6_5.15 updates 1.2 M python-libs i686 2.6.6-52.el6 updates 5.3 M zlib i686 1.2.3-29.el6 base 73 k zlib-devel i686 1.2.3-29.el6 base 44 k Transaction Summary ============================================================================================================================================== Install 1 Package(s) Upgrade 6 Package(s) Total download size: 8.3 M Is this ok [y/N]: y Downloading Packages: (1/7): openssl-1.0.1e-16.el6_5.15.i686.rpm | 1.5 MB 00:34 (2/7): openssl-devel-1.0.1e-16.el6_5.15.i686.rpm | 1.2 MB 00:05 (3/7): python-2.6.6-52.el6.i686.rpm | 74 kB 00:01 (4/7): python-devel-2.6.6-52.el6.i686.rpm | 171 kB 00:02 (5/7): python-libs-2.6.6-52.el6.i686.rpm | 5.3 MB 01:55 (6/7): zlib-1.2.3-29.el6.i686.rpm | 73 kB 00:00 (7/7): zlib-devel-1.2.3-29.el6.i686.rpm | 44 kB 00:00 ---------------------------------------------------------------------------------------------------------------------------------------------- Total 52 kB/s | 8.3 MB 02:42 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : zlib-1.2.3-29.el6.i686 1/13 Updating : zlib-devel-1.2.3-29.el6.i686 2/13 Updating : openssl-1.0.1e-16.el6_5.15.i686 3/13 Updating : openssl-devel-1.0.1e-16.el6_5.15.i686 4/13 Updating : python-2.6.6-52.el6.i686 5/13 Updating : python-libs-2.6.6-52.el6.i686 6/13 Installing : python-devel-2.6.6-52.el6.i686 7/13 Cleanup : openssl-devel-1.0.0-25.el6_3.1.i686 8/13 Cleanup : zlib-devel-1.2.3-27.el6.i686 9/13 Cleanup : python-2.6.6-29.el6_2.2.i686 10/13 Cleanup : python-libs-2.6.6-29.el6_2.2.i686 11/13 Cleanup : openssl-1.0.0-25.el6_3.1.i686 12/13 Cleanup : zlib-1.2.3-27.el6.i686 13/13 Verifying : python-libs-2.6.6-52.el6.i686 1/13 Verifying : zlib-1.2.3-29.el6.i686 2/13 Verifying : python-devel-2.6.6-52.el6.i686 3/13 Verifying : python-2.6.6-52.el6.i686 4/13 Verifying : openssl-devel-1.0.1e-16.el6_5.15.i686 5/13 Verifying : openssl-1.0.1e-16.el6_5.15.i686 6/13 Verifying : zlib-devel-1.2.3-29.el6.i686 7/13 Verifying : openssl-devel-1.0.0-25.el6_3.1.i686 8/13 Verifying : zlib-devel-1.2.3-27.el6.i686 9/13 Verifying : python-libs-2.6.6-29.el6_2.2.i686 10/13 Verifying : python-2.6.6-29.el6_2.2.i686 11/13 Verifying : openssl-1.0.0-25.el6_3.1.i686 12/13 Verifying : zlib-1.2.3-27.el6.i686 13/13 Installed: python-devel.i686 0:2.6.6-52.el6 Updated: python.i686 0:2.6.6-52.el6 Dependency Updated: openssl.i686 0:1.0.1e-16.el6_5.15 openssl-devel.i686 0:1.0.1e-16.el6_5.15 python-libs.i686 0:2.6.6-52.el6 zlib.i686 0:1.2.3-29.el6 zlib-devel.i686 0:1.2.3-29.el6 Complete! [root@devcacom ~]# yum info python-setuptools Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * epel: mirror.premi.st * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Installed Packages Name : python-setuptools Arch : noarch Version : 0.6.10 Release : 3.el6 Size : 1.5 M Repo : installed From repo : anaconda-CentOS-201207051201.i386 Summary : Easily build and distribute Python packages URL : http://pypi.python.org/pypi/distribute License : Python or ZPLv2.0 Description : Setuptools is a collection of enhancements to the Python distutils that allow : you to more easily build and distribute Python packages, especially ones that : have dependencies on other packages. : : This package contains the runtime components of setuptools, necessary to : execute the software that requires pkg_resources.py. [root@devcacom ~]# yum -y install python-setuptools Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * epel: mirror.premi.st * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Setting up Install Process Package python-setuptools-0.6.10-3.el6.noarch already installed and latest version Nothing to do [root@devcacom ~]# easy_install pip Searching for pip Reading http://pypi.python.org/simple/pip/ Best match: pip 1.5.6 Downloading https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e Processing pip-1.5.6.tar.gz Running pip-1.5.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Lq3duO/pip-1.5.6/egg-dist-tmp-cLVd4J warning: no files found matching 'pip/cacert.pem' warning: no files found matching '*.html' under directory 'docs' warning: no previously-included files matching '*.rst' found under directory 'docs/_build' no previously-included directories found matching 'docs/_build/_sources' Adding pip 1.5.6 to easy-install.pth file Installing pip script to /usr/bin Installing pip2.6 script to /usr/bin Installing pip2 script to /usr/bin Installed /usr/lib/python2.6/site-packages/pip-1.5.6-py2.6.egg Processing dependencies for pip Finished processing dependencies for pip [root@devcacom ~]# sudo pip install virtualenvwrapper Downloading/unpacking virtualenvwrapper Downloading virtualenvwrapper-4.3.1.tar.gz (86kB): 86kB downloaded Running setup.py (path:/tmp/pip_build_root/virtualenvwrapper/setup.py) egg_info for package virtualenvwrapper Installed /tmp/pip_build_root/virtualenvwrapper/pbr-0.10.0-py2.6.egg [pbr] Processing SOURCES.txt warning: LocalManifestMaker: standard file '-c' not found warning: no previously-included files found matching '.gitignore' warning: no previously-included files found matching '.gitreview' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no files found matching '*.html' under directory 'docs' warning: no files found matching '*.css' under directory 'docs' warning: no files found matching '*.js' under directory 'docs' warning: no files found matching '*.png' under directory 'docs' Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/lib/python2.6/site-packages/virtualenv-1.11.6-py2.6.egg (from virtualenvwrapper) Downloading/unpacking virtualenv-clone (from virtualenvwrapper) Downloading virtualenv-clone-0.2.5.tar.gz Running setup.py (path:/tmp/pip_build_root/virtualenv-clone/setup.py) egg_info for package virtualenv-clone Downloading/unpacking stevedore (from virtualenvwrapper) Downloading stevedore-0.15.tar.gz (348kB): 348kB downloaded Running setup.py (path:/tmp/pip_build_root/stevedore/setup.py) egg_info for package stevedore Installed /tmp/pip_build_root/stevedore/pbr-0.10.0-py2.6.egg [pbr] Processing SOURCES.txt warning: LocalManifestMaker: standard file '-c' not found warning: no previously-included files found matching '.gitignore' warning: no previously-included files found matching '.gitreview' warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no files found matching '*.html' under directory 'docs' warning: no files found matching '*.css' under directory 'docs' warning: no files found matching '*.js' under directory 'docs' warning: no files found matching '*.png' under directory 'docs' warning: no files found matching '*.py' under directory 'tests' Downloading/unpacking argparse (from stevedore->virtualenvwrapper) Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded Running setup.py (path:/tmp/pip_build_root/argparse/setup.py) egg_info for package argparse warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.orig' found anywhere in distribution warning: no previously-included files matching '*.rej' found anywhere in distribution no previously-included directories found matching 'doc/_build' no previously-included directories found matching 'env24' no previously-included directories found matching 'env25' no previously-included directories found matching 'env26' no previously-included directories found matching 'env27' Installing collected packages: virtualenvwrapper, virtualenv-clone, stevedore, argparse Running setup.py install for virtualenvwrapper [pbr] Reusing existing SOURCES.txt changing mode of build/scripts-2.6/virtualenvwrapper.sh from 644 to 755 changing mode of build/scripts-2.6/virtualenvwrapper_lazy.sh from 644 to 755 Skipping installation of /usr/lib/python2.6/site-packages/virtualenvwrapper/__init__.py (namespace package) Installing /usr/lib/python2.6/site-packages/virtualenvwrapper-4.3.1-py2.6-nspkg.pth changing mode of /usr/bin/virtualenvwrapper.sh to 755 changing mode of /usr/bin/virtualenvwrapper_lazy.sh to 755 Running setup.py install for virtualenv-clone Installing virtualenv-clone script to /usr/bin Running setup.py install for stevedore [pbr] Reusing existing SOURCES.txt Running setup.py install for argparse warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.orig' found anywhere in distribution warning: no previously-included files matching '*.rej' found anywhere in distribution no previously-included directories found matching 'doc/_build' no previously-included directories found matching 'env24' no previously-included directories found matching 'env25' no previously-included directories found matching 'env26' no previously-included directories found matching 'env27' Successfully installed virtualenvwrapper virtualenv-clone stevedore argparse Cleaning up... [root@devcacom ~]# vi .bashrc if [ -f /usr/bin/virtualenvwrapper.sh ]; then export WORKON_HOME=$HOME/.virtualenvs source /usr/bin/virtualenvwrapper.sh fi [root@devcacom ~]# source ~/.bashrc