Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
puts "CIRCLE_PULL_REQUEST: #{ENV['CIRCLE_PULL_REQUEST']}"
puts "CIRCLE_BRANCH: #{ENV['CIRCLE_BRANCH']}"
exit true if ENV['CIRCLE_PULL_REQUEST'].nil?
@gin0606
gin0606 / check_wip.rb
Created June 14, 2018 04:35
CircleCIでプルリクエストがWIPかチェックするやつ
def pr_url
uri_path = URI.parse(ENV['CI_PULL_REQUEST']).path.split('/')
"https://api.github.com/repos/#{uri_path[1]}/#{uri_path[2]}/pulls/#{uri_path[4]}"
end
def pr_title
require 'net/http'
require 'uri'
require 'json'
@gin0606
gin0606 / railstimestamp.swift
Created February 14, 2018 10:40
rails の Timestamp を Date に変換できる format
let timestamp = "2017-07-03T17:00:00.000Z"
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
let date = formatter.date(from: timestamp)!
print(date) // => 2017-07-03 17:00:00 +0000
import React from 'react';
import { createStore } from 'redux';
import { Provider, connect } from 'react-redux';
const View = props => (
<div>
<p>{props.count}</p>
<button onClick={props.onClickIncrement}>+1</button>
<button onClick={props.onClickDecrement}>-1</button>
</div>

Keybase proof

I hereby claim:

  • I am gin0606 on github.
  • I am gin0606 (https://keybase.io/gin0606) on keybase.
  • I have a public key ASAqSiNJbgMbQfYpX6kUWuwNBQ-8PB-dhyjlCPWBkjiKZgo

To claim this, I am signing this object:

@gin0606
gin0606 / eof.sh
Created March 17, 2016 11:10
ファイル末尾に改行入れるやつ。これは"*.rb"を指定してる
find . -name '*.rb' -type f -exec sh -c "tail -1 {} | xxd -p | tail -1 | grep -q -v 0a$" ';' -exec sh -c "echo >> {}" ';'
@gin0606
gin0606 / date_time_regex-rfc3339.rb
Last active September 28, 2015 09:18
rfc3339 の datetime の定義にmatchするはずの正規表現
module DateTimeRegex
module RFC3339
class << self
def date_fullyear
/\d{4}/
end
def date_month
/\d{2}/
end
RSpec.describe User do
describe 'POST /api/users' do
let(:access_token) { FactoryGirl.create(:access_token) }
let(:headers) do
{
'Authorization' => "#{access_token.token_type} #{access_token.token}"
}
end
let(:params) do
{
RSpec.describe User do
context "with correct parameters" do
subject { build(:user) }
it { is_expected.to be_valid }
end
describe "User has properties" do
subject { build(:user) }
it { is_expected.to respond_to :screen_name }
RSpec.describe User do
it "should be valid if it's the correct parameters" do
expect(build(:user)).to be_valid
end
context "when screen_name is not present" do
before { @user = build(:user, screen_name: "") }
it "should not be valid" do
expect(@user).not_to be_valid