flags

PowerShell mandatory parameter depends on another parameter

那年仲夏 提交于 2019-11-29 05:44:06
I have a PowerShell function which changes the registry key values. Code: param( [Parameter()] [switch]$CreateNewChild, [Parameter(Mandatory=$true)] [string]$PropertyType ) It has a parameter, "CreateNewChild", and if that flag is set, the function will create the key property, even if it wasn't found. The parameter "PropertyType" must be mandatory, but only if "CreateNewChild" flag has been set. The question is, how do I make a parameter mandatory, but only if another parameter has been specified? OK, I've been playing around with it. And this does work: param( [Parameter(ParameterSetName=

Why do the INC and DEC instructions *not* affect the Carry Flag (CF)?

旧街凉风 提交于 2019-11-28 23:16:18
Why do the x86 instruction INC (increment) and DEC (decrement) not affect the CF (carry flag) in FLAGSREGISTER? Ira Baxter To understand why you probably need to remember the current "x86" CPUs with 32 and 64 bit values started life as much more limited 8-bit machines, going back to the Intel 8008. (I coded in this world back in 1973, I still remember (ugh) it!). In that world, registers were precious and small. You need INC / DEC for various purposes, the most common being loop control. Many loops involved doing "multi-precision arithmetic" (e.g, 16 bits or more!) By having INC / DEC set the

Removing Strikethrough from TextView

*爱你&永不变心* 提交于 2019-11-28 22:31:51
I'm using this line below in order to set a strikethrough on my TextView: tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); However later on in the Fragment, if they click the TextView again, I would like the strikethrough to be removed. What line of code can I use to simply make the TextView display the text in the normal format again? Thanks in advance! I ended up finding this online: tv.setPaintFlags(tv.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG)); This successfully removes the strikethrough and therefore I called this in my OnListItemClick method after carrying out

Enum.HasFlag, why no Enum.SetFlag?

有些话、适合烂在心里 提交于 2019-11-28 19:50:50
问题 I have to build an extension method for each flag type I declare, like so: public static EventMessageScope SetFlag(this EventMessageScope flags, EventMessageScope flag, bool value) { if (value) flags |= flag; else flags &= ~flag; return flags; } Why isn't there an Enum.SetFlag like there is an Enum.HasFlag ? Also, why does this not work always? public static bool Get(this EventMessageScope flags, EventMessageScope flag) { return ((flags & flag) != 0); } For example, if I have: var flag =

How to disable a log.Logger

南楼画角 提交于 2019-11-28 18:30:10
问题 I have some heavily instrumented code that makes use of the log package. Now it's come time to turn off the logging, and I can't determine how to turn off the standard logger. Have I missed something? Should I be checking a flag before making log calls, or commenting them out in production? 回答1: For completely disabling logs, it's actually better to call log.SetFlags(0) Joril and set the output to a no-op io.Writer (i.e., log.SetOutput(ioutil.Discard) ) But even after this, the operations

Bash if statement with multiple conditions throws an error

眉间皱痕 提交于 2019-11-28 15:20:08
I'm trying to write a script that will check two error flags, and in case one flag (or both) are changed it'll echo-- error happened. My script: my_error_flag=0 my_error_flag_o=0 do something..... if [[ "$my_error_flag"=="1" || "$my_error_flag_o"=="2" ] || [ "$my_error_flag"="1" && "$my_error_flag_o"="2" ]]; then echo "$my_error_flag" else echo "no flag" fi Basically, it should be, something along: if ((a=1 or b=2) or (a=1 and b=2)) then display error else no error fi The error I get is: line 26: conditional binary operator expected line 26: syntax error near `]' line 26: `if [[ "$my_error

Do java flags Xms and Xmx overwrite flag XX:+UseCGroupMemoryLimitForHeap?

情到浓时终转凉″ 提交于 2019-11-28 08:09:10
问题 I'm running a containerized java application in Kubernetes. In order to make the jvm reserve memory according to the container specifications, the flags -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap must be set. If both those flags are set along with Xms and Xmx flags, what would the behavior of the jvm be? Do one flag overwrite the other? For example, if we had java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xms -Xms2500M -Xmx2500M -jar myjar.jar

How to create global variable in Swift?

大憨熊 提交于 2019-11-28 07:46:04
I am trying to set a global variable. In my case, just a boolean flag that indicates if a view is being presented for the first time: var initialLoadFlag: Bool = true After the view is presented, I want to set this flag to false: var initialLoadFlag: Bool = false And then check for it thenceforth: if initialLoadFlag { showWelcomeMessage() } So, I would like to create initialLoadFlag as a global variable. Where and how? I've tried: In the viewDidLoad area of my view controller In the application() method in my AppDelegate.swift file In the AppDelegate class No luck. I'm getting a Use of

What are the gcc predefined macros for the compiler's version number?

时间秒杀一切 提交于 2019-11-28 06:49:09
I have run into a bug with gcc v3.4.4 and which to put an #ifdef in my code to work around the bug for only that version of the compiler. What are the GCC compiler preprocessor predefined macros to detect the version number of the compiler? DigitalRoss From the gnu cpp manual... __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ These macros are defined by all GNU compilers that use the C preprocessor: C, C++, Objective-C and Fortran. Their values are the major version, minor version, and patch level of the compiler, as integer constants. For example, GCC 3.2.1 will define __GNUC__ to 3, __GNUC_MINOR

CMAKE - setting compile flags for libraries

≯℡__Kan透↙ 提交于 2019-11-28 05:48:17
问题 I have a CMakeLists.txt script to compile my libraries. The problem is I cannot set the compile flags for the libraries. I've tried SET(CMAKE_CXX_FLAGS "/W3 /nologo /EHsc") SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG") SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG") SET(CMAKE_C_FLAGS "/W3 /nologo /EHsc") SET(CMAKE_C_FLAGS_DEBUG "/MTd /Od /Ob0 /Zi /RTC1 /DDEBUG /D_DEBUG") SET(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG") SET(CMAKE_EXE_LINKER_FLAGS "/W3 /nologo