environment

Remove objects in .GlobalEnv from within a function

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 06:22:23
I would like to create a function ( CleanEnvir ) which basically calls remove/rm and which removes certain objects from .GlobalEnv . CleanEnvir <- function(pattern = "tmp"){ rm(list = ls()[grep("tmp", ls())], envir = globalenv()) } keep <- 1 tmp.to.be.removed <- 0 ls() ## does not work CleanEnvir() ls() ## does work rm(list = ls()[grep("tmp", ls())], envir = globalenv()) ls() ls() needs to look in the correct place. By default it looks in the current frame, that of the function CleanEnvir in your case and hence was only finding "pattern" in your original. CleanEnvir <- function(pattern = "tmp"

How can I set the Windows PATH variable from Perl?

做~自己de王妃 提交于 2019-12-03 05:58:51
I need to set the an environment variable from within Perl. Ideally, I need to query a variable and then change it if it is not what is required. Specifically it is the PATH variable I want to change. How do I get and set these variables? runrig If you need to change environment variables globally and permanently, as if you set it in the control panel, then you have to muck with the registry (update: and now there are modules to do this, Win32::Env and Win32::Env::Path ). Note that changing variables in the registry and "broadcasting" the change will not change the environment variables in

starting rails in test environment

我的未来我决定 提交于 2019-12-03 03:10:02
I'm trying to load up rails in the test environment using a ruby script. I've tried googling a bit and found this recommendation: require "../../config/environment" ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'test' This seems to load up my environment alright, but my development database is still being used. Am I doing something wrong? Here is my database.yml file... however I don't think it is the issue development: adapter: mysql encoding: utf8 reconnect: false database: BrianSite_development pool: 5 username: root password: dev host: localhost # Warning: The database defined as

Setting environment variables with puppet

大兔子大兔子 提交于 2019-12-03 02:39:27
I'm trying to work out the best way to set some environment variables with puppet. I could use exec and just do export VAR=blah . However, that would only last for the current session. I also thought about just adding it onto the end of a file such as bashrc. However then I don't think there is a reliable method to check if it is all ready there; so it would end up getting added with every run of puppet. myitcv I would take a look at this related question . *.sh scripts in /etc/profile.d are read at user-login time (as the post says, at the same time /etc/profile is sourced) Variables export

Laravel 5 app always using 'testing' environment configuration

风格不统一 提交于 2019-12-02 23:29:07
I have a Laravel 5 app with two environments and two configurations: testing (for PHPUnit configuration, in-memory db) and local (my development configuration). Even when the environment is configured to be local , the application only loads the configuration in the resources/config/testing folder. I can see the environment in the same app from the APP_ENV environment variable, and it is local . Should I just not be using a testing configuration directory for configuring my tests? What's a better way to configure my testing environment in Laravel 5? Laravel 5 doesn't cascade config files

Running unit tests with Nose inside a Python environment such as Autodesk Maya?

心已入冬 提交于 2019-12-02 21:17:43
I'd like to start creating unit tests for my Maya scripts. These scripts must be run inside the Maya environment and rely on the maya.cmds module namespace. How can I run Nose tests from inside a running environment such as Maya? Moe Use the mayapy executable included in your maya install instead of the standard python executable. In order for this work you'll need to run nose programmatically. Create a python file called runtests.py and put it next to your test files. In it, include the following code: import os os.environ['PYTHONPATH'] = '/path/to/site-packages' import nose nose.run() Since

How do I switch to older versions of the ruby/rails environment?

ε祈祈猫儿з 提交于 2019-12-02 19:37:31
I'm trying to keep along with the Tekpub Build your own blog on rails screencast. I'm still very much a ruby novice and the problem is that I have Rails 3 installed while Rob uses an older version (Of the top of my head: version 2.3.2). I know how to get that version of rails with gem install rails --version=2.3.2 but when I type rails new the version of the application is rails 3. How do I make this particular app work with the older version? I know this has something to do with rvm but I have no idea how to do anything but the basic rvm use operation. Try, rvm use <ruby version> rvm gemset

mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?

主宰稳场 提交于 2019-12-02 18:24:49
问题 In my local/development environment, the MySQLi query is performing OK. However, when I upload it on my web host environment, I get this error: Fatal error: Call to a member function bind_param() on a non-object in... Here is the code: global $mysqli; $stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?"); $stmt->bind_param('i', $cur_id); $stmt->execute(); $stmt->bind_result($uid, $desc); To check my query, I tried to execute the query via

Get spring application environment in thymeleaf

只愿长相守 提交于 2019-12-02 18:02:15
My Spring Boot application runs with 3 configurations: application.properties --> for development environment application-test.properties --> for test environment application-production.properties --> for production environment How is it possible to get in thymeleaf environment the application is running? I need to include the Google Analytics code only in production environment. You can do the following if you only have one profile active at a time. <div th:if="${@environment.getActiveProfiles()[0] == 'production'}"> This is the production profile - do whatever you want in here </div> The

How can I detect Heroku's environment?

扶醉桌前 提交于 2019-12-02 17:27:13
I have a Django webapp, and I'd like to check if it's running on the Heroku stack (for conditional enabling of debugging, etc.) Is there any simple way to do this? An environment variable, perhaps? I know I can probably also do it the other way around - that is, have it detect if it's running on a developer machine, but that just doesn't "sound right". Neil Middleton An ENV var seems to the most obvious way of doing this. Either look for an ENV var that you know exists, or set your own: on_heroku = False if 'YOUR_ENV_VAR' in os.environ: on_heroku = True more at: http://devcenter.heroku.com