Questions tagged [global]

Refers to a space where variables and other items may be accessed from any scope.

4669 questions
1233
votes
13 answers

Global Git ignore

I want to set up Git to globally ignore certain files. I have added a .gitignore file to my home directory (/Users/me/) and I have added the following line to it: *.tmproj But it is not ignoring this type of files, any idea what I am doing wrong?
Mild Fuzz
  • 29,463
  • 31
  • 100
  • 148
464
votes
10 answers

What does "nonlocal" do in Python 3?

What does nonlocal do in Python 3.x? To close debugging questions where OP needs nonlocal and doesn't realize it, please use Is it possible to modify variable in python that is in outer, but not global, scope? instead. Although Python 2 is…
ooboo
  • 16,259
  • 13
  • 37
  • 32
320
votes
10 answers

Using global variables between files?

I'm bit confused about how the global variables work. I have a large project, with around 50 files, and I need to define global variables for all those files. What I did was define them in my projects main.py file, as following: #…
user1632861
235
votes
13 answers

Ruby on Rails: Where to define global constants?

I'm just getting started with my first Ruby on Rails webapp. I've got a bunch of different models, views, controllers, and so on. I'm wanting to find a good place to stick definitions of truly global constants, that apply across my whole app. In…
AlexC
  • 3,610
  • 3
  • 26
  • 26
201
votes
3 answers

Augmentations for the global scope can only be directly nested in external modules or ambient module declarations(2669)

I would like to store my NodeJS config in the global scope. I tried to follow this => Extending TypeScript Global object in node.js and other solution on stackoverflow, I made a file called global.d.ts where I have the following code declare…
Bobby
  • 4,372
  • 8
  • 47
  • 103
200
votes
10 answers

How to declare a global variable in php?

I have code something like this:
LIGHT
  • 5,604
  • 10
  • 35
  • 78
192
votes
5 answers

Can I make a function available in every controller in angular?

If I have a utility function foo that I want to be able to call from anywhere inside of my ng-app declaration. Is there someway I can make it globally accessible in my module setup or do I need to add it to the scope in every controller?
Ludwig Magnusson
  • 13,964
  • 10
  • 38
  • 53
181
votes
3 answers

What happens to global and static variables in a shared library when it is dynamically linked?

I'm trying to understand what happens when modules with globals and static variables are dynamically linked to an application. By modules, I mean each project in a solution (I work a lot with visual studio!). These modules are either built into…
Raja
  • 2,846
  • 5
  • 19
  • 28
155
votes
9 answers

Global variables in Javascript across multiple files

A bunch of my JavaScript code is in an external file called helpers.js. Inside the HTML that calls this JavaScript code I find myself in need of knowing if a certain function from helpers.js has been called. I have attempted to create a global…
Goro
  • 9,919
  • 22
  • 74
  • 108
154
votes
2 answers

Global variables in Javascript and ESLint

I have got multiple javascript files and I have defined some global variable in a file which loads before the others. As a consequence all of the files loaded after the first have access to the global variable. However ESLint shows the global…
marco_sap
  • 1,739
  • 2
  • 12
  • 12
129
votes
12 answers

How to make a cross-module variable?

The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it? The variable (let's be original and call it 'foo') doesn't have to be truly global, in the…
Dan Homerick
  • 4,118
  • 7
  • 28
  • 30
127
votes
2 answers

Find and replace globally in Sublime Text 2 (all files and in all directories)

Is there a way to find and replace a text string automatically in all folder's files?
itsme
  • 48,972
  • 96
  • 224
  • 345
111
votes
11 answers

Where to store global constants in an iOS application?

Most of the models in my iOS app query a web server. I would like to have a configuration file storing the base URL of the server. It will look something like this: // production // static NSString* const baseUrl = "http://website.example/" //…
JoJo
  • 19,587
  • 34
  • 106
  • 162
106
votes
7 answers

What is the 'global' object in NodeJS

I've just seen a weird behaviour of the this keyword in NodeJS environment. I'm listing them with code. I've run this code with NodeJS v6.x, with a single JavaScript file. While testing with one line of code as follows, whether with or without the…
Arnab Das
  • 3,548
  • 8
  • 31
  • 43
104
votes
10 answers

Extending TypeScript Global object in node.js

I have a node.js app that attaches some config information to the global object: global.myConfig = { a: 1, b: 2 } The TypeScript compiler doesn't like this because the Global type has no object named myConfig: TS2339: Property 'myConfig'…
d512
  • 32,267
  • 28
  • 81
  • 107
1
2 3
99 100