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
35 views

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
52 views

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
409 views

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
681 views

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
747 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 ...
John Knoop's user avatar
1 vote
1 answer
844 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 ...
fortran's user avatar
  • 137
3 votes
2 answers
79 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 ...
comphonia's user avatar
  • 133
3 votes
0 answers
978 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 ...
Nikolay's user avatar
  • 31
3 votes
3 answers
697 views

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
1k 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 ...
SteloNLD's user avatar
  • 151
1 vote
1 answer
184 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 ...
user431806's user avatar
12 votes
1 answer
4k 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 ...
user avatar
4 votes
3 answers
4k 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 ...
Byoungchan Lee's user avatar
3 votes
2 answers
970 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: ...
Incomputable's user avatar
  • 9,259
2 votes
0 answers
140 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 ...
Tomilov Anatoliy's user avatar
4 votes
0 answers
109 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 ...
battle2048's user avatar
0 votes
1 answer
6k 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 ...
vickk's user avatar
  • 11
1 vote
1 answer
2k views

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
870 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 ...
JustAnEuropean's user avatar
3 votes
4 answers
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 ...
user3496101's user avatar
9 votes
2 answers
16k 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 ...
oz123's user avatar
  • 497
5 votes
1 answer
312 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 ...
tr3online's user avatar
  • 153
7 votes
2 answers
247 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 ...
doughgle's user avatar
  • 619
8 votes
2 answers
164 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 ...
dmgl's user avatar
  • 183
1 vote
1 answer
188 views

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

I have a tree of objects. ...
dtech's user avatar
  • 161
3 votes
2 answers
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 ...
Tadgh's user avatar
  • 195
1 vote
2 answers
991 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 ...
Brian Patterson's user avatar
-1 votes
1 answer
78 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 ...
ShuklaSannidhya's user avatar