If your code is working than this probably belongs on Codereview since you seem to be seeking improvement advice. But check their on topic help section to make sure it does. — Patrick Evans19 secs ago
I've got a complex object tree that I need to instantiate. The object tree is a bunch of specialized classes that don't have a common root object (other than Object) and has generic objects (that I need to configure), and custom objects (all the "My" classes in the example code).
I've created th...
I want to port a crypto function from C to Java. The function has to run in constant time, so no conditional branchings are allowed.
The original C code is:
int x,result;
...
result = (x==7);
...
So that 'result' is set to 1 if 'x==7' and to 0 otherwise. The 'result' variable is then used in ...
Here's meth that exports a list of likes from soundcloud to csv. How can I make it better?
def tracks
page_size = 50
client = SoundCloud.new(:client_id => CLIENT_ID)
res = []
tracks = client.get("/users/#{USERNAME}/favorites", limit: page_size, order: 'created_at', linked_partitioning: 1...
Hi!
So here is some of the code in my library:
InverseAPI.cpp:
// InverseAPI (Cobalt)
// Developed by Sahibdeep Nann (@SahibdeepNann)
// https://github.com/InitializeSahib/InverseAPI
// Licensed under the MIT License
#include "stdafx.h"
#include "InverseCobalt.h"
namespace InverseCobalt {
...
thanks for detailed code review. Now its much more clear. so the compiler doesn't allow non const arguments to bind to temporary objects. Btw why does it allowed me to use this non-const copy constructor in operator+ then ? — barney30 secs ago
I'm brand new at Java and have read a bunch of questions/answers about this but have not been able to find a solution which works.
I have a ListView and when I remove an item from my list (within getView using onClick), I call an Asynctask to remove the item from the database, and then pull the r...
I'm looking for a code review on a class that I've written, it was my first attempt at lockless programming and I'd love and feedback I can get.
https://github.com/Protheus-Engine/Protheus/blob/devel/src/Utilities/Pipe.h
Thank you for any help and/or advice.
I don't understand why this code is causing loop. Can someone please explain?
x = raw_input('Enter a number: ')
ans = 0
while ans**3 < x:
ans += 1
if ans ** 3!= x:
print('No cube root for ' + str(x))
else:
print('Cube root for'+ str(x)+ 'is'+ str(ans))
Please pardon me if I've p...
This question contains some C# code I've written as well as a XML format I have designed. My C# code runs a series of "jobs" by loading the XML file and then calling different SQL stored procedures and E-Mailing the results to different addresses. My question specifically relates to the C# code t...
This code hides a message in an image by altering the blue values in the top left part. This is just for fun as I think it would be easy for a cryptographer to find and decrypt this.
Original
With message We will meet at London bridge at dawn
As you can (cannot) see, as long as the message...
assalamu a'laikum
include
include
int main (void)
{
DDRA = 0xFF;
unsigned char x;
scanf(" %c",&x);
while (1)
{
if (x=='a')
{
PORTA = 0x01;
}
if (x=='b')
{
PORTA = 0x02;
}
} ...
Is rewriting the code in a review on-tpoic or considered a bad answer?
For example, I am reviewing a quesion where I feel that OP woudl be better suited splitting their code out into using CSS and HTML and a bit of JavaScript instead of entirely JavaScript, however this would mean rewriting all of their code
"But, I want to improve my code" Stack Overflow is place where we solve problems. If your code works fine and you are asking for hints to how you can improve it farther you should post this question on codereview.stackexchange.com instead. — Pshemo23 secs ago
I am a new guy to java. I want to find the longest sequential same character array in a input character arrays. For example,this character array bddfDDDffkl, the longest is DDD, and this one: rttttDDddjkl, the longest is tttt. I use the following code to deal with this problem. But, I want to imp...
I have installed Orweb(Android equiv of tor browser), Orweb doesn't appear to allow bookmarks only a homepage, no problem I'll just create a simple html page containing a list of links and set this as the homepage....
Via ES Explorer I tried setting the html file to open in Orweb using 'open as'...
However, there is a lot of talk about what implementations are secure and not secure. How does my method measure up? Is it secure? Are there more secure methods in PHP for hashing tokens and matching with tokens later on?
Since you're specifically asking about security, I think reviewing you...
I'm getting myself acquainted with Rust and decided to implement the classical overlapping intervals problem.
Here is a statement of the problem:
Given a collection of intervals, write a function that merges all
overlapping intervals and prints them out.
For example, given [1, 3], [2...
Recently, I wrote a review that discussed certain points in the OP's code, but did not contain any code in the review itself.
Are answers like these discouraged?
Large wall of text incoming. Go to the bathroom, grab a drink, etc...
Try/Catch
The first thing I would refactor is your try/catch statement. Its just way too large, though that may just be the internal comments (which I'll get to next). Try blocks should really only encompass those statement...
I'm learning python and I have written a bank program incorporating all the skills I've gathered so far. Using the program, one can create user profiles (name, password, account balance) which will be stored in three different text files. One can then do the normal bank transactions: deposit, wit...
This is my first question on codereview although i'm pretty active on the askubuntu stack exchange.
I have written a VERY simple convert that converts a string to a character array and then displays the ascii value of each character this is my first time using c++ i usually write java/scala.
Co...
I have seen that moderators work hard to format questions and answers.
Is there a check list they use (specially for CR), so others can also contribute by editing or properly formatting their own questions or answers?
Welcome to CodeReview.
The key problem I have with your code right now is that it doesn't separate data from presentation. This is a maintainability issue because it means now your data is inexplicably tied to your view, and you cannot change one without altering the other. How can we fix this?
...
As moderator election are coming to an end, I would like to invite members of the community to take some time to review all the policies we've made in the past and see if they are still relevant, but need revision, and see which need be deprecated or better clarification.
This is intent to take ...
Yeah, generally all beginner Python questions don't fit PEP8, which needs to be commented on. but most need individual points beyond the standard template
I've been told by others on numerous occasions that my teacher was wrong in saying that we should use using namespace std; in our programs. Hence, we should use std::cout and std::cin and these are more proper. However, they did not even make it clear ever why this is a bad practice.
Why is usin...
part of the skill in being a programmer is knowing when to use what tool for what job - if you don't need bare-metal speed and you can write something in less LOC/faster in another language - or you enjoy it more - then do it
we're way past the days now where we have to worry about individual cpu cycles. except maybe in embedded/performance critical software like nuclear systems/energy grids
Not necessarily. I can recommend a introductory good paper, if you want. Category theory is really abstract, but not hard to grasp when you're a little interested in maths.
`Categories originally arose in mathematics out of the need of a formalism to describe the passage from one type of mathematical structure to another. A category in this way represents a kind of mathematics, and may be described as category as mathematical workspace` for example I have numbers, than I want matrices so I make a category to map from numbers to matrices ?
A few things to point out:
#############################################################################
#This is the function that is called at the beginning of the program
Please do not do this. Ever.
You don't need to wrap your initial code in a big, literal box.
A simple comment, or ...
Comments
Code should be self commenting. Your comments are superfluous.
//Declare Variables.
string input;
int size;
Namespaces
using namespace std; is considered bad practice. Short code is not a requirement in C++, clear code is preferred.
Return
return 0; is a legacy from C. In C++, it'...
I'll try to give you an introductory example for programmers, but it will take some time. Suppose you want to write a function to sum lists of integers. Let's call this function sum. You did your best and the result is quite a nice function. Now some days later you want another function prod to multiply the same list of integers. And like a month later you write a function concat to concatenate lists of strings.
Now all your functions work nicely, however programmers always try to be DRY and reduce the amount of code. Can we find a common pattern amongst those functions? The first apparent thing is, that they all operate on lists. The input is a list with elements of some type, let us call it T. The output is a somewhat concatenated or reduced result, but it is still of type T.
For example, we could not reduce a list of persons and get a concatenated person. (Human centipede)
Now the category theory comes into play. All of our types T are lists. So let's specialize it a little and call it [A] where A is a type that in our example is either the integers or strings.
We can use our "general" function with integers, with strings, but not with persons of course.
I need to just save this markdown to a text file....
Don't do this. Just... *don't*. You're taking values from a table and injecting them into a query as a plain string. I'm reminded of this.
![xkcd - Exploits of a Mom][xkcd]
[xkcd]: imgs.xkcd.com/comics/exploits_of_a_mom.png "Her daughter is named Help I'm trapped in a driver's license factory."
[Courtesy xkcd.com](xkcd.com/license.html)
So what do integers and strings have in common? In the perspective of category theory they support a mathematical structure called a monoid. You can read about what this exactly is, but for our example it has two nice properties.
1.) We can "combine" two elements of type A with an operation, let's call it "op", and get a third element which is again of type A. 2.) We have a so called neutral element, let's call it "n". For integer addition this is 0, for multiplication it is 1 and for strings it is the empty string. The neutral element has the property that x op n = x for all x.