Skip to content

Instantly share code, notes, and snippets.

View srockstyle's full-sized avatar

Shohei Kobayashi srockstyle

View GitHub Profile
@srockstyle
srockstyle / ansible_add_repository.yml
Created September 7, 2018 00:15
ansibleでリポジトリ追加祭り in CentOS 7
tasks:
- name: set timezone to Asia/Tokyo
timezone:
name: Asia/Tokyo
- name: add epel
yum:
name: epel-release
state: latest
- name: add mysql repo
yum:
@srockstyle
srockstyle / kubernetes_install.sh
Created September 7, 2018 00:13
[WIP] kubernetes in CentOS7
yum install etcd kubernetes flannel
vi /etc/etcd/etcd.conf
#--------
#ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"
ETCD_LISTEN_CLIENT_URLS="http://master01:2379,http://localhost:2379"
#--------
systemctl start etcd
@srockstyle
srockstyle / footer_vagrantfile
Created September 7, 2018 00:10
ansible_localを使うときの前準備。
@srockstyle
srockstyle / gist:738e529480699fdc73837c5e6fb0a877
Created September 7, 2018 00:09
MySQL8でのユーザ作成
mysql> CREATE ROLE super_user_role;
Query OK, 0 rows affected (0.11 sec)
mysql> GRANT ALL ON srockstyle.* TO super_user_role;
Query OK, 0 rows affected (0.15 sec)
mysql> CREATE USER 'srockstyle'@'%' IDENTIFIED BY "aaaaaaaaa" DEFAULT ROLE super_user_role;
Query OK, 0 rows affected (0.02 sec)
@srockstyle
srockstyle / install_nginx_certbot.sh
Created September 7, 2018 00:05
yumでnginx用のcertbotをインストール
# インストール
$ yum -y install yum-utils
$ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
$ sudo yum install python2-certbot-nginx
# 始める
$ sudo certbot --nginx
# ワイルドカード
$ sudo certbot -a dns-plugin -i nginx -d "*.example.com" -d example.com --server https://acme-v02.api.letsencrypt.org/directory
@srockstyle
srockstyle / rvm_update.sh
Created September 7, 2018 00:03
rvmのアップデート
rvm get latest
@srockstyle
srockstyle / connetc_all.sql
Created September 7, 2018 00:01
どこからでも繋げることができるようにするSQL(開発環境だけにつかうよ)
GRANT ALL PRIVILEGES ON *.* TO root@'%';
FLUSH PRIVILEGES;
@srockstyle
srockstyle / rails_g_migration.sh
Last active August 23, 2018 22:37
マイグレーションファイル作成
# songテーブルとalbamテーブルに
$ rails g migration AddIdsToSong
$ rails g migration AddIdsToAlbum
@srockstyle
srockstyle / activerecord_use_part2.rb
Last active August 23, 2018 22:34
[WIP] ActiveRecordの使い方リスト:その2
## scope
# scopeさんはよくつかうであろう検索条件を書いておくことができます。これをやることで毎回同じこと書かずに済みます。
scope :rock_artist_search,where(genre: "rock")
Artist.rock_artist_search
## ids
# レコードのidだけをとってきます
Artist.ids
@srockstyle
srockstyle / activerecord_use_part1.rb
Last active August 23, 2018 22:32
[WIP] ActiveRecordの使い方リスト:その1
##-------------------------
# where
##-------------------------
## 基本
@artsts = Artist.where(genre: 'Rock')
## 配列で指定もできます。この場合は探したい文字列のところに「?」を入れて、次の配列にでていた順番に探したい文字列を順番にいれていけば大丈夫です。
@artsts = Artist.where("name = ? and genre = ?","Oasis","Rock")
# 値がnullをすべて取得とかできます。