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
2 answers

Display element in a grid and conditionally add to redux or remove if not selected

I have some logic on my JSX for an element in a grid, if element is selected, then add to redux, if element is not selected then remove from redux... is working ok, but I sense a bad smell... ...
manuelBetancurt's user avatar
2 votes
1 answer

Retrieving unspecified function arguments from external context (scope)

The Problem I have a module with several sibling classes that share a method with a similar name. These methods receive the same basic arguments, however, for a number of the sibling classes the ...
Greenstick's user avatar
5 votes
3 answers

Wrap a js function with a fixed this arg

If I use node.addEventListener('click',Wyg.Editor.nodeClickedEvent); then when node is clicked, ...
Reed's user avatar
  • 239
1 vote
0 answers

Polling an SFTP server to list files in a directory

When is it better to instantiate the sftp client globally vs inside a function as shown below? What considerations favor one method over the other? For a long ...
trivial_tasks's user avatar
4 votes
1 answer

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 ...
John Knoop's user avatar
1 vote
1 answer

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 ...
fortran's user avatar
  • 137
3 votes
2 answers

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 ...
comphonia's user avatar
  • 133
3 votes
0 answers

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 ...
Nikolay's user avatar
  • 31
3 votes
3 answers

Bool function in PHP to check if you run the script inside docker

I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After some research I found a solution that people check some processes via ...
Matt Komarnicki's user avatar
5 votes
0 answers

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 ...
SteloNLD's user avatar
  • 151
1 vote
1 answer

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 ...
user431806's user avatar
12 votes
1 answer

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 ...
user avatar
4 votes
3 answers

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 ...
Byoungchan Lee's user avatar
3 votes
2 answers

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: ...
Incomputable's user avatar
  • 9,259
2 votes
0 answers

"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 ...
Tomilov Anatoliy's user avatar
4 votes
0 answers

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 ...
battle2048's user avatar
0 votes
1 answer

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 ...
vickk's user avatar
  • 11
1 vote
1 answer

Caching DOM-queries

I've been optimizing my code and I always tend to cache common selectors like this (jQ): ...
Tommie's user avatar
  • 131
6 votes
3 answers

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 ...
JustAnEuropean's user avatar
3 votes
4 answers

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 ...
user3496101's user avatar
9 votes
2 answers

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 ...
oz123's user avatar
  • 497
5 votes
1 answer

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 ...
tr3online's user avatar
  • 153
7 votes
2 answers

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 ...
doughgle's user avatar
  • 619
8 votes
2 answers

Advice needed for scopes in JavaScript

I would like to connect this "JS" to Bugzilla (example: or I started to learn JS language today and I would like to ask you: How can I not do bad things ...
dmgl's user avatar
  • 183
1 vote
1 answer

Order and visibility tracking algorithm (e.g. scope visibility)

I have a tree of objects. ...
dtech's user avatar
  • 161
3 votes
2 answers

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 ...
Tadgh's user avatar
  • 195
1 vote
2 answers

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 ...
Brian Patterson's user avatar
-1 votes
1 answer

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 ...
ShuklaSannidhya's user avatar