Questions tagged [scope]

In computer programming, the scope of an identifier is the part of a computer program where the identifier, a name that refers to some entity in the program, can be used to find the referred entity.

Filter by
Sorted by
Tagged with
2
votes
0answers
76 views

Create an isolated dependency scope with “overrides” in Asp.Net Core

Some of the classes in my multi-tenant Asp.Net Core application depend on database repositories which in turn depend on a delegate called GetCurrentTenantKey. In ...
1
vote
1answer
84 views

Importing modules for private use in Python [closed]

There's something I completely dislike when importing a module in an interactive Python shell, typing the name of the module, hitting tab and getting the automatic completion cluttered with other ...
3
votes
2answers
56 views

Storing statistics as JSON in a simulation game

I am working on a choice-based simulation and players have to choose between different locations, I am pushing those choices to an array locationLog and my ...
1
vote
1answer
101 views

Manager-class for turn-based browser game, OOP

I have been developing a game project (hobby) for the last 2 to 3 years. The game is using JS on the frontend and PHP on the backend. The game is turn-based and each turn is divided into 4 phases and ...
2
votes
0answers
274 views

Memory release after joblib.Parallel [python]

Stuck with the issue with memory consumption - after running joblib's Parallel, deleting results and gc.collect() -ing I still have increased memory (checking by htop for process line). Found no way ...
4
votes
0answers
141 views

See the Progress of the Powershell Jobs you are running

This code allows you monitor the progress of the Powershell Jobs you just started. One of the key features is the ability to stop the other Jobs when 1 is failed. For example, if you are running some ...
7
votes
1answer
784 views

Mimic C#'s nameof() in Python

I rewrote some code I posted earlier this month. It attempts to mimic C#'s nameof() by extracting names from bytecode instructions. This seems more reliable than ...
3
votes
3answers
1k views

SCOPE_EXIT implementation

I'm a fanboy of the Boost library and I've used Boost's components extensively in my C++03 project. The team decided to merge several pieces of code including my project. I will get the C++14 ...
3
votes
2answers
438 views

scope_exit macro

This is actually not something new, but I think many people wanted something useful and not incredibly complicated. So, here it is: ...
0
votes
1answer
5k views

Accessing parent scope from directive

This is how I can access the exact scope value, otherwise it will be $scope.type of local scope. I am accessing this from the template in ...
2
votes
0answers
129 views

“Multi” scope guard using template argument deducing feature

Using modern C++ feature template argument deduction for class templates and folding expressions it is possible to implement "multi" scope guard utility, which have right order of functor calls: <...
1
vote
0answers
36 views

Fake closure to provide variable scoping in SASS

For some time I've wanted a way to provide private scope to variables, functions, etc. that needed to be used across multiple separate selections. As far as I'm aware there is no official solution for ...
4
votes
0answers
87 views

Angular controller scope inheritance vs service

On my site I have a navbar component that I want to customize for each and every ng-view I end up loading. Currently I'm doing ...
1
vote
0answers
52 views

Eloquent Scope and Normal Way

I read the documentation part of Eloquent, especially scopes: Scopes allow you to easily re-use query logic in your models. To define a scope, simply prefix a model method with scope: And so, with ...
1
vote
1answer
868 views

Caching DOM-queries

I've been optimizing my code and I always tend to cache common selectors like this (jQ): ...
6
votes
3answers
779 views

Nested loop to render tiles in a grid

This code works but I'm not really sure if I wrote it good enough. It seems a bit vague but I can't really assess it properly. I'm particularly concerned with the ...
1
vote
2answers
671 views

Using a dependency container to load a parent/child class

In PHP, I have a parent/child class and am using dependency container to load them. I am trying to use the same database connection on all of them without duplicating the object. I used ...
3
votes
2answers
4k views

Accessing a global list [closed]

I'm sort of at a loss for what to do with webapps and whether what I'm doing is actually allowed or not. Here is a sample of the type of thing I'm doing at the moment. I need a list that is accessible ...
3
votes
4answers
2k views

Summing up distinct elements in steps

My current task is to find a score from an array where the highest/lowest scores have been taken away, and if the highest/lowest occur more than once (ONLY if they occur more than once), one of them ...
7
votes
2answers
218 views

Conway's Game of Life - Conventional JavaScript?

I'm using the Game of Life Kata to help me learn JavaScript. I've picked up the syntax through Codecademy tutorials, but my current skill level is Novice. The example code has working functionality ...
9
votes
2answers
13k views

Handling signals in Python inside a function

I have code that needs to exit gracefully. To simplify things, I am presenting an example based on the answer given here. Since I need to handle a few signals, I thought of putting this logic in a ...
5
votes
1answer
298 views

Communicating between plugins whilst maintaining context in Javascript

I'm making some changes to a JavaScript plugin on a site I've been made steward over. This main plugin has it's own sub-plugins and I'm trying to make certain aspects modular. Currently, I'm ...
8
votes
2answers
160 views

Advice needed for scopes in JavaScript

I would like to connect this "JS" to Bugzilla (example: bugzilla.mozilla.org or landfill.bugzilla.org). I started to learn JS language today and I would like to ask you: How can I not do bad things ...
1
vote
1answer
181 views
-1
votes
1answer
72 views

Is declaring a property as `public` insecure?

I posted a question few weeks back, on making a PHP Login Script. Most of you guys told me not to use global variables and especially for something like MySQLi ...