Skip to content

Instantly share code, notes, and snippets.

View chihirokaasan's full-sized avatar

ChihiroMazda chihirokaasan

View GitHub Profile
@chihirokaasan
chihirokaasan / main.js
Created March 2, 2018 01:40
Vue.jsプラグインsortable.js の読み込み
import Sortable from 'vue-sortable/vue-sortable.js'
Vue.use(Sortable)
@chihirokaasan
chihirokaasan / wp-config.php
Created January 9, 2018 02:38
WordPress config.php Switch databases in production and testing environments
/** WordPress のためのデータベース名 */
/** テスト環境のHOST */
if($_SERVER["HTTP_HOST"] == "testURL.jp") {
define('DB_NAME', 'test_DB_Name');
/** MySQL データベースのユーザー名 */
define('DB_USER', 'DB_Test_User_Name');
/** MySQL データベースのパスワード */
define('DB_PASSWORD', 'Test_DB_PASSWD');
/** MySQL のホスト名 */
define('DB_HOST', '127.0.0.1');
@chihirokaasan
chihirokaasan / AppController.php
Last active September 6, 2017 02:19
CakePHP3 redirect to SSL
namespace App\Controller;
use Cake\Controller\Controller;
use Cake\Event\Event;
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
@chihirokaasan
chihirokaasan / AppController.php
Last active September 6, 2017 02:02
CakePHP2 CakePHP1.3 redirect to SSL
class AppController extends Controller
{
var $components = array('Security');
function beforeFilter()
{
// When you want to specify the action
/*
*if ($this->action === 'index') {
* $this->Security->blackHoleCallback = 'forceSSL';
@chihirokaasan
chihirokaasan / mysql-container
Created July 24, 2017 03:51
Docker のMySQLイメージからコンテナを作成
docker run --name your-container-name -e MYSQL_ROOT_PASSWORD=your-mysql-root-password -d mysql:5.7
@chihirokaasan
chihirokaasan / php-to-MySQL
Created July 24, 2017 03:23
PHPからMySQLへ繋ぐ際のサンプル
<?php
$dsn = 'mysql:host=172.17.0.2;dbname=your-database-name';
$username = 'root';
$password = 'your-root-password';
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$dbh = new PDO($dsn, $username, $password, $options);
@chihirokaasan
chihirokaasan / howToGetContainerIPAddress
Created July 24, 2017 03:20
DockerのコンテナのnameまたはIDからIPアドレスを取得
docker inspect --format '{{ .NetworkSettings.IPAddress }}' your-container-name-or-id
@chihirokaasan
chihirokaasan / container-login
Created July 24, 2017 03:11
Dockerのコンテナにアクセス
docker exec -it your-container-name bash
#例 MySQLのDockerコンテナにログインしてMySQLにアクセス
docker exec -it your-container-name bash
root@0your-container-name:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
@chihirokaasan
chihirokaasan / command
Last active July 24, 2017 02:27
Docker run command
docker run -v /your-app-source-dir:/var/www/html --privileged -d -p 8000:80 --name your-php-container-name your-php-image /sbin/init -DFOREGROUND
@chihirokaasan
chihirokaasan / DockerFile
Created July 24, 2017 02:04
CentOS7のapacheベースのphp7のイメージ
FROM centos:centos7
MAINTAINER matsuda
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN yum -y install wget epel-release
RUN wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
RUN rpm -Uvh ./remi-release-7.rpm
RUN sed -i '4a priority=1' /etc/yum.repos.d/remi-php71.repo