How to find the path of the local git repository when I am possibly in a subdirectory [duplicate]

git rev-parse –show-toplevel could be enough if executed within a git repo. From git rev-parse man page: –show-toplevel Show the absolute path of the top-level directory. For older versions (before 1.7.x), the other options are listed in “Is there a way to get the git root directory in one command?”: git rev-parse –git-dir That would … Read more

What is the difference between parent.frame() and parent.env() in R; how do they differ in call by reference?

parent.env is the environment in which a closure (e.g., function) is defined. parent.frame is the environment from which the closure was invoked. f = function() c(f=environment(), defined_in=parent.env(environment()), called_from=parent.frame()) g = function() c(g=environment(), f()) and then > g() $g <environment: 0x14060e8> $f <environment: 0x1405f28> $defined_in <environment: R_GlobalEnv> $called_from <environment: 0x14060e8> I’m not sure when a mere … Read more

Best way to create custom config options for my Rails app?

For general application configuration that doesn’t need to be stored in a database table, I like to create a config.yml file within the config directory. For your example, it might look like this: defaults: &defaults audiocast_uri_format: http://blablalba/blabbitybla/yadda development: <<: *defaults test: <<: *defaults production: <<: *defaults This configuration file gets loaded from a custom initializer … Read more

Can you get DB username, pw, database name in Rails?

From within rails you can create a configuration object and obtain the necessary information from it: config = Rails.configuration.database_configuration host = config[Rails.env][“host”] database = config[Rails.env][“database”] username = config[Rails.env][“username”] password = config[Rails.env][“password”] See the documentation for Rails::Configuration for details. This just uses YAML::load to load the configuration from the database configuration file (database.yml) which you can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)