111,444 questions
-7
votes
4
answers
117
views
problem in javascript temprature converter [closed]
I am trying to make a temperature converter that automatically changes value when the user changes the input and clicks elsewhere (using the onChange in my html file) in javascript, but when i type in ...
2
votes
1
answer
72
views
Utilizing a loop or automated approach to join all possible elements in one dataframes together based on defined criteria
Summary: I want to be able to recreate my SQL code via Python such that I dont have to manually type out each join for situations when the combinations get too large to handle
I have one table
import ...
Advice
0
votes
3
replies
41
views
Trigger Function to check record uniqueness
I have a trigger in Postgresql 13 like this to prevent duplicate entry on one of the coloumn :
This trigger is used in Arcgis Field Map apps.
CREATE OR REPLACE FUNCTION xxx_check_unique()
...
7609
votes
86
answers
1.6m
views
How do JavaScript closures work?
How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?
I ...
0
votes
1
answer
116
views
Remainder check and pass on to main program
I'm writing a simple maths sketch. At this point I want to check if 2 random numbers, when divided, leave a remainder. If not then pass them onto the next part of the program. If the remainder is not ...
7671
votes
42
answers
1.2m
views
var functionName = function() {} vs function functionName() {}
I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.
The previous developer used two ways ...
Advice
2
votes
7
replies
126
views
Do all definitions of an inline function in C share the same address?
I know that it's possible to take the address of an inline function, just like with ordinary functions. But if each translation unit has its own inline definition, and I take the address of the ...
0
votes
1
answer
64
views
Is there any function to remove litespeed_docref from heaader in WordPress website [closed]
I am looking to remove
<script data-no-optimize="1">var litespeed_docref=sessionStorage.getItem("litespeed_docref");litespeed_docref&&(Object.defineProperty(document,&...
Advice
0
votes
2
replies
52
views
Make these all apply to one function, so that one plays, but stops the one before it
How do I make these all apply to one function, so that one plays, but stops the one before it?
Code
def rex_audio(self):
RexAud = SoundLoader.load('Rex.wav')
RexAud.play()
...
1
vote
0
answers
60
views
Error with Random Intercept Model Using nlme and Custom Function
I am working with a custom logistic function:
logistic.fcn <- function (x, y0, y100B, dy100.F, a, x0B, dx0.F, isF_num) {
y0 + ((y100B + isF_num*dy100.F)-y0)/(1 + exp (-a * (x - (x0B + isF_num*...
3505
votes
25
answers
836k
views
What is the difference between call and apply?
What is the difference between using Function.prototype.apply() and Function.prototype.call() to invoke a function?
const func = function() {
alert("Hello world!");
};
func.apply() vs. ...
2690
votes
30
answers
1.5m
views
Set a default parameter value for a JavaScript function
I would like a JavaScript function to have optional arguments which I set a default on, which get used if the value isn't defined (and ignored if the value is passed). In Ruby you can do it like this:
...
2475
votes
31
answers
2.7m
views
JavaScript check if variable exists (is defined/initialized)
Which method of checking if a variable has been initialized is better/correct?
(Assuming the variable could hold anything (string, int, object, function, etc.))
if (elem) { // or !elem
or
if (typeof ...
0
votes
3
answers
219
views
Realloc in function that deletes a row in a matrix
I have just encountered a case in this C program:
void row_del(int**& a, int& row, int col, int k) {
for (int j = 0; j < col; j++) {
for (int i = k; i < row - 1; i++) {
...
3199
votes
22
answers
690k
views
How do I make function decorators and chain them together?
How do I make two decorators in Python that would do the following?
@make_bold
@make_italic
def say():
return "Hello"
Calling say() should return:
"<b><i>Hello</i>&...
0
votes
0
answers
43
views
How to keep an add on Python debugger function to stay in scope
After trying Lavi Kumar's example it seems the package import pdbext.debug in ~/.pdbrc goes out of scope when another source file is called.
~/.pdbrc:
!import pdbext.debug
alias pl !pdbext.debug....
Advice
0
votes
4
replies
76
views
Calculating resistance and resilience of a soil microbial community
I want to calculate resistance and resilience of the soil microbial community in my experiment.
I have an experimental design with 4 treatments: ambient (control), drought, warmed, and warmed & ...
0
votes
1
answer
139
views
How to modify a Python function to handle one, several, or all parameters in a dictionary
I want to setup an environment in a Jupyter notebook where parameters are stored in a dictionary parValue and where you can change values of one or several parameters with a function par(), while ...
0
votes
1
answer
65
views
Function Filter - How to not apply filter on a specific cell value?
In Google Sheets, I have a database on which I want to apply a filter depending on 10 criteria from 10 columns, using values from 10 specific cells. I can do this, but I would like that the filter ...
1
vote
0
answers
81
views
Type '(x: string) => void' is not assignable to type '(x: unknown) => void' [duplicate]
unknown is so annoying to work with when using strict Typescript. I understand not being allowed to assign a type unknown to a known type, but you are able to assign known types to unknown. So why ...
0
votes
3
answers
149
views
Array Functions
I am currently learning the new array functions in Excel. I've been learning them for a bit, but still learning.
I am trying to create a dynamic YTD type report off some dummy data however I can't ...
3
votes
2
answers
64
views
Why does this collapsible need 2 clicks to open, then 2 more clicks to close?
Description
I'm having an issue with a collapsible requiring 2 clicks of a button to open, then another 2 clicks to close. The Show/Hide text inside the button gets mixed up as well. I think it might ...
2220
votes
27
answers
579k
views
What is the scope of variables in JavaScript?
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined ...
2
votes
1
answer
211
views
Void function doesn't print elements of matrix C++
I'm trying to print elements of matrix (example will be below). Here is the following code written in Dev-C++:
#include <iostream>
using namespace std;
class Matrix {
private:
int **...
1023
votes
24
answers
608k
views
Javascript call() & apply() vs bind()?
I already know that apply and call are similar functions which set this (context of a function).
The difference is with the way we send the arguments (manual vs array)
Question:
But when should I use ...
0
votes
1
answer
67
views
Store the result of a function in a reactive and reuse it in a other function Rshiny
Motivation : I would like to have the app.R file as svelt as possible so I use function to do the larger part of computations that doesn't need to be made in a reactive environnement. Still, I need ...
3
votes
2
answers
89
views
How to use the type of a referenced column as a VARIADIC argument type in a (Postgres) SQL function or procedure definition?
The PostgreSQL documentation for argtype in function and procedure definitions states:
The type of a column is referenced by writing table_name.column_name%TYPE.
This works fine for IN mode ...
574
votes
31
answers
557k
views
PHP mail function doesn't complete sending of e-mail
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: yoursite.com';
$to = '[email protected]';
$subject = 'Customer ...
-1
votes
1
answer
77
views
Variable isn't being set to result of Get-Content command
i'm trying to automate a few basic tasks for a helpdesk team and I cannot seem to understand why I cannot get the desired result from this code:
I did try to explicityl define $Tile as a [string] but ...
793
votes
28
answers
538k
views
Determine function name from within that function
Is there a way to determine a function's name from within the function?
def foo():
print("my name is", __myname__) # <== how do I calculate this at runtime?
In the example above, ...
769
votes
24
answers
623k
views
Decorators with parameters?
I have a problem with the transfer of the variable insurance_mode by the decorator. I would do it by the following decorator statement:
@execute_complete_reservation(True)
def test_booking_gta_object(...
2
votes
2
answers
180
views
How to check whether a name is a locally accessible function?
How to check whether a name is a locally accessible function and only locally accessible?
For example, with
function out = top_level_function(name)
% ???
function helper2
end
end
function ...
878
votes
16
answers
1.1m
views
Pass a JavaScript function as parameter
How do I pass a function as a parameter without the function executing in the "parent" function or using eval()? (Since I've read that it's insecure.)
I have this:
addContact(entityId, ...
681
votes
30
answers
793k
views
How to get the return value from a thread?
The function foo below returns a string 'foo'. How can I get the value 'foo' which is returned from the thread's target?
from threading import Thread
def foo(bar):
print('hello {}'.format(bar))
...
1576
votes
8
answers
2.0m
views
Passing parameters to a Bash function
I am trying to search how to pass parameters in a Bash function, but what comes up is always how to pass parameter from the command line.
I would like to pass parameters within my script. I tried:
...
844
votes
19
answers
2.1m
views
How do I call a function from another .py file? [duplicate]
file.py contains a function named function. How do I import it?
from file.py import function(a,b)
The above gives an error:
ImportError: No module named 'file.py'; file is not a package
2
votes
1
answer
98
views
Why is my parameter seen as a NoneType when I set it as an integer?
I followed the Panda3D tutorial and got everything working so tried adding my own custom arguments using argparse. The first one I made was --no-rotate where it would stop the camera rotating which ...
490
votes
48
answers
403k
views
Simplest/cleanest way to implement a singleton in JavaScript
What is the simplest/cleanest way to implement the singleton pattern in JavaScript?
2
votes
4
answers
205
views
How to work with data passed to a function, but without an explicit name in its parameters in C?
There is a declaration of a function in C language.
int foo(int, int) {
// код функции.
}
How do I access a parameter inside a function, only the parameter type is specified (no name).
A program ...
986
votes
26
answers
597k
views
How are lambdas useful? [closed]
I'm trying to figure out Python lambdas. Is lambda one of those "interesting" language items that in real life should be forgotten?
I'm sure there are some edge cases where it might be ...
2
votes
3
answers
130
views
How to pass object to a function in PowerShell
I am trying to save some date to a PSCustomObject in one function and pass that object to another function so I can access the objects properties and values. I am doing something incorrect as I can ...
843
votes
23
answers
593k
views
What is the use of the JavaScript 'bind' method?
What is the use of bind() in JavaScript?
769
votes
16
answers
1.2m
views
How to apply a function to two columns of Pandas dataframe
Suppose I have a function and a dataframe defined as below:
def get_sublist(sta, end):
return mylist[sta:end+1]
df = pd.DataFrame({'ID':['1','2','3'], 'col_1': [0,2,3], 'col_2':[1,4,5]})
mylist = ...
1
vote
1
answer
166
views
Functional bean can't be recognized by Spring Function
I have two configuration classes with functional beans:
@Configuration
public class PositionReporter {
@Bean
public Supplier<Aircraft> reportPositions() {
return () -> new ...
1470
votes
8
answers
244k
views
What does the exclamation mark do before the function?
I found this code:
!function () {}();
What is the purpose of the exclamation mark here?
1003
votes
18
answers
195k
views
What is the difference between a 'closure' and a 'lambda'?
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused.
And now that we're here, how do they differ from a regular function?
644
votes
14
answers
905k
views
Return value in a Bash function
I am working with a bash script and I want to execute a function to print a return value:
function fun1(){
return 34
}
function fun2(){
local res=$(fun1)
echo $res
}
When I execute fun2, it ...
-2
votes
2
answers
81
views
If I want a string of text to print if a variable is less than a number how can I do this? [closed]
I'm trying to understand how functions work, I defined my function with length and area parameters.
Here is the problem: I want to write if area is less than a # then print a string of text.
def ...
2
votes
1
answer
129
views
Why is my code for generating a curve fit of a cosine to a sum of gaussians working so poorly?
I have this code in which I'm trying to use scipy.optimize.curve_fit() to take a cos^2(x) function and approximate it as a sum of gaussian peaks. However, it is generating a very poor fit and I can't ...
-2
votes
1
answer
84
views
Could I use a dynamic function to match values to another sheet in Google Sheets? [closed]
I'm making a quiz-type thing with Google Sheets- one as the user-end (where the quiztaker would input answers) and one as the answersheet. What I want to do is have a function in conditional ...