environment

Perl - What scopes/closures/environments are producing this behaviour?

空扰寡人 提交于 2019-11-28 10:22:26
问题 Given a root directory I wish to identify the most shallow parent directory of any .svn directory and pom.xml . To achieve this I defined the following function use File::Find; sub firstDirWithFileUnder { $needle=@_[0]; my $result = 0; sub wanted { print "\twanted->result is '$result'\n"; my $dir = "${File::Find::dir}"; if ($_ eq $needle and ((not $result) or length($dir) < length($result))) { $result=$dir; print "Setting result: '$result'\n"; } } find(\&wanted, @_[1]); print "Result: '

How to set AngularjJS base URL dynamically based on fetched environment variable?

谁都会走 提交于 2019-11-28 10:03:20
I have a development and production environment in which my URL's differ: production: www.exmaple.com/page development: dev.environment/project/page I know that I can set the base URL in AngularJS with the <base href='/project/' /> but that doesn't help me out here. Before I load my AngularJS application I fetch a config file (in app.js, with the .run statement, which reads a variable that has the environment: ]).run([ '$rootScope', '$http', function ( $rootScope, $http ) { var configDeferred = $q.defer(); // fetch config and set the API $http.get('config.json').then(function(response) {

Checking for workstation lock/unlock change with c#

淺唱寂寞╮ 提交于 2019-11-28 09:23:47
DUPLICATE: How can I programmatically determine if my workstation is locked? How can I detect (during runtime) when a Windows user has locked their screen (Windows+L) and unlocked it again. I know I could globally track keyboard input, but is it possible to check such thing with environment variables? You can get this notification via a WM_WTSSESSION_CHANGE message. You must notify Windows that you want to receive these messages via WTSRegisterSessionNotification and unregister with WTSUnRegisterSessionNotification. These posts should be helpful for a C# implementation. http://pinvoke.net

Programmatically adding a directory to Windows PATH environment variable

怎甘沉沦 提交于 2019-11-28 08:24:44
I'm writing a Win32 DLL with a function that adds a directory to the Windows PATH environment variable (to be used in an installer). Looking at the environment variables in Regedit or the Control Panel after the DLL has run shows me that my DLL has succeeded in adding the path to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKEY_CURRENT_USER\Environment . But when I start up a new Command Prompt (after running the DLL), the directory I added does not show up in the output of echo %PATH% and I can not access the executable that lives in that directory by

PS1 line-wrapping with colours problem

余生长醉 提交于 2019-11-28 05:18:43
Here's my PS1 variable: PS1='\u:\W$(__git_ps1 "\e[32m\][%s]\e[0m\]")$ ' Works great for picking up my Git branch, but it has the unfortunate side-effect of wrapping the lines when the colours are active, so that they overlap when you use long commands. Can anyone with magic PS1 skills help me out to fix this? Got it, needed to escape the colours properly. Fix: PS1='\u:\W$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]")$ ' May I suggest the following method for colors in Bash, it makes the code much more readable and alot harder for you to miss an escape or two. Put the following in your ~/.bashrc BLACK=$

Windows 7 environment variable not working in path

十年热恋 提交于 2019-11-28 04:29:31
I am trying to set up some path using environment variable. I added an environment variable "MAVEN_HOME" with the value "C:\maven". Then in the path I added "%MAVEN_HOME%\bin;...rest". When I type "echo $MAVEN_HOME%" I get the correct "C:\maven" printed on the screen. But when I type "mvn" which is a batch file in the "bin" directory, it can't find it. So, I manually added the entire path in PATH. "C:\maven\bin;...rest" and it was able to find "mvn" and execute it. Could someone help me what I did wrong? pcmind I had exactly the same problem, to solve it, you can do one of two things: Put all

Verify object existence inside a function in R [duplicate]

本小妞迷上赌 提交于 2019-11-28 04:27:17
问题 This question already has an answer here: How to check if object (variable) is defined in R? 6 answers I want to determine whether an object exists inside a function in R: foo <- function() { y <- "hello" if (exists(y, envir = sys.frame())) print(y) } foo() Error in exists(y, envir = sys.frame()) : invalid first argument I thought adding the envir = sys.frame() would do the trick. Also tried envir = environment() Expected foo() "hello" 回答1: You should have checked ?exists : Usage: exists(x,

Installing Gems without rvm, as root, with explicit version of ruby

ぐ巨炮叔叔 提交于 2019-11-28 02:19:29
问题 I've decided to get rid of rvm, and I'm having trouble compiling a gem with my new version of ruby 1.9.2. The gem requires 1.9.2, I have it, yet says it can't install without, so the error messages makes no sense. How can I explicitly tell the gem to compile with said version of ruby? Gem::InstallError: linecache19 requires Ruby version >= 1.9.2. An error occured while installing linecache19 (0.5.12), and Bundler cannot continue. Make sure that `gem install linecache19 -v '0.5.12'` succeeds

Shell out from ruby while setting an environment variable

佐手、 提交于 2019-11-28 00:41:21
I need to shell out to a process while setting an environment variable for it. I tried this one-liner: system "RBENV_VERSION=system ruby extconf.rb" This syntax works in shell script but not from ruby. ( Update: turns out this syntax works from ruby after all, but I failed to see its effect due to my particular use-case.) So I'm doing this: rbenv_version = ENV['RBENV_VERSION'] ENV['RBENV_VERSION'] = 'system' begin system "ruby extconf.rb" ensure ENV['RBENV_VERSION'] = rbenv_version end I'm forced to such a long expression because I don't want to override the environment variable permanently if

How to use git to manage one codebase but have different environments

…衆ロ難τιáo~ 提交于 2019-11-28 00:35:10
问题 I'm using git for a personal project at the moment and have run into a problem of having one codebase for two different environments and was wondering what the cleanest way to use git would be. Main Desktop I Use this machine for most of my development. I have a git repository here that I cloned off of an empty repository that I use on my internal server. I do most of my work here and push back to the internal server so I can use that as a master of truth and to ease making backups. Laptop I