Sublime Text 2で検索する(Command + F)際に日本語の文字を入力してEnterすると文字が消える現象への対処法
タイトルの通りです。
Preferences -> Key Bindings DefaultからDefault(OSX).sublime-keymapファイルを開いて編集。以下の行をコメントアウトします。
// Find panel key bindings // serch内で日本語入力後Enterすると文字が消えないようにコメントアウト // { "keys": ["enter"], "command": "find_next", "context": // [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}] // }, { "keys": ["shift+enter"], "command": "find_prev", "context": [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}] }, { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true}, "context": [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}] }, // Replace panel key bindings // serch内で日本語入力後Enterすると文字が消えないようにコメントアウト // { "keys": ["enter"], "command": "find_next", "context": // [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}] // }, { "keys": ["shift+enter"], "command": "find_prev", "context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}] }, { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true}, "context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}] }, { "keys": ["ctrl+alt+enter"], "command": "replace_all", "args": {"close_panel": true}, "context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}] }, // Incremental find panel key bindings // serch内で日本語入力後Enterすると文字が消えないようにコメントアウト // { "keys": ["enter"], "command": "hide_panel", "context": // [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}] // }, { "keys": ["shift+enter"], "command": "find_prev", "context": [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}] }, { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true}, "context": [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}] },
これにて、検索時の日本語入力に苦戦させられる問題を解決しました。ちなみこのコメントアウトにより、EnterKeyを押してもfind_nextされなくなりますが、Command + Gすれば同じことができるので問題ないかと思います。find_prevはShift + Command + Gでできます。
プリンタがたまに使えなくなる理由とMacでの解決法
こんにちは、オークです。
うちの会社では急にプリンタが使えなくなることが多いので、原因を調べたら、プリンタのIPが関係しているんじゃないかという結論が浮上しました。
社内の無線LANがDHCPに従っている時、PCやプリンタのIPアドレスは無線LANアクセスポイント(【参考】1参照)が動的に振り分けています。
PCやプリンタが再起動されると、振り分けらていたIPアドレスは変更されます。
なのでプリンタが使えなくなる問題は、DHCPによってIPアドレスが変更されていたことによって起こるものと考えられます。
なので対処法(Mac)としては以下の2つになります。
①Macでのプリンタの設定を更新する
[システム環境設定]→[プリンタとスキャナ]ページで左側に表示されているプリンタを[−]で削除して、[+]で追加し直す。これによって変更後のIPアドレスを持ったプリンタを追加することができます。
②プリンタのIPアドレスを固定してしまう
DHCPに従うとしょっちゅうIPアドレスが変更されて面倒な時は、プリンタのIPアドレスを固定すると良いでしょう。これによって①によって対処する必要がなくなると思われます。ただしAir Printなどの規格の方が影響している可能性もあるので、これが完全な解決策とは一概に言えません。これついて詳しいことがわかれば情報を更新しようと思います。
【参考】
1. ルーターとハブの違い 【図解・初心者向け】
Facebook SDK × CakePHP × MAMPでFacebookログインサイトを開発(2)
前回の記事、「Facebook SDK × CakePHP × MAMPでFacebookログインサイトを開発(1)」の続きです。
③-1.
https://github.com/facebook/facebook-php-sdk からFacebook SDKをダウンロード
③-2.
facebook-php-sdk-masterフォルダを「facebook」に名称変更して、CakePHPのapp/Vendor/に設置
④ControllerとViewの作成
④-1.
UsersController(コード)
④-2.
users/index(コード)
users/index(Google Chrome上での表示:ログイン時)
users/index(Google Chrome上での表示:ログアウト時)
ポイントの1つ目は、createFacebook関数内で、appIDとsecretを記述するところです。これはFacebook Developersのアプリの設定ページに表示されているものを記述します。(下図参照)
ポイントの2つ目は、Facebook Developersのアプリの設定ページのSite URLとログイン処理をするページを一致させることです。今回はusers/loginページをログイン処理のページにしましたが、実装に従って、適宜調整して下さい。
(こちらも下図参照)
あとの部分は、CakePHPでの開発であれば、ここに書いてあるコード通りにやっていただければ動くかと思います。では。
【参考サイト】
・[CakePHP]ローカル環境のCakePHP2.3でFacebook接続して情報取得&投稿する | offsidenowの日常を綴ったブログ(http://offsidenow.phpapps.jp/archives/275)
・cakePHPでFacebookログイン - もぎゃろぐ(http://blog.mogya.com/2013/04/cakephpfacebook12.html)
・facebook php sdk api でログアウトする方法 - いろいろつまみ食い(http://d.hatena.ne.jp/imaiworks/20120518/1337310167)
Facebook SDK × CakePHP × MAMPでFacebookログインサイトを開発(1)
ご無沙汰してます。オークです。
最近はFacebookでログインできるサイト作りを勉強していたので、それについて記事を書きます。
●環境:
Mac(OS X バージョン10.9.2)、CakePHP(2.4.10)、ローカル環境(MAMP)
●大まかな手順:
①Facebook Developersへの登録
②アプリの登録
④ControllerとViewの作成
●詳細な手順
①Facebook Developersへの登録
①-1.
https://developers.facebook.com へアクセス
①-2.
左上の[Apps]→[Register as a Developers]
①-3.
同意して[次へ]
①-4.
携帯メールアドレスを登録して、[確認コードを取得]
①-5.
登録したメールアドレス宛てに確認コードが届くのでそれを[確認コード]へ入力→[完了]
②アプリの登録
②-1.
Developersのホーム画面の左上から[Create a New App]
②-2.
Display Nameとカテゴリを入力(Namespaceは入力しなくてもOK。Display NameとNamespaceは後で変更できるので何でもOK)→数値入力して完了
②-3.
[Apps]→[アプリ名]→[Settings]。App DomainsにCakeフォルダを置くサイトのドメインを入力。ただし、MAMPで開発する時は「localhost」ではなく「自分のPC名.local」という形で登録
②-4.
[Add Platform]→[Website]。[Site URL]は「自分のPC名.local/test2/users/login/」とする(「login」の後の「/」は必須)
次回は
④Controllerの作成
について解説したいと思います。
VagrantのMacへの導入 & Apache, PHP, MySQL, memcachedのインストール
2014/04/24現在
①virtual Box のインストール
https://www.virtualbox.org/wiki/Downloads
②vagrant のインストール
http://www.vagrantup.com/downloads.html
③どこでもよいがvagrant用のフォルダを作成
今回(2014/04/24)は~の下にCentOSフォルダを作った
作ったらそのフォルダに移動
④OSイメージの追加(2013/09/05時点の記事)
$ vagrant box add centos http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
⑤仮想マシンの作成
⑥Vagrantfileの設定を変更(一番下の【Vagrantfileの設定】を参照)
⑦仮想マシンの起動
$ vagrant up
⑧仮想マシンにログイン
⑨仮想マシンに色々インストール(以下、複数行のコマンドは一気に貼り付け可能)
sudo yum -y upgrade
# リポジトリ追加
sudo rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
sudo rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
sudo vi /etc/yum.repos.d/remi.repo
# 下記を変更
[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=0
↓
enabled=1
# Apache(2.2.15-26)
sudo yum -y install httpd-devel
# PHP(5.4.13-1)
sudo yum -y install php-mbstring
sudo yum -y install php-mcrypt
sudo yum -y install php-pear-DB
sudo yum -y install php-pear-Auth-*
sudo yum -y install php-pecl-apc-devel
sudo yum -y install zlib-devel
# MySQL(5.5.30-1)
sudo yum -y install mysql-devel
sudo yum -y install mysql-server
# memcached(1.4.15-2)
sudo yum -y install memcached-devel
sudo yum -y install php-pecl-memcache
# リポジトリの無効化
sudo vi /etc/yum.repos.d/rpmforge.repo
# 下記を変更
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
↓
enabled = 0
sudo vi /etc/yum.repos.d/epel.repo
# 下記を変更
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
↓
enabled=0
sudo vi /etc/yum.repos.d/remi.repo
# 下記を変更
[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=1
↓
enabled=0
# Apacheの設定
# 不要なコンフィグを読込まないようにする
sudo mv -i /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org
# 起動
sudo service httpd start
# 自動起動設定
sudo chkconfig httpd on
# /etc/httpd/conf/httpd.conf編集
sudo vi /etc/httpd/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
# 上の設定で、ブラウザからアクセスした時に白い画面が表示される場合(というかやった方がいい)
<Directory “/var/www/html”>
Options FollowSymLinks
AllowOverride All
</Directory>
# PHPの設定
# エラーログ出力先作成
sudo mkdir /var/log/php
sudo chown apache /var/log/php
sudo chmod 755 /var/log/php
sudo vi /etc/php.ini
# 下記を変更
expose_php = On
↓
expose_php = Off
;date.timezone =
↓
date.timezone = 'Asia/Tokyo'
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
↓
error_reporting = E_ALL & ~E_NOTICE
↓
error_log = "/var/log/php/php_errors.log"
# セッションの保存先をmemcacheに設定
sudo vi /etc/php.d/memcache.ini
# 下記を変更
;session.save_handler=memcache
↓
session.save_handler=memcache
;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
↓
session.save_path="tcp://localhost:11211"
sudo vi /etc/httpd/conf.d/php.conf
# 下記を変更
php_value session.save_handler "files"
php_value session.save_path "/var/lib/php/session"
↓
#php_value session.save_handler "files"
#php_value session.save_path "/var/lib/php/session"
# memcachedの設定
# 自動起動設定
sudo chkconfig memcached on
# 起動
sudo service memcached start
sudo service httpd restart
# MySQLの設定
# ログの出力先作成
sudo mkdir /var/log/mysql
sudo chown -R mysql:mysql /var/log/mysql
# 起動
sudo service mysqld start
# 自動起動設定
sudo chkconfig mysqld on
# 初期設定
sudo mysql_secure_installation
# 対話式で設定が始まります。
# rootにパスワードを設定する以外は、すべてエンターでOKです。
Set root password? [Y/n]
New password: 任意のパスワード
Re-enter new password: 任意のパスワード
# 以下略
sudo rm -rf /var/www/html
# /home/vagrant/srcを/var/www/htmlにシンボリックリンクを設定
sudo ln -fs /home/vagrant/src /var/www/html
# iptable設定
sudo iptables -F
sudo /etc/init.d/iptables save
sudo /etc/init.d/iptables restart
# 追加
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
sudo service iptables save
sudo service iptables restart
# postfix
sudo /etc/rc.d/init.d/postfix start
sudo chkconfig postfix on
# http://jun-ya.hatenablog.com/entry/2013/08/09/170335
sudo vi /etc/httpd/conf/httpd.conf
# 3箇所書き換えた
<Directory />
...
# 以下を追記
EnableSendfile Off
...
</Directory>
<Directory “/var/www/html”>
...
# 以下を追記
EnableSendfile Off
...
</Directory>
<Directory “/home/vagrant/src”>
...
# 以下を追記
EnableSendfile Off
...
</Directory>
⑩CentOS/src/index.htmlというファイルをおく。index.htmlの中身は何でもいい ex. hello
⑪http://localhost:8080/ にアクセス
すると⑩で作ったindex.htmlの中身が表示される
----------------------------------------以下、CakePHPの場合の設定----------------------------------------
⑫CakePHP のcore.php に mask を2箇所追記
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666 ←追加する
));
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666 ←追加する
));
参考(http://qiita.com/pakiln/items/0f3e3ca4dc67495c8218)
以上
●【Vagrantfileの設定】
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
// この行を追加
config.vbguest.auto_update = true
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
# config.vm.box_url = "http://domain.com/path/to/above.box"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
// この行をコメントアウト
config.vm.network :forwarded_port, guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
// この行をコメントアウト
config.vm.synced_folder "src/", "/home/vagrant/src", owner: 'vagrant', group: 'apache', mount_options: ['dmode=777', 'fmode=666']
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.
# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file base.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "site.pp"
# end
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
# end
# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
●トラブルシューティング
1. vagrant再起動($ vagrant reload)の時、以下のエラーメッセージが表示される
------------------------------------------------------------------------------------------
There are errors in the configuration of this machine. Please fix
the following errors and try again:
* Unknown configuration section 'vbguest'.
------------------------------------------------------------------------------------------
# config.vbguest.auto_update = true //の行を以下のように修正
if Object.const_defined? 'VagrantVbguest'
config.vbguest.auto_update = false
config.vbguest.no_remote = true
end
参考(https://groups.google.com/forum/#!topic/vagrant-up/hNAyk57BLaM)
2. 1.で直してvagrant再起動($ vagrant reload)の時、以下のエラーメッセージが表示される
------------------------------------------------------------------------------------------
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group apache | cut -d: -f3`,dmode=777,fmode=666 /home/vagrant/src /home/vagrant/src
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=777,fmode=666 /home/vagrant/src /home/vagrant/src
------------------------------------------------------------------------------------------
(★以下のことを実行する前提として、vagrantにapacheがインストールされている必要がある)
(効果があるかはわからないが、前もって
$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group apache | cut -d: -f3`,dmode=777,fmode=666 /home/vagrant/src /home/vagrant/src
$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g apache`,dmode=777,fmode=666 /home/vagrant/src /home/vagrant/src
の2つのコマンドを試した
)
②$ sudo /etc/init.d/vboxadd setup
実行終了したら $ exit
③vagrant halt
④vagrant up
参考(http://qiita.com/osamu1203/items/10e19c74c912d303ca0b)
3. http://localhost:8080/ にアクセスすると、「データを受信していません」とブラウザに表示される
⑨の設定を全て行えば、このエラーは出ない
4. http://localhost:8080/ にアクセスすると、「Forbidden 403」とブラウザに表示される
/home/vagrant のアクセス権がないのが原因なので、以下のコマンドを入力
$ sudo chmod 755 /home/vagrant
参考(http://www.iscs.jp/tips/tips.php?id=22)
5. CakePHPのフォルダにアクセスしても「Not Found」と表示される
⑨の設定を全て行えば、このエラーは出ない
TCPDFはできないことが多い!と感じる
先日クライアントに、PDFファイルを出力できるようにしてくれと言われた。
「やってやろうじゃないか!htmlとcssを組み合わせればレイアウトも自由自在でしょ!」といきまいて作業にとりかかったが、あら大変。実際はそんなに単純じゃなくて、PDFファイルのレイアウトを色々いじるのは難しい!と感じたので、忘れないうちに今回学んだことをメモ。
(もしかしたら私の知識や検索が不足していて、ホントはもっと効率的なやり方があるのかもしれないが、もしそうだとしたら悪しからず)
環境:CakePHP2.4による開発、tcpdf Ver 6.0.055
0. 前提:CSSは効くものと効かないものがある。外部CSSは読み込まないので、styleタグ内にCSSを書くしかない。完全に効かない!とかならまだしも、効くものとそうでないのがあるのが質が悪い。
1. styleタグ内で、id指定は効かない。class指定は効く
//×ケース <div id="content"></div> <style> #content { color: red; } </style> //◯ケース <div class="content"></div> <style> .content { color: red; } </style>
→よって、class指定すべし
2. margin, padding, float使えない。
→よって、レイアウトはtableタグを使ってやるべし
3.
全角スペースも半角スペースも正確に認識しない
→よって、「 」で対応すべし
4.
太い線が引けない。cssで「border: solid 10px black」と指定しても、 10pxの線にならない。(色は変えられる。しかし、太さと線の形式(dotted, double等)は効かない
→よって、tcpdfの関数を使うべし。以下コード($pdfは最初に作成したインスタンス)
$pdf->SetLineWidth(0.8); //0.8は線の太さ $pdf->Line(10.0, 52.0, 153.0, 52.0); //10.0, 52.0は線の始点のX座標, Y座標 //153.0, 52.0は線の終点のX座標, Y座標
その他のできないことリスト
・centerタグが使えない
参考になるサイト
・PDFファイルを生成するためのPHPライブラリ「TCPDF」 | モノについてのモノ語り(http://www.near-mint.com/blog/5040)
以上。新情報あれば追加します。
CakePHP2.4:削除したユーザーでログイン不可にする処理
AppControllerに1行記述するだけ。
public $components = array(
'Session',
'Auth' => array(
'loginAction' => array(
'controller' => 'users',
'action' => 'login'
),
'authenticate' => array(
'Form' => array(
'userModel' => 'User',
'fields' => array(
'username' => 'code',
'password' => 'password'
),
# 以下の1行追加で、削除したユーザーではログイン不可になる
'scope' => array('User.deleted' => 0),
)
)
),
);
以外に簡単!!