I can create a new stripe connect account with
require 'stripe'
Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Account.create({
type: 'express',
country: 'US',
email: 'jenny.rosen#example.com',
capabilities: {
card_payments: {requested: true},
transfers: {requested: true},
},
})
I understand I can provide that account with a test address using a 'token' called address_full_match. But I have no idea what that 'token' is nor how to use it in ruby code, that is, I do not know what ruby code to write to use this 'token'
I tried the obvious to generate/access a token:
Stripe::address_full_match
NoMethodError: undefined method `address_full_match' for Stripe:Module
from (pry):10:in `__pry__'
How can I use this 'token' in ruby code (specifically, in Stripe::Account.create()) ?
Further attempts
Attempt 1
If we search the documentation for any instances of enabled": true it returns zero results, but if we search for instances of enabled": false we get 16 results. So the documentation doesn't provide a single example creating an account with either charges_enabled: true, nor with payouts_enabled: true, which is surprising since that's predominantly what developers want to do - create account functional accounts (not dysfunctional ones)
Attempt 2
I tried placing address_full_match in the 'Address line 1' field of the web UI. But it still results in payments_enabled: false
You will get it from StripeCheckout JS client
you have to include js script from stripe
<script src="https://checkout.stripe.com/checkout.js"></script>
Again create a script and In the js script you have to write like
StripeCheckout.configure({
key: "<%= Rails.configuration.stripe[:publishable_key] %>",
locale: "auto",
name: "XYZ",
description: "XYZ Description",
email: "<%= current_user.email %>",
billingAddress: true,
zipCode: true,
token: function(token) {
console.log("Stripe Token : " + token.id)
}
});
I found this reference https://docs.aws.amazon.com/sdkforruby/api/Aws/CostExplorer/Client.html#initialize-instance_method for finding cost of ec2 instance usages ,while in implementing phase i got exception.
in gem file i used this
gem 'aws-sdk', '~> 3'
cost_client = Aws::CostExplorer::Client.new(
region: "us-east-1",
access_key_id: "XXXX",
secret_access_key: "XXX"
)
resp = cost_client.get_cost_and_usage({
time_period: { # required
start: "2019-01-01", # required
end: "2019-05-01", # required
},
granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
filter: {
or: [
{
# recursive Expression
},
],
and: [
{
# recursive Expression
},
],
not: {
# recursive Expression
},
dimensions: {
key: "AZ", # accepts AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, SCOPE, PLATFORM, SUBSCRIPTION_ID, LEGAL_ENTITY_NAME, DEPLOYMENT_OPTION, DATABASE_ENGINE, CACHE_ENGINE, INSTANCE_TYPE_FAMILY, BILLING_ENTITY, RESERVATION_ID
values: ["Value"],
},
tags: {
key: "TagKey",
values: ["Value"],
},
},
metrics: ["MetricName"],
group_by: [
{
type: "DIMENSION", # accepts DIMENSION, TAG
key: "GroupDefinitionKey",
},
],
next_page_token: "NextPageToken",
})
i got this excetion NameError: uninitialized constant Aws::CostExplorer.how can i get response from this api?
gems you used are not compatible with costexplorer sdk.
use this-
gem 'aws-sigv4', '~> 1.1'
gem 'aws-sdk-core', '~> 3.52', '>= 3.52.1'
gem 'aws-sdk-costexplorer', '~> 1.22'
Hope this will help you :)
You are using version 3 while your docs point to v2.
Check https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/CostExplorer.html, specially the following
This module provides support for AWS Cost Explorer Service. This
module is available in the aws-sdk-costexplorer gem.
I cannot understand this error neo4j.config.session_path is deprecated, please use neo4j.config.session.path. I get this in the myspec file during the testing. I updated Neo4j to version 9 from 7 and now I have this deprecation. I cannot understand what I should do because nowhere I cannot find the line is deprecated. I'm getting the error in the next lines of code:
describe "Edit Access" do
before :all do
Amendment.delete_all
a = Amendment.create(cid: "X1", namespace: "http://www.example.com", property: "question",
study_value: "ADEF", default_value: "A1", datatype: "string")
a = Amendment.create(cid: "X1", namespace: "http://www.example.com", property: "enabled",
study_value: "true", default_value: "true", datatype: "boolean")
a = Amendment.create(cid: "Y1", namespace: "http://www.example.com", property: "enabled",
study_value: "false", default_value: "true", datatype: "boolean")
ua_create
end
after :all do
Amendment.delete_all
ua_destroy
end
You should find neo4j.config.session_path defined somewhere in your app. Maybe search / grep for it? The places I would expect to find it are:
config/application.rb
config/environments/development.rb
config/environments/test.rb
config/environments/production.rb
Separately, I would make sure to read the upgrade guide for issues that may come up upgrading from 7.x to 8.x/9.x
I'm using Ruby with the Mechanize GEM to log in to TDAmeritrade's website.
I try to execute: page = agent.get('https://invest.ameritrade.com/grid/p/login') and it returns page.forms as follows:
2.0.0-p0 :049 > page.forms
=> [#<Mechanize::Form
{name nil}
{method "POST"}
{action "https://invest.ameritrade.com/grid/p/login"}
{fields
[hidden:0x5b6684a type: hidden name: mAction value: submit]
[hidden:0x5b665a2 type: hidden name: fp_browser value: ]
[hidden:0x5b66386 type: hidden name: fp_screen value: ]
[hidden:0x5b661e2 type: hidden name: fp_software value: ]
[hidden:0x5b6f36e type: hidden name: fp_timezone value: ]
[hidden:0x5b6ffb2 type: hidden name: fp_language value: ]
[hidden:0x5b6fe5e type: hidden name: fp_java value: ]
[hidden:0x5b6fcc4 type: hidden name: fp_cookie value: ]
[hidden:0x5b6fbfc type: hidden name: flashVersion value: ]
[selectlist:0x5b6f756 type: name: ldl value: main:home]}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons [button:0x5b6eafe type: submit name: value: ]}>
]
As you can see, neither the username nor password fields are shown even though they can be seen on the website in a browser. How do I log in to TDAmeritrade with my Ruby script using the Mechanize GEM (http://mechanize.rubyforge.org/)?
Thanks in advance.
For sites that login via a POST request, you can manually capture the XHR in something like Firebug and replicate it in your code.
For example, the site you have listed has a bunch of hidden fields that get added on submission of a username and password. Luckily, you can pass a hash to a POST request call on your Mechanize::Agent.
#agent.post("https://invest.ameritrade.com/grid/p/login",
{"tbPassword" => yourPass, "tbUsername" => yourUsername})
Of course you'll need to add the additional fields as well.
example POST XHR from Firebug for your example site
flashVersion 11.9.900
fp_browser mozilla/5.0 (macintosh; intel mac os x 10.8; rv:24.0) gecko/20100101 firefox/24.0|5.0 (Macintosh)|MacIntel
fp_cookie 1
fp_java 1
fp_language lang=en-US|syslang=|userlang=
fp_screen 24|2560|1440|1440
fp_software
fp_timezone -4
ldl main:home
mAction submit
tbPassword yourPassword
tbUsername yourUsername
You might run into problems with mechanize on different sites that implement javascript. You might want to try using the watir-webdriver or if it's a site that has a lot of javascript use you might be better off using phantomjs.
I used the gem to install ckeditor. As such there is no config.js in the project (there is in the actual gem folder that I don't want to modify). The install did create a ckeditor.js in the config/initializers folder that would seem to be the correct place to put the tool bar definition. But everything I have tried to get that to work throws a variety of syntax or method not found errors. Has anyone had success with this? If so a quick example would be very helpful.
My current ckeditor.js is:
# Use this hook to configure ckeditor
if Object.const_defined?("Ckeditor")
Ckeditor.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require "ckeditor/orm/active_record"
# Allowed image file types for upload.
# Set to nil or [] (empty array) for all file types
# config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
# Allowed attachment file types for upload.
# Set to nil or [] (empty array) for all file types
# config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]
end
end
1.Add following in application.js
//= require ckeditor/ckeditor
//= require_tree ./ckeditor
2.Add a config.js in app/assets/javascript/ckeditor
Sample config.js
if(typeof(CKEDITOR) != 'undefined')
{
CKEDITOR.editorConfig = function(config) {
config.uiColor = "#AADC6E";
config.toolbar = [
[ 'Bold', 'Italic', 'Underline', 'Strike' ],
[ 'NumberedList', 'BulletedList', 'HorizontalRule' ],
[ 'Blockquote' ],
[ 'Undo', 'Redo' ],
[ 'insertResolved' ],
[ 'Source' ]
];
}
} else{
console.log("ckeditor not loaded")
}
I have the same problem as yours. At first, I followed Config rails with asset pipeline but it doesn't work for me. Then I realized that the author of that link only create a new style of toolbar. You need to call it in the view also. That means you need to add this line
input_html => {:toolbar => 'MyToolbar'}
to make it works.
In order to test if the config.js is working, you can check the source of your webpage to see whether assets/javascripts/ckeditor/config.js is added.
Another way to check is to edit the editor color by uncommenting this line: config.uiColor = '#AADC6E'. If the color of the editor changes then it works.
I also made a stupid mistake that I include the ckeditor js files two times: once in the application.js, once in the layouts/application.html.haml file. Don't know whether this is the source of the problem or not. You can try.
Hope this helps.
this worked for me:
How to configure CKEditor in Rails 3.1 (gem + Asset Pipeline)
just save the snippet given in the answer, in config.js file
May be my comment on github will help you https://github.com/galetahub/ckeditor/issues/136#issuecomment-8870692
This is the updated answer to Rails 4.1 with ckeditor 4.1.0 to custom configure the ckeditor toolbar.
In your view, using simple_form, you need to config the input like this example:
_FORM.HTML.ERB
<%= simple_form_for(#foo) do |f| %>
<%= f.input :bar, as: :ckeditor %>
<%= f.button :submit %>
<% end %>
In your Javascript assets you need to create a folder called "ckeditor" and in there create a file called "config.js"
../JAVASCRIPTS/CKEDITOR/CONFIG.JS
CKEDITOR.editorConfig = function(config) {
//config.language = 'es'; //this could be any language
config.width = '725';
config.height = '600';
// Filebrowser routes
// The location of an external file browser, that should be launched when "Browse Server" button is pressed.
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
// The location of a script that handles file uploads in the Flash dialog.
config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
// The location of a script that handles file uploads in the Image dialog.
config.filebrowserImageUploadUrl = "/ckeditor/pictures";
// The location of a script that handles file uploads.
config.filebrowserUploadUrl = "/ckeditor/attachment_files";
// You could delete or reorder any of this elements as you wish
config.toolbar_Menu = [
{ name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] },
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
{ name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] },
{ name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About'] }, '/',
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
{ name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'] },
{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] }, '/',
{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
{ name: 'colors', items: ['TextColor', 'BGColor'] },
{ name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'] }
];
config.toolbar = 'Menu';
return true;
};
The config for the application.js is like this, notice that the order of ckeditor and require_tree is important
APPLICATION.JS
//= require jquery
//= require jquery_ujs
//= require ckeditor/init
//= require_tree .
Now in your ckeditor.rb you should uncomment this line "config.asset_path" and add the path to the config.js file that you created before wich is "/assets/ckeditor/"
../CONFIG/INITIALIZERS/CKEDITOR.RB
# Use this hook to configure ckeditor
Ckeditor.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require "ckeditor/orm/active_record"
# Customize ckeditor assets path
# By default: nil
config.asset_path = "/assets/ckeditor/"
end
I hope it helps :D!