Skip to content

Instantly share code, notes, and snippets.

View negabaro's full-sized avatar

kim negabaro

View GitHub Profile
@negabaro
negabaro / fileupload.js
Last active May 2, 2018 06:24
I would like to different files for each test
'use strict';
class FileUpload {
upload(path,domain) {
browser.url(domain);
browser.waitForExist('.btn-primary', 10000);
browser.chooseFile('#snapshot_file', path);
browser.element('#btn-upload').click();
@negabaro
negabaro / gist:7ce72338d07e71569925e752e48be022
Created February 16, 2018 16:43
nginx http -> https redirect
# http -> https redirect
set $check_redirect "";
set $check_domain "";
if ($http_host ~ xx\.xx$) {
set $check_domain "on";
}
if ($http_host ~ yy\.yy$) {
set $check_domain "on";
}
resource "aws_eip" "example" {
count = "${var.create_eip}"
instance = "${aws_instance.example.id}"
}
resource "aws_route53_record" "example" {
count = "${1 - var.create_eip}"
zone_id = "A1B2CDEF3GH4IJ"
name = "foo.example.com"
type = "A"
ttl = 300
@negabaro
negabaro / css
Last active December 10, 2017 15:08
weekCalendar
.wrap {
width: 500px;
margin: 0 auto;
}
.btn-holder {
text-align: center;
margin: 10px 0 10px 0;
}
#calendar table {
border-collapse: collapse;
@negabaro
negabaro / view-form.html.haml
Created October 17, 2017 20:55
Rails AASM view example
= bootstrap_form_for(@article, layout: :horizontal) do |f|
= f.text_field :title, autofocus: true
= f.text_area :body_source, rows: 20
.form-group
.col-sm-offset-2.col-sm-10
= f.button '下書きを保存', name: 'ope[cmd]', value: 'save', class: 'btn btn-lg btn-default'
- if @article.draft?
= f.button '公開する', name: 'ope[cmd]', value: 'publish', class: 'btn btn-lg btn-default'
@negabaro
negabaro / model-article.rb
Created October 17, 2017 20:54
Rails AASM model example
include AASM
aasm do
state :draft, :initial => true
state :published
#event :publish, before: ->{ self.published_at = Time.now } do
event :publish do
transitions :from => :draft, :to => :published
@negabaro
negabaro / aasm-articles_controller.rb
Created October 17, 2017 20:52
Rails AASM controller example
def create
@article = current_user.articles.build(article_params)
if @article.valid?
@article.save!
case params[:ope][:cmd]
when 'publish'
@article.publish!
puts "hi this is publish zone"
flash[:success] = '記事を公開しました。'
#app/models/user.rb
def self.find_for_twitter_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
unless user
user = User.create(user_nickname: auth.info.nickname,
provider: auth.provider,
uid: auth.uid,
email: User.create_unique_email,
password: Devise.friendly_token[0,20]
)
@negabaro
negabaro / check_rspec_enable.sh
Created October 6, 2017 11:20
不要なRSPEC省略
#echo "export RSPEC_ENABLE=0" >> ~/.bashrc
should_run_rspec(){
echo "You Should Run RSPEC Test"
sed -i 's/export RSPEC_ENABLE=0/export RSPEC_ENABLE=1/g' ~/.bashrc
}
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD)"
check_file() {
for var in $changed_files
@negabaro
negabaro / rails-controller.txt
Last active September 19, 2017 14:02
CRUD simple noticeboard with rails5.1
app/controller/articles_controller.rb
class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy]
def show
end
def edit