Questions tagged [variables]

23893 questions
1

votes
1

answer
198

Views

Inverting colors with CSS Variables

I want to create a local inverted theme (modern browsers). Color shades are set using CSS Vars (CSS custom properties). Some elements have more contrast, others are low contrast. Now the inverted container has a black background. Everything within there, should be reversed. Dark grey should be light...
Frank Lämmer
1

votes
3

answer
2.5k

Views

Cypress How to store global constants in a file that can be used across all spec files?

I'm looking for a way to store global constants in a file that could be used across all my spec files. Can anyone help?
Ryan Parker
1

votes
1

answer
205

Views

Securing .env parameters in react project

I'm new to React and js worlds, I'm trying to create production build of my application This application has some env parameters (api keys, secrets, etc.) living in .env.production file, when I run yarn build I get /build folder, especially main.js file, where all of my 'secure' env parameters expos...
Generwp
1

votes
2

answer
355

Views

Use jq to parse json into environment variable format

I would like to below code to output KNOCK_KNOCK='Who is there?' TEST_FILE='{ 'KNOCK_KNOCK': 'Who is there?' }' for s in $(echo $TEST_FILE | jq -r 'to_entries|map(\'\ (.key)=\(.value|tostring)\')|.[]' ); do echo $s done I got the loop from this post: Exporting JSON to environment variables and cann...
George R Malary
1

votes
2

answer
278

Views

Can't access variable key inside .env (dotenv package React)

So I'm trying to understand how to use .env to secure my api key & data for my login auth. I've followed the process of the dotenv package and the stackoverflow answer here. What I did: 1. I installed the dotenv package 2. In my rootfolder, I added a .env with only one line: API_AUTH=http://myapilin...
Cédric Bloem
0

votes
1

answer
11

Views

Replacing an if statement's condition character with a variable

This is probably an easy one. In R, can I replace an if condition character (such as >) with a character and execute the if statement with it? For example, if the if statement is: ifelse(1 < 2, 'T', 'F') But I'm getting the > condition character through a variable: cc
dan
1

votes
3

answer
46

Views

How do I loop through column names to compute statistics?

say I have data that looks like this rating repair model 5 0 1 4 0 0 2 1 1 5 1 0 I want to be able to find the mean of rating for every time repair ==1. However I actually have 200 column names I want to do this for that do not follow a specifi...
Megan
1

votes
2

answer
45

Views

nvcc warns about a device variable being a host variable - why?

I've been reading in the CUDA Programming Guide about template functions and is something like this working? #include /* host struct */ template struct Test { T *val; int size; }; /* struct device */ template __device__ Test *d_test; /* test function */ template T __device__ testfunc() { retur...
Herzog Igzorn
1

votes
3

answer
41

Views

How to resolve user environment variables in filepath

Golang on windows. Trying to use os.Open('%userprofile%\\myfile.txt') Getting file path not found and golang is not resolving %userprofile% to my C:\users\myusername folder.
user3051040
1

votes
2

answer
36

Views

How to pass string as column name in R [duplicate]

This question already has an answer here: How to call an object with the character variable of the same name 1 answer Dynamically select data frame columns using $ and a vector of column names 8 answers m ='jan' n = '5e' r = paste0('jan','5e','_results') 'jan5e_results' Now I want to use r's val...
noob
1

votes
1

answer
36

Views

how PHP global keyword work inside function using scope? [duplicate]

This question already has an answer here: Reference: What is variable scope, which variables are accessible from where and what are “undefined variable” errors? 3 answers i have written this code and I got the point of its first function. I was practicing while looking at this screenshot from w...
suryavansh
1

votes
3

answer
38

Views

Can I unpack variables in order to check their membership in another list?

I would like to know if I have a list of integers, then can I unpack them to check if they are present in another list or must I do it manually? I know there are built in functions like any() and all() but I am wondering if we can unpack variables during a membership test. list1 = [1,2,3,4,5,6,7,8,9...
Mohamed Motaz
1

votes
3

answer
40

Views

How to move multiple variables from a function into the global scope?

I'm new to python and I'm working on creating a monopoly like game and am working on the settings aspect of the program and I have a function that asks the user what they want to put in for each setting I am then using another function to import those settings to a text file so they can be stored fo...
warherolion
1

votes
2

answer
29

Views

sed using dollar sign for both environment variable and end-of-line pattern matching [duplicate]

This question already has an answer here: Using dollar sign in sed for both variable replacement and character 3 answers In sed, we use double quotes to read environment variable indicated by a dollar sign, what should i do if I want to use the dollar sign for end-of-line pattern at the same time?...
once
1

votes
3

answer
48

Views

instantiation of variables in body of lambda

I write all the rules of lambda expression, but I have a doubt about it. When to use lambda A lamda expression is used only to override an abstract method of a functional interface. Not to override methods of concrete classes, abstract classes or not functional interfaces. Infact in all these cases...
Adryr83
1

votes
2

answer
43

Views

static uint8_t variable changes to incorrect value when using += on Mac

I had a colleague today ask me a question regarding his code that I could not answer. He is writing a C unit test on Mac that makes use of a static uint8_t variable (initialized to 0) for holding the current read position from a test buffer across invocations of a seemingly simple read function in t...
Michael Cress
1

votes
2

answer
42

Views

Use a jq range variable to feed into a new jq filter

I have some JSON that looks like this: { 'vertices': [ { 'id': 71597, 'ns': 'ca', 'alias': 'polarized' }, { 'id': 129748, 'ns': 'av', 'name': 'Polarized' }, { 'id': 129898, 'ns': 'av', 'name': 'False' } ], 'edgeGroups': { 'hasAttributeValue': [ [ 0, 1 ], [ 0, 2 ] ] } } The various entries in .vertic...
antun
1

votes
3

answer
635

Views

Select flyspell via a variable in a file

Question: How can i select flyspell automatically by an EMACS Variable in my file (not via the .emacs configuration file!), just for that file, similar like I select the ispell dictionary just for that file EXAMPLE abc.tex: ---SNIP--- text text .. text text .. ---SNIP--- Second Question: How can I...
user1165430
1

votes
1

answer
2.7k

Views

How do I create a session variable in Python?

I use Python 3 as a serverside scripting language, and I want a way to keep users logged into my site. I don't use any framework, since I prefer to hand code pages, so how do I create session variables like in PHP in Python 3?
Orcris
0

votes
1

answer
22

Views

Problem to compare a variable with a .get()

I have a problem I don't know how to compare a variable with a .get() of a Entry so what is the problem ? I'm a newbie of python and i'm french My code: from tkinter import * from random import * from tkinter.messagebox import * liste = ['A TI TA', 'B TA TI TI TI', 'C TA TI TA TI', 'D TA TI TI', 'E...
ZeEleveZozo
0

votes
0

answer
2

Views

Can tensorflow Session.run() return memory address to variable rather than a copy

I'm using TensorFlow to train a deep neural network. Python interacts with TensorFlow via Session, which outputs the results. In my case, I want to return the weights of my network, use them to process my data externally (i.e. outside tensorflow), and then pass the weights back to tensorflow to upd...
python_freak
0

votes
0

answer
26

Views

how to get local variables of a method from another class

I have two classes A and B A class contains a method which has some of the local variables. now I want to fetch their name and data type in the B class. can you please help me with this. I researched about java reflection. but I found that I can not achieve this by using reflection, as local variab...
Shweta
-3

votes
2

answer
33

Views

How do I include a var inside a var using {}

I have: var lineArea = new Chartist.Line('#line-area', { labels: ['a', 'b', 'c', 'd'], ~break I have to replace the abcd with a var: var mondays = document.getElementById('mondays').innerHTML; alert(mondays); var lineArea = new Chartist.Line('#line-area', { labels: [{mondays}], series: [ [0, 20...
sukebe7
1

votes
1

answer
9.2k

Views

Destroy PHP Sessions on Browsers Tab Close

i am stucked, i am working on Projects hotbartendersla i have used a lot of sessions to process data in event booking, now i want to destroy the session when user closed the window/tab of browser,because when ever i open site the selection remains same as i did. i have used this window.onbeforeunlo...
Engr Zardari
-1

votes
3

answer
21

Views

How does a variable refer to the same variable in vba?

total beginner here. I have a hard time understanding the following code, or any code that operates the same variable. For example: Private Sub CommandButton1_Click() Dim i As Long For i = 1 To 3 i = i + 1 Next i MsgBox (i) End Sub Why does this return 5?
Ilan S
1

votes
2

answer
177

Views

why can't we have capital letters in tuple variable declaration in scala

Why can't we have Capital letter in a tuple variable, As I create a TestData it throws an error val (trainingData, TestData): Tuple2[RDD[LabeledPoint],RDD[LabeledPoint]] = (splits(0), splits(1))
wctapasadan
1

votes
2

answer
408

Views

How to declare a global variable and access it in all the other modules in ReactJS?

Being new to ReactJS, I wanted help with the global variable declaration and usage. The scenario is that I have different modules and I want to access a variable which is available in all the modules, irrespective of their relations. To be precise, I have an admin panel and a user dashboard which ha...
Miral Kumbhani
1

votes
1

answer
133

Views

How to access a variable that was created in a transaction?

I'm using rails 4.2 I have two db calls that both need to exist OR both not exist, so I'm using transactions inside a method in order to do that. I also want the variable I am creating to be accessible by other places in the same method. Do I just need to use an instance variable instead of a local...
James Herd
1

votes
1

answer
50

Views

Python - Variable Name Not Defined

This is my (shortened) code. race1names = ['Jeff', 'Paul', 'Mark'] race1odds = [5, 6, 7] class Horse: def __init__(self, name, odds, age, weight): self.name = name self.odds = odds self.age = age self.weight = weight def Horsecreate(): hcount = 0 horse = {} while hcount < 3: cname = race1names[hcoun...
O.Woodman
1

votes
3

answer
52

Views

Python don't modify values while iterating over a list with zip(), but does it while with enumerate()

Why Python works differently when iterating using index numbers? For example with the zip function (that don't has indexes when used in the for loop) a value isn't stored in a variable. While with the enumerate() function (that allow me to have an 'index' in the foor loop) it happens normally. A s...
Gabz
1

votes
3

answer
31

Views

How to create an array in constructor that will be used later

I am making a Matrix class and want to make the constructor input the Matrix type too. How can I initialize a specific type 2d array? public class Matrix { public int[][] matrix; //?? Matrix(int x,int y,string type) { switch (type) { case 'int': //initialize a int 2d array case 'double': //initializ...
Clement Hui
1

votes
1

answer
32

Views

Can Cmd determine path location of a .exe or other file type?

I think the best way to ask my question is by giving an example. This is a question about environmental/user variables. I am using windows system. I have the environmental variable: C:\Program Files\Anaconda3\Scripts I have a file: C:\Program Files\Anaconda3\Scripts\conda.exe typing 'conda' into cmd...
JimmyWilliams
1

votes
3

answer
59

Views

Getting the object variable name for the new object

I have an object constructor such as: function myObjConstr () { console.log(object_name); } I want this results: var name1 = new myObjConstr(); //print in console log 'name1' var nameff = new myObjConstr(); //print in console log 'nameff'
Mostafa Maher
1

votes
3

answer
40

Views

Why function works when declaring variable globally but not with var

I would like to declare the property soundFileName as var soundFileName = 'audio/60.wav'; so that soundFileName isn't defined globally, but when I do I get ReferenceError: soundFileName is not defined. I am passing the value of soundFileName as a parameter to loop(soundFileName), and I would think...
forestkelley
1

votes
4

answer
49

Views

Why do I need to cast from double to int, but not vice versa?

Let's say I have a double and an int. double x = 5; int y = x; When I do this, it throws an error because I need to explicitly cast from double to int like this, int y = (int) x; for it to work. But when I do int x = 5; double y = x; No error is thrown, and it works perfectly fine. Is there any reas...
bob larry
1

votes
2

answer
33

Views

Variable globally scoped but why function unable to access?

Why execution failed at first console log despite globally scoped variable exist? const message = 'starts with mssg #1'; //Global scope function scopeTest() { console.log('1. test #1: ', message); //
bg27
1

votes
4

answer
49

Views

SQL select statement PHP store dynamic multiline result into variable and convert into string for sending in an email

I need to send a summary of a table select in an email. /* Table name: comments username comment language date -------------------------------------------------------- Daniel I am Daniel. en 2019-05-01 Michael I am Michael! de 2019-05-04 S...
DanielM
1

votes
2

answer
41

Views

How to set environment variable can access anytime using powershell?

I have text file with this format 12345 . I want to set that value as environment variable that I can access it even the powershell closed. My expectation when I want to access that environment variable from command line, I just use this command : echo %ID% and I t will show 12345 $file = Get-Conte...
Job
0

votes
2

answer
32

Views

Variables in custom python module

I am making my own custom python module called zoro, and I want to enable people making a variable, and the variable is equal to a function in my module, but how do I make that? I've already tried looking in to the code of other modules like turtle, and turtle used the self argument, so I tried to u...
BE Official
0

votes
2

answer
14

Views

Assign cell values base don Range variable

I currently have code that copies values from several ranges, and pastes those values into other ranges. The scope of this project is constantly changing, so the ranges need to be changed in my VBA code every time a row or column is added. I'm trying to streamline this by creating Global range varia...
Alex D

View additional questions