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
@ryujignh
ryujignh / README.md
Created August 3, 2022 18:51 — forked from jesster2k10/README.md
Rails API Social Login

Rails API-Only Social Login

This is another piece of code I've extrapolated from a Ruby on Rails project I'm currently working on. The code implmenets social login with a RoR API-based application, targeted at API clients.

The setup does not involve any browser-redirects or sessions as you would have to use working with Omniauth. Instead, what it does is takes an access_token generated on client-side SDKs, retireves user info from the access token and creates a new user and Identity in the database.

This setup works with native applications as described in the Google iOS Sign In Docs (see Authenticating with a backend server)

"shift_tab_unindent": true,
"show_full_path": true,
"translate_tabs_to_spaces": true,
"word_separators": "./\\()\"'-:,.;<>~!#$%^&*|+=[]{}`~?",
"word_wrap": "true"
"trim_trailing_white_space_on_save": true,
@ryujignh
ryujignh / file0.swift
Last active March 3, 2018 08:43
Swift: NSCoderを使ったデータの保存、ロード ref: https://qiita.com/ryujignh/items/3c03115d6b939ff87f3f
var itemArray = [Item]()
let dataFilePath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("Items.plist")
var itemArray = []
let defaults = UserDefaults.standard
@ryujignh
ryujignh / file0.txt
Last active February 28, 2018 23:39
メモ:Swiftでテーブルを作る時のお作法 ref: https://qiita.com/ryujignh/items/cc8f6314426c134721c6
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemArray.count
}
- @recommended_loggers && @recommended_loggers.each do |logger|
li salt
class AvatarsController < ApplicationController
before_action :authenticate_user!
def show
end
def update
# to crop, need to assign crop attrs before assigning avatar file
current_user.assign_attributes(user_crop_params)
if current_user.update(user_params)
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
@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));
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