Skip to content

Instantly share code, notes, and snippets.

View ryujignh's full-sized avatar

Ryuji Ganaha ryujignh

  • San Francisco Bay Area
View GitHub Profile
Last login: Tue Oct 27 10:21:02 on ttys004
MacBook-Pro-2:lighthouse RyujiGanaha$ irb
irb(main):001:0> ls
NameError: undefined local variable or method `ls' for main:Object
from (irb):1
from /Users/RyujiGanaha/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
irb(main):002:0> xit
NameError: undefined local variable or method `xit' for main:Object
from (irb):2
from /Users/RyujiGanaha/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
@ryujignh
ryujignh / counting
Last active October 29, 2015 02:07
def index(list)
empty = Hash.new
list.each_char.each_with_index do |letter, index|
empty[letter] ||= []
empty[letter] << index
end
empty
end
def redeem_bottles(bottles)
redeems_loop = 0
total_redeems = 0
while bottles >= 2 do
redeem_bottles = (bottles / 2)
redeems_loop += redeem_bottles
puts total_redeems += redeems_loop
break
end
require 'rubygems'
require 'rest-client'
require 'open-uri'
#Writeのやり方(How to write)
wiki_url = "http://en.wikipedia.org/"
wiki_local_filename = "wiki-page.html"
#Wikipediaのトップページを取得して、保存するメソッド
#"w"が保存をするというアクション。上書きしちゃうよ。
if @post.save
refirect_to posts_path
else
render :new
end
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'react-rails', '~> 1.5'
gem 'rails-api'
gem 'puma'
gem 'pg'
gem 'oauth'
gem 'jwt'
gem 'ffaker'
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
activejob (= 4.2.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.0)
User, Taggings, Tagというモデルがる。
UserはTaggingsをthrougして沢山のtagを持っている。
User
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, polymorphic: true
@ryujignh
ryujignh / file0.txt
Created February 16, 2016 05:25
FormのinputをJSONに起こしてlocalStorageに保存する。 ref: http://qiita.com/ryujignh/items/ca963ba3db35cbf63558
var namelist = {
first_name: first_name,
last_name: last_name
};
localStorage.setItem("setdata", JSON.stringify(namelist));
This is the form that rendering form1 partial
= simple_form_for @user do |f|
= f.fields_for :profile, @user.profile || Profile.new do |p|
= render 'users/form1', f: f, p: p
This is the form
.form-1
.form-1-detail
= f.input :name