Questions tagged [methods]

12859 questions
1

votes
1

answer
170

Views

Chrome.tabs.executeScript(); + .addEventListener(“click”, …); to inject code into active webpage through chrome extension

I am trying to make a chrome extension that injects code into the active webpage through the popup.html file... popup.html > hello this is a test document.getElementById('Mr_Button-Click_Extend').addEventListener('click', TheGreatEmbed() { chrome.tabs.executeScript(null, {file: 'js/inject.js'}); })...
1

votes
0

answer
87

Views

Solving Multi-dimentional ODE in Python

I have to solve numerically ODE of 2nd order. The issue is that I need to solve it simultaneously for two objects (in general N objects) and each object has 4 variables (2 dimensions): 2 in position and 2 in velocity. Please see code below to see the example. When trying to solve it in Python (Scipy...
matekrk
1

votes
0

answer
98

Views

Autograd fails to properly calculate Normal CDF derivative

I'm a total neophyte when it comes to Autograd, so I feel like I may be doing something very obviously wrong. However, I've spent a full day struggling on this. I am trying to calculate the derivative of a function that includes a normal cdf. I had no success with Autograd, so I broke it up into sma...
Mango Fed
1

votes
0

answer
125

Views

I am getting the following Error

I am getting the following Error: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference this the Logcat java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitud...
تثقف
1

votes
1

answer
99

Views

How does a Parent variable store a Child that is larger than Parent?

I am a beginner in java right now and confused in certain concepts. Suppose there is a parent class and a child class. Methods are overridden between the two. If I do this: Parent p = new Child(); How exactly is memory allocated for the object? Supposing memory of parent is 32 bytes and child class...
Mihir
1

votes
0

answer
36

Views

Updating object on Python < arcade library >

I'm currently coding in some assignment. I create a class named Ship and created some methods to make the object class ship be able to move. class Ship(): def __init__(self): self.center.x = 400 self.center.y = 300 self.velocity.dx = .25 self.velocity.dy = .25 def advance_down(self): self.center.y =...
SkylarR95
1

votes
0

answer
29

Views

Flask - HTTP methods post and get gives error when positions exchanged

Today I was playing around with my Flask project and found that when I change: @app.route('/search', methods=['GET', 'POST']) to @app.route('/search', methods=['POST', 'GET']) that is, when I change the order of “POST” and ”GET”, it produces some error, since I have solved the typo bug...
Rahul Gurung
1

votes
0

answer
15

Views

Creating a method for a class with multiple inheritance (Python)

Defining methods for a class with multiple inheritance in Python I am struggling to understand how I could define methods in a class with multiple inheritance. All the code runs well, until I define instances - the very last line. Please help. I am new to OOP in Python. Defining Class A with attr...
psparule
1

votes
1

answer
35

Views

How to run component's method via HTML in Vue2

I have a .vue file, ServiceList, which imports the component Information.vue. I would like to run Information's code in a loop in ServiceList's template like so: ServiceList.vue Headline {{ service.name }} import Information from './Information' ... (more components here) export default { component...
A. A. Pedersen
1

votes
0

answer
38

Views

Set property if method is currently running

So I have a class containing following property: public bool Busy { get; set; } In the same class I have a bunch of asynchronous methods. What I want to achieve is automatically set Busy property to true if any method in the class is being currently running, then set it back to false once methods r...
Categle
1

votes
0

answer
31

Views

Copy argument of static Method

I have Two classes, First the ViewDatabase.java with the following method: public void collectUserInfo(final ArrayList ids){ databaseReference.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { ArrayList friends = new Ar...
1

votes
1

answer
24

Views

Use global variable in jQuery function and then set it

I want to make a function that updates a variable defined in the function parameters - the example below should set 'cargo' to '10'. var cargo = 0; function itemChange(action,item,x){ if (action == 'set'){ item = x; } } itemChange('set', cargo , 10); console.log(cargo); Instead I'm getting 0 back, a...
Hunter Forest
1

votes
0

answer
37

Views

Cannot find any turtle.inspect commands in turtle Lua shell

This should be a simple issue but I have been scratching my head for a while - I am using Tekkit 1.2.9g from the Technic launcher and the integrated ComputerCraft turtles. I am specifically interested in the turtle.inspectUp/Down commands, but at least from the lua shell within the turtle I cannot...
Scott Anderson
1

votes
0

answer
275

Views

invoke method with list of parameter c#

I have a class: namespace TestLib1 public class TestLib1 { public IEnumerable Measure1(IEnumerable _inParameters) { // this is just to do something foreach (TestedParameter item in _inParameters) { item.Param_Description = 'TestParam'; } return _inParameters; } } that contains class from public cla...
Seba Ja
1

votes
1

answer
9

Views

How do I pass a return value from one method to another?

I need to pass a return value from windCorrectionAngle method to groundSpeed method and place it at the very end of the expression ('windCorAng'). This is the only part that doesn't work for me. From what I learned it is not something that Java can do easily because it can't see the return from othe...
Eli
1

votes
1

answer
74

Views

Why won't truncateTable work in Joomla 3.7?

I have the following code attempting to truncate a table. The Joomla documentation makes me believe this will work, but it does not. What am I missing? $db = JFactory::getDbo(); truncate_query = $db->getQuery(true); //$truncate_query = 'TRUNCATE ' . $db->quoteName('#__mytable'); $truncate_query->tru...
Rob
1

votes
3

answer
84

Views

How does Python assign function to classes and instances?

I'm quite confused about Python's behavior when I assign function to classes and instances: class A: def printf(*args): print(args) def printff(*args): print(args) a = A() a.printf() print('-'*5, a.printf) print('-'*5, A.printf) A.printf = printff a.printf() print('-'*5, a.printf) print('-'*5, A.pri...
Allan Chain
1

votes
1

answer
20

Views

Extending Swift type with method that requires a generic

My question is about extending a type with a method that requires a generic. I want to extend IndexPath and add a method to check if it's valid in a given NSFetchedResultsController. Here's my extension: public extension IndexPath { func isValid(in fetchedResultsController: NSFetchedResultsControlle...
nambatee
1

votes
1

answer
49

Views

INRIA SPOON API MethodCalls-Retrieve Callee Classes for method.getExecutable() and method.getTarget()

I am trying to extract method calls for a project that I am parsing using the tool spoon developed by INRIA, I already have a methods mysql table where I stored all the methods (methodid, methodname, classid, classname ). I am using the following code to extract the methodcalls within my project: Sp...
larasmith
1

votes
0

answer
311

Views

Java - Access Class Variable [duplicate]

This question already has an answer here: How to read the value of a private field from a different class in Java? 11 answers Getting value of public static final field/property of a class in Java via reflection 3 answers I was wondering how I would access a Class variable from within a method whe...
Ivar Eriksson
1

votes
1

answer
239

Views

Speed up a C++ code implementing numerical integration

I have this C++ code that implements a rectangular numerical integration #include #include using namespace std; float pdf(float u){ return (1/(pow(1+u, 2))); } float cdf(float u){ return (1 - 1/(u+1)); } // The main function that implements the numerical integration, //and it is a recursive funct...
BlackMath
1

votes
1

answer
72

Views

Why can't I reference extension methods with internal visibility from my .cshtml pages? [duplicate]

This question already has an answer here: How come internal members in my view model aren't accessible in the view? 1 answer I have an ASP.NET Core 2.1 default project (upgraded from 2.0 without using the new 'default UI' facilities, as the plan is to customise the default views and controllers). I...
Hammerite
1

votes
1

answer
122

Views

Python 3.6: abc.abstracmethod on classmethod no check on class level call

With python 3.6, When I decorate an abstractmehod with abc.abstractmethod withing a class having metaclass=abc.ABCMeta, the abstract method can be called from a class (not instance) point of view. It seems that the abc decorators are performing the checks when the class is instanciated, so it is not...
Michael Hooreman
1

votes
1

answer
191

Views

Using TypeScript decorators and promises with proper typing?

I wrote a buffered decorator, which works as expected by returning a Promise (during the execution). However, to make the tsc transpiler happy, I'm forced to cast the decorated function with any and then (in the example below) with Promise. How can I avoid the extra casts? Is it even possible for a...
hsk81
1

votes
1

answer
34

Views

jQuery 'serialize' method not passing username to Firefox

I am attempting to pass a bootstrapv4 modal username/password form to php using jQuery. It is 'successful', but only partially, since it does not seem to work in Firefox. In the html... 'signInForm' is the ID of the form. 'uName' (username) and 'uPass' (password) are the 'name=' values of the 2 inp...
lilHenry
1

votes
0

answer
25

Views

Is there a possible way to generate multiple jasper report in one method using looping?

i am now experiencing a trouble on my development. My problem is that i am not able to generate multiple reports. Here's the controller code: getLatestEvalDocInstance?.each{ if (it?.currentEvaluatorRole.authority == 'ROLE_CSA_APPROVING_AUTHORITY_1') { docEvalType
Effoc
1

votes
0

answer
47

Views

.getSelectedItem() is not working in combo box

Combo comboLevels = new Combo(shellAfterCasual, SWT.NONE); comboLevels.setBounds(52, 31, 91, 23); String[] items = new String[] { 'Swedish 1', 'Swedish 2', 'Swdish 3' }; comboLevels.setItems(items); //this is in main //as a method i need to getselected item for example id 'swedish1 ' is clicked i ne...
Oliver Kadi
1

votes
2

answer
47

Views

invoking a class method inside the class itself

Hi everyone i wanna use a calculated value from a method of the class itself for the rest of the class methods but it must calculate once for all and i need to invoke method inside the class itself i write an example: class something(): def __init__(): pass def __sum(self, variable_1, variable_2): s...
Hamed Fathi
1

votes
1

answer
32

Views

how to pass data and use user input in method calls

I am having the most difficult time understanding method calls that use outside variables. Here is what I'm trying to do in print form, and below I'll paste two attempts. I keep getting loops of the same error messages when i try to fix what I'm doing. I'm also wanting a user to enter a number to...
dev2660
1

votes
2

answer
36

Views

Subclass var initialization step and OOP structure design

The abstract super class Parent has abstract method extract(Int), getting the value a from primary constructor, and submit it to that method extract(a). abstract class Parent ( val a : Int ) { abstract fun extract ( i : Int ) init { // call overriden extract(Int) extract ( a ) } } The sub class Chil...
BingLi224
1

votes
1

answer
271

Views

Update and save an order item in the order on Woocommerce 3

I am trying to change the quantity, subtotal and total of a line item in woocommerce, but my code seems to not change anything but the end total... why is that?? (there is only 1 line item for any order I want to change) here is my code to change a line item details; $ordernum = 12345; //what I want...
RickMorty
1

votes
0

answer
8

Views

Error: the if are execute before I click in the button. Only the else is running, but should not be run

I have a Login class and create an instance of it in the Main class, with an instance I'm calling the method start , however in the one term clicking the 'Login' button does not run the method 'show_entry_fields' correctly. When I execute and click on a Main room I immediately get to the console: '...
cicada 3301
1

votes
1

answer
268

Views

c# Call a method by memory address

I am trying to call a function at a specified memory address in c#, here is how I would go about it in C: typedef void _do(int i); auto doActor = (_do*)0xAAAABEEF; doActor(1); How do I replicate this behavior in C# if at all possible? Very new to C# all help is appreciated. More in depth explanation...
1

votes
1

answer
59

Views

Is there a numerical method for approaching the first derivative at t = 0 s in a real-time application?

I want to improve step-by-step, whilst unevenly-sampled data are coming, the value of the first derivative at t = 0 s. For example, if you want to find the initial velocity in a projectile's motion, but you do not know its final position and velocity, however, you are receiving (slowly) the measurem...
Jorge Cruz
1

votes
1

answer
79

Views

How to access a private instance variable from a protected method in TypeScript

I have an abstract class with an abstract method that is implemented by the child class. The implemented method in the child class should update an private instance variable of the child class. After this I want to retrieve the value of the private variable by using a getter method. To see the probl...
ElrondMcBong
1

votes
2

answer
94

Views

Symfony 4 bugged route

I was trying to create a route type 'any' to allow both get and post but it did not work so I tried adding two routes to my route annotation like this /** * @Route('/news', name='newsSinglePOST', methods={'post'}) * @Route('/news', name='newsSingleGET', methods={'get'}) * @return \Symfony\Component\...
Sam
1

votes
0

answer
93

Views

Use string array as function parameters

I have done some research and I'm very surprise I did not find a solution for this simple problem. EDIT : The question is about wether is that possible or does C# not provide any way to do what I'm trying to do In the following example, I want to call IWannaBeCalled from Linker with the parameters f...
Yanis.F
1

votes
0

answer
15

Views

Equivalent method Format for ComponentOne

I did a program in C# to extract a DataGridView into an Excel file and I used a third party class to do the extraction (here the doc). I want to use this method called Format, but my problem is that I had to use necessarily old libreries and this method isn't supported. I have searched online but I...
Matteo
2

votes
1

answer
22

Views

Why is method executed with a delay

I am a developing an Android app in Android Studio. Let's say i have a method checkSomething and doSomething. In my doSomething method I have a piece of code that looks like this: int i = checkSomething(); if(i >= x){ runThisMethod(); }else{ runThis(); } During the debugging I found out that my code...
Duzy
0

votes
4

answer
12

Views

How can I update the state of an array index individually in a React component without effecting the whole array itself when using setState()?

I'm revisiting an old problem that I asked about and approaching it differently. Currently I want to update the score array individual. Currently what happens is when the onClick function runs it removes all whole array. How do I update just that array's index that I am trying to specify??? class Ap...
Micah Johnson

View additional questions