This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/devise.rb | |
# for web | |
config.omniauth :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], | |
{ access_type: "offline", | |
prompt: "consent", | |
select_account: true, | |
provider_ignores_state: true, | |
scope: "plus.profile.emails.read,calendar,contacts" } | |
# for api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result = await fetch({ | |
api: "http://localhost:3000/users/auth/google_oauth2_for_api/callback", | |
method: 'get', | |
params: { | |
code: response.params.code, | |
redirect_uri: redirectUrl | |
} | |
}) | |
// The result is from rails side. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let redirectUrl = Expo.AuthSession.getRedirectUrl(); | |
let response = await Expo.AuthSession.startAsync({ | |
authUrl: | |
`https://accounts.google.com/o/oauth2/v2/auth?` + | |
`&client_id=${GOOGLE_WEB_APP_ID}` + | |
`&redirect_uri=${encodeURIComponent(redirectUrl)}` + | |
`&response_type=code` + | |
`&access_type=offline` + | |
`&prompt=consent` + | |
`&scope=${encodeURIComponent('https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/contacts')}`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wallet = artifacts.require("./MyWallet.sol"); | |
var receivedProposal = function (walletInstance, from, to) { | |
return new Promise((resolve, reject) => { | |
var event = walletInstance.proposalReceived({from: from, to: to}, {fromBlock: 0, toBlock: "latest"}); | |
event.watch(function(error, response) { | |
event.stopWatching(); | |
if (error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find node name is gd:email and attribute rel value contains work wording | |
node = doc.xpath("//*[name()='gd:email'][contains(@rel, 'work')]").first | |
# change email address attribute value | |
node.attributes["address"].value = value[:address] | |
# change node content <node>{content is here}</node> | |
node.content = value | |
# remove all nodes that name is gd:phoneNumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Rails.application.config_for(:database) | |
=> {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"listia_development", "pool"=>5, "username"=>"listia", "socket"=>"/tmp/mysql.sock"} | |
> h = Hashie::Mash.new(Rails.application.config_for(:database)) | |
=> #<Hashie::Mash adapter="mysql2" database="listia_development" encoding="utf8" pool=5 reconnect=false socket="/tmp/mysql.sock" username="listia"> | |
> h.adapter | |
=> "mysql2" | |
> h.database | |
=> "listia_development" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When you use select * for update, other process only could touch the query when it be `committed` | |
# Query 1 | |
User.transaction do | |
User.find(1).groups.joins(:owner).lock.each(&:destroy) | |
end | |
User.transaction do | |
# If the groups has same owner, it will wait the query 1 | |
# If not, it will continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
bool leap_year(int y) { | |
int is_leap; | |
is_leap = (y % 400 == 0) || | |
((y % 4 == 0) && !(y % 100 == 0)); | |
return is_leap; | |
} | |
int main(void) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
int main(void) { | |
int leap_year(int y) | |
{ | |
int is_leap; | |
is_leap = (y % 400 == 0) || | |
((y % 4 == 0) && !(y % 100 == 0)); | |
return is_leap; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some default enhancements/settings for IRB, based on | |
# http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks | |
unless defined? ETC_IRBRC_LOADED | |
# Require RubyGems by default. | |
require 'rubygems' | |
# Activate auto-completion. | |
require 'irb/completion' |
NewerOlder