If you have working code that you're looking to have peer-reviewed for improvement, your post belongs on Code Review, which was established just for that purpose. If that's not what you're asking, then please edit your post to clearly explain the problem you're having with the code you've posted and ask a specific question related to that code. — Ken White49 secs ago
RELOAD! There are 5975 unanswered questions (89.8519% answered)
For a homework assignment, we were tasked to create a basic calculator in MySQL and store it in a procedure. I believe I did a solid job but am looking to see where I can improve.
DELIMITER $$
CREATE PROCEDURE Calculate(IN Num1 INT, IN Num2 INT, IN operation VARCHAR(100))
BEGIN
IF operation = "...
@SᴀᴍOnᴇᴌᴀ Possibly related to this bug: Feeds are no longer posted in chat Adam Lear wrote not too long ago that it should be fixed now - but if you notice that something is still not working as expected, please leave a comment there.
In the bug report, I have used Captain Obvious as an example of a feed which was not posting messages into chat for some time. I hope that's ok.
My first post at code review, hope this goes well. I am reading an Excel file using Pandas and I feel like there has to be a better way to handle the way I create column names. This is something like the excel file I'm reading:
1 2 # '1' is merged in the two cells ab...
I'm attempting to parse an SVG file to get all of the colors that are present in the file. SVGs are XML based and their structure can vary a bit. For example:
<svg viewBox="-80 -80 160 160">
<g stroke="black" fill="none">
<path d='...' fill='#0FF'/>
<path d='...' fill='#F0F'/>
.....
I got a bit of a strange JS issue that I could use help on if anyone has time…
Basically if you flick the slider just the wrong way then it'll spin infinitely rather than just settle on a slide and stop. It's a bit hard to get it to do that. I think it has something to do with spinning past the ...
I wrote this for a class project, the backend for this dog voting website. I noticed duplicate code among multiple functions I was writing to be deployed as a cloud function: they all were wrapped in try/except blocks that returned either 200 and JSON or 500 and a traceback. (I understand that it...
This is the new code, I am unsure if I made the suggestions the the suggestion intended on my previous post First Python program: Tic-Tac-Toe.
I have only been working on programming for about 3 weeks so anymore suggestions or insight on the original post of the suggestions would be more than w...
I have a method that creates a database record...
the data to be added is in the constructor.
DataBaseRecordCreator DataBaseRecordCreator = new DataBaseRecordCreator("Bob", 35);
there is only one method currently called with to following code...
if(CreateDatabaseRecord() == "sucess")
{
Cons...
I wanted to know (1) and thanks for (5). If someone would show me such code in codereview/interview earlier I wouldn't guess the answer myself. So probably I'll stick to (5) too. — Sinatr39 secs ago
Also, how about posting your code on codereview.stackexchange.com? Make sure it works as intended, provide some background and examples of usage, and you should get some valuable advice specific to your case there. — Georgy57 secs ago
Simple class to simpify runtime file loading of ressources. The class reads all files from a given directory including all subdirectories and stores the name together with the path in a simple struct. If a file needs to be used by the program just pass the name to GetPath() and the class returns ...
I am creating a Client to consume the SOAP request. The Client is sending request using HTTP POST. Below are two requests that I need to consume:
Request 1:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abc="http://pay_t...
Best way to loop through cells :
for or for each cls in rng ?
Sub for()
For i = a To b
For j = c To d
'things to cells(i,j)
Next j
Next i
End Sub
or
sub ForEach()
dim cls as variant
dim rng as range
set rng = myrange
for each cls in rng
'Things to cls
next cls
e...
I am using PHP 7.2 and MySQLi. I have the login script. I want to improve the code add login type like 'Admin,' super', 'user' and make a type best session in an index page. I have to get two error first session only working index page. no work any other page and last I want to log in by type. pl...
0
So I have been practicing competitive coding for a while now and am using codeforces.com for the same. I recently encountered a problem called "One Dimensional Japanese Crossward" on that site ( https://codeforces.com/problemset/problem/721/A ). After lots of tries and lots of fails, I was fin...
I am working on Valid Perfect Square - LeetCode
and wrote a standard leftmost bisect search to solve the problem
class Solution:
def isPerfectSquare(self, num: int) -> bool:
#base case 1
if num == 1: return True
lo = 1
hi = num
#recur case
w...
I have the following working code, but it is too slow because I have to run the same code for several files inside a folder. Please help me avoid the nested for loop or make it more efficient.
def create_nodes(self):
for child in self.tree.getroot():
columnNames = child.attrib
...
How can i make this function faster? I am calculating parameters for timeseries & the data size is very big
def param(data_param):
w = []
x = []
y = []
z = []
p = d = q = range(0, 2) # Define the p, d and q parameters to take any value between 0 and 2
pdq = list(itertools...
I work in marketing and I am currently trying to aggregate data for 50 facebook pages on the same Business Page.
I have a loop that tries a series of requests to grab all data. I am not sure I am handling exceptions in the best way possible, so I was wondering if somebody had any idea on how to ...
If the code works then suggestions for improvement belong on CodeReview.SE — Paulie_D35 secs ago
I'm voting to close this question as off-topic because if the code works then suggestions for improvement belong on CodeReview.SE — Paulie_D50 secs ago
@Paulie_D Feel free to recommend the OP post on CR but in the future, please don't use the existence of the Code Review site as a reason to close a question. Evaluate the request and use a reason like too broad, primarily opinion-based, etc. Then you can mention to the OP that it can be posted on Code Review if it is on-topic. Please see the section What you should not do in this answer to A guide to Code Review for Stack Overflow users — Sᴀᴍ Onᴇᴌᴀ21 secs ago
BTW this post would not really be on-topic for CR because it looks like a snippet and it would really help reviewers to see the entirety of the code — Sᴀᴍ Onᴇᴌᴀ9 secs ago
@SimonForsberg - is there a typo in your meta answer here - in the last paragraph: "A hit, description, alternative algorithm can be suggested" - was the intention: "A hint, description..."?
I'm trying to extract the key value in C from a string in a config file which may have arbitrary whitespace leading and trailing the string. This is what I've come up with so far. It's not quite right yet. It's been quite some time since I've picked up C and have been spoiled by baked-in string ...
@rekiem87 this post would currently not be on-topic for CR in its current form, because it doesn't contain any code. I'm not sure where exactly is the best place for a question like this but perhaps one could discern after reading "Which Site?"... — Sᴀᴍ Onᴇᴌᴀjust now
The Hashset uses open addressing, linear probing and Robin Hood hashing for handling collisions. It comes with insert and remove operations, iteration (back and forward using a single iterator), min and max keys (this is to interface with a treeset that I've made, but not very useful) and set ope...
I have a list of article titles, where i wish to count the number of occurrences for each word. (and remove some words and characters) The input is in a .csv file where the titles are in column 'Titles'
I already have a code that does the job(pasted below), but maybe someone could help me do it ...
does anybody know how I would set click listener for button 5 to save username and password into my SQL DB so it can be retrieved in another activity?
public class Registering extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedIn...
I have created the code below that compare two spreadsheets . It initially compares the range of value from sheet1 ("Status") to sheet2 ("Interface") . Whenever a range matches with the ranges present in other sheet , it does nothing .When the range does not any matches in the other sheet , then ...
I'm in the process of doing a training course in C#. I've just gone over covering Polymorphic OOP / composition over inheritance etc...
The latest exercise I completed in the course was to create two base classes, DBConnector & DBCommand that can be used for any database. The verbatim requiremen...
I have a list of orders and for some order fields I need get the data that is common among the orders. If the data is not in common, I should indicate null. I collect the common data in a CommonData object. In addition, I also store the order codes and order ids associated with the CommonData.
...
The point of this project is to be able to create an excel configuration file where the user can input search strings and search files, both potentially having wildcards, and search those files for those strings.
The problem is that while I have working code, it just simply takes the program to...
The task:
Implement integer exponentiation. That is, implement the pow(x, y)
function, where x and y are integers and returns x^y.
Do this faster than the naive method of repeated multiplication.
For example, pow(2, 10) should return 1024.
Solution 1
function pow(x, y) {
if (...
The following code is for a vertical menu, where I needed a marker to slide down next to a link upon hovering over said link. Therefore I needed to change css properties of a html element (the top-margin in this case).
What I've done in jQuery is add a class ('.movedown1' or '.movedown2') to the...
I work in the population health industry and get contracts from commercial companies to conduct research on their products. This is the general code to identify target patient groups from a provincial datasets, including DAD (hospital discharge), PC (physician claims), NACRS (emergency room visit...
I am still fairly new to coding and learned about the basics of ASP.NET Identity. I have used ASP.NET Identity in past personal projects for User Authentication (Individual User Accounts) and Login. As I learn more about how an application should be structured and other coding guidelines, I que...
In a bucket, there are total 100 balls, in which 10 are red, 40 are green and remaining 50 are black. Every ball has a numeric unique tag starting from 1 to 100, like red balls have tag 1 to 10 than green balls have their tags from 11 to 50 and rest black tags are from 51 to 100.
Now If I take a...
Java noob trying my hand at basic FTP. Trying to turn an Apache Commons Net FTP tutorial into a functioning program where users enter server, user, pass and can modify/add/view/delete files.
However, whenever I get to the "list files" command I receive an unusual error. The error is:
Exception ...
If this code is working and you are looking for suggestions to improve it. Please post it on Code Review. SO is more for helping you troubleshoot errors in your code. — Zack E17 secs ago
Also if you have a working solution, and you are asking how to make it better, this is off topic for StackOverflow, and would be on topic for CodeReview as you are not asking about an error, but asking about refactoring. — Taplar34 secs ago
Lets say I have this data:
let trips = [
{
from: "DEN",
to: "JFK"
},
{
from: "SEA",
to: "DEN"
},
{
from: 'JFK',
to: 'SEA'
},
];
and my origin is 'JFK', I want to sort the list by how I have traveled. So for instance, this should be the end result:
let trips...
Ive got some code which converts data from hours to days. I am wondering if there are any improvements which could be made to make it more efficient or any other improvements in general that could be made? other information:for t = Int((n - 1) / 24) + 1, the n is the amount of rows of data. u is ...
It was worth a try. You might want to dig through Code Review to see if anyone's asked about and gotten a more elegant solution that'll compile for C++11. — user45813011 min ago
I'm new to Python, for a school project I created a "fishing simulator". Basically, use of random. I know that my code is repetitive towards the end but I don't know how to simplify it.
import time
import random
fishing = True
a = b = c = d = e = 0 #define multiple variables as same thing
print ...
Automation is king. We do code reviews, and they do creep in depending on who signs off on the approvals - I've never been on a team were it's 100% of all reviewers required to merge, so it's usually "2 accepts / no declines". Automating the check will also help flush out the ones that slipped though and are already in the codebase too. — antonyh42 secs ago