Ruby-AWS where to save config / how to load config - ruby-on-rails-3

I am not sure what is the best way to do an appliaction wide configuration of the Ruby/Aws gem?
I found an example of how a configuration file needs to look like: https://forums.aws.amazon.com/message.jspa?messageID=117931#117931
But what is the recommended way to store the configuration? Shall I put a simple file in config/amazonrc
and then call
Amazon::Config.new("#{RAILS_ROOT}/config/amazonrc")

I found now a good solution:
config/initializers/amazon.rb
require File.dirname(__FILE__) + '/../../config/environment.rb'
ENV['AMAZONRCDIR'] = "#{Rails.root}/config/"
config/.amazonrc
[global]
locale = 'de'
cache = false
key_id = '0Y44V8FAFNM119C6PXX2'
secret_key_id = 'YYYYYY'
[de]
associate = 'ID-21'

Related

Is the Mapbox access token still required for Kepler.gl?

we plan to integrate Kepler.gl into our open source analytics platform which will be used by many users. We have successfully integrated the library into our code and are able to visual beautiful maps with our data. The library is awesome and we want to use it but aren't sure about the Mapbox integration. Our code works without setting any Mapbox access token. Is the token no longer required if one uses the Kepler.gl with default settings? Are there any limitations in using it without a token e.g. will no longer work if more than 100 users use it?
This is the Kepler.gl related code that we used:
map_1 = KeplerGl(show_docs=False)
map_1.add_data(data=gdf.copy(), name="state")
config = {}
if self.save_config:
# Save map_1 config to a file
# config_str = json.dumps(map_1.config)
# if type(config) == str:
# config = config.encode("utf-8")
with open("kepler_config.json", "w") as f:
f.write(json.dumps(map_1.config))
if self.load_config:
with open("kepler_config.json", "r") as f:
config = json.loads(f.read())
map_1.config = config
# map_1.add_data(data=data.copy(), name="haha")
html = map_1._repr_html_()
html = html.decode("utf-8")
Thanks for your help
Tobias

How to use conan compon with my own build system? can you give me a demo?

I am new to conan, and I want to use the feature of component of conan,
I read the https://docs.conan.io/en/latest/creating_packages/package_information.html
but still cannot know how to use it .
likes the example:
'''
self.cpp_info.name = "OpenSSL"
self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto"
self.cpp_info.components["crypto"].libs = ["libcrypto"]
self.cpp_info.components["crypto"].defines = ["DEFINE_CRYPTO=1"]
self.cpp_info.components["ssl"].names["cmake"] = "SSL"
self.cpp_info.components["ssl"].includedirs = ["include/headers_ssl"]
self.cpp_info.components["ssl"].libs = ["libssl"]
self.cpp_info.components["ssl"].requires = ["crypto"]
'''
why the crypto self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto" ?
my build system is not based on CMake.
how to extract files to every component?
how to copy to local cache?
how to consume one component?
can anyone can give a demo how to create two libs and how to consume the libs
based on
https://github.com/shreyasbharath/conan-package-binary-example
https://github.com/shreyasbharath/conan-package-binary-consume-example
Thanks you very much !

can karate read files from outside the classpath with a relative path instead of absolute path

I'm trying to read a properties file for karate-config.js. It works when i provide the absolute path from my local but when i provide a relative path. it doesn't work. Any way around this? Thanks !
var config = karate.read("file:/repo/tests/utils/al_dev.json"); -- This doesn't work
var config = karate.read("file:~/repo/tests/utils/al_dev.json"); -- This doesn't work
var config = karate.read("file:/Users/user1/IdeaProjects/repo/tests/utils/al_dev.json"); -- This works
I was able to get it working. I had to update the path to reflect the project structure and it worked.
var config = karate.read("file:../../utils/al_dev.json");
Project structure:
project1 ->
tests ->
Utils ->
Services ->
client 1 ->
client 2 ->
I took advantage of answer wrote by Peter Thomas and it worked for me, I could read a json body from a file somewhere else in the project, not needed to be in the same folder as features. This is a sample of code I used:
Scenario: POST with json file reading from anywhere.
Given path "/api/apitesting/v1/transactions"
And def projectPath = karate.properties['user.home']
And def filePath = projectPath + "/IdeaProjects/01 Courses TM/karate/src/test/resources/data/TestBodyAnywhere.json"
And def requestBody = read('file:' + filePath)
And request requestBody
When method post
Then status 201
As you can see, I used user.home instead of user.dir, (which use to be recommended but this points directly to the same folder where you are calling it instead of pointing to outside that folder). User.home points directly to your root user, so it would be something like this C:/Users/MyUser. Then, from there you can start indicating the relative path in a new variable to your file. Finally, remember to use 'File:' keyword inside the read method and concatenate it with your path variable.
Hope it helps. ;)
Best regards!
Sorry, Karate (Java) can't resolve these special OS paths. I guess you know that this is not recommended, best practice is all test resources be kept under the project root. Anyway, here is a workaround:
* def home = java.lang.System.getProperty('user.home')
* def temp = read('file:' + home + '/repo/tests/utils/al_dev.json')

Ldap authentication with MoinMoin doesn't work

I'm trying to connect MoinMoin with my ldap server, however it doesn't work. Am I doing the setting in a proper way?
I'm using MoinMoin from the Ubuntu's repository.
Here I show you my farmconfig.py:
from farmconfig import FarmConfig
# now we subclass that config (inherit from it) and change what's different:
class Config(FarmConfig):
# basic options (you normally need to change these)
sitename = u'MyWiki' # [Unicode]
interwikiname = u'MyWiki' # [Unicode]
# name of entry page / front page [Unicode], choose one of those:
# a) if most wiki content is in a single language
#page_front_page = u"MyStartingPage"
# b) if wiki content is maintained in many languages
page_front_page = u"FrontPage"
data_dir = '/usr/share/moin/data'
data_underlay_dir = '/usr/share/moin/underlay'
from MoinMoin.auth.ldap_login import LDAPAuth
ldap_authenticator1 = LDAPAuth(
server_uri='ldap://192.168.1.196',
bind_dn='cn=admin,ou=People,dc=company,dc=com',
bind_pw='secret',
scope=2,
referrals=0,
search_filter='(uid=%(username)s)',
givenname_attribute='givenName',
surname_attribute='sn',
aliasname_attribute='displayName',
email_attribute='mailRoutingAddress',
email_callback=None,
coding='utf-8',
timeout=10,
start_tls=0,
tls_cacertdir=None,
tls_cacertfile=None,
tls_certfile=None,
tls_keyfile=None,
tls_require_cert=0,
bind_once=True,
autocreate=True,
)
auth = [ldap_authenticator1, ]
cookie_lifetime = 1
This is an indentation issue, auth and cookie_lifetime must be within class Config (so just indent all that by 4 spaces).

Scons (Build System) Variables : load config file with custom/unknown values

I have a trouble with Scons.Variables. I want to use config files with custom keys and values. My idea to load config files with keys and values and use it with SubstFile method.
For example (rough code) :
vars = Variables('templateValues.conf')
vars_dict = vars.UnknownVariables().keys() # bad code, need something to convert vars to Python dictionary
env.Substfile('myconfig.cfg.in', SUBST_DICT = vars_dict)
But vars.UnknownVariables() return empty list.
My test template file :
version = 105
mode = 'release'
source = 'database'
emulate = 'no'
And vars.UknownVariables() called :
vars = Variables('templateValues.conf')
print vars.UnknownVariables().keys()
# []
May be somebody try to implement something like this and can give some advances ?
I not found neeeded tools in Scons, but Python is great (i newbie in python now, few days studing only).
Google give me some useful links, such as SimpleConfigParser (i use method from CustomParser)
Implement it is very easy and i got what i need :
Import('env')
templVars = parse_config('template.conf')
varEnv = env.Clone(tools = ['textfile', 'default'])
varEnv.Substfile('config.cfg.in', SUBST_DICT = templVars)
Content of config.cfg.in file :
this is simple text with template values
Version is %version%
Build mode is %mode%
Emulator mode %emulate%
Thanks for using Avina !
Content of template.conf file :
%version% = 105
%mode% = 'test1'
%source% = 'database'
%emulate% = 'no'
And result file :
this is simple text with template values
Version is 105
Build mode is 'test1'
Emulator mode 'no'
Thanks for using Avina !