This is the second time I am writing any practical JavaScript so it is pretty likely that I have messed something up.
I am beginner, so just need a piece of advice before sharing the code: Do I need to be more focused on writing maintainable and flexible code or do I need to be more focused on wr...
I implemented a simple java virtual machine in C.
Here it is: https://github.com/phillbush/jvm
It includes two programs: javap(1), a java disassembler; and java(1), the jvm itself.
It does not have a garbage collector nor exception handler yet, but I want to implement them (but how should I do it...
I was trying to implement a generic PriorityQueue in C#. Below is my implementation which works fine as per few test cases.
Operations supported-
Add: Adds an element
Poll: Removes the smallest element and returns it
Remove: Removes a specific element (only first occurence) and returns it
Clear:...
I am trying to code up a basic combinatorial math library for C++. Started with the implementation of the factorial function. Here I include the code and the test code. Please review.
Is the way of throwing argument exceptions the best way to do it?
Am I using the Test code the correct way for t...
This would be a matter of taste and opinion, so this question is not a good fit for SO. If your code is working as expected and you want some advice to improve it, you might want to have a look at codereview.stackexchange.com . Anyway, the more complex a task becomes, the more you'll find different ways to do it .. — Thierry Lathuille22 secs ago
I made a scripting language (interpreter) in C. The codes are too long, and I can't paste all of them it in here.
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "functions.h"
#include "lang/constants.h"
#include "lang/names.h"
#include "lang/lang.h"
I have this method that I feel has code repetition that can be improved but since I am new to GO, I am not quite sure how to improve it. I would appreciate if anyone can give me their opinion.
func (c *Configuration) loadFromEnvVars(key string, target interface{}, optional bool, defaultValue inte...
I have a project where I publish and subscribe some data packages. Mostly those data packages are just one package, but sometimes (1 in 100) there could be more packages at one time (a lot more, like 100.000 at the same time) I have a class PacketTransport which only has a IDataPacket property in...
@potong yes, you're right. I missed handling that case, which was probably needed in the OP's problem. One more reason to love code reviews :) — Ionuț G. Stan19 secs ago
I have this method that I feel has code repetition that can be improved but since I am new to GO, I am not quite sure how to improve it. I would appreciate if anyone can give me their opinion.
func (c *Configuration) loadFromEnvVars(key string, target interface{}, optional bool, defaultValue inte...
SO is not a code review platform so I primarily try to solve questions in the scope given by the TO. Nonetheless, I added a solution that doesn't involve querying already modified elements. — shaedrich46 secs ago
This is my first post here and I'm not sure if this is excatly the right site to ask my question.
Anyways, I have developed an gym managment application in which you can add new members,add membership for members,measurements, equipment,services for eqipment and stuff like that.
I also have added...
If you love code reviews may I offer some more? First, the . matches any single character so I think you intended \.. Second, {...} group commands but are unnecessary for a single command ,so /^text/! b loop would be suffice. Third, since that single command is flow control, it infers anything following does match and so another match is not necessary. Finally, since the -n` option is invoked, a p command or flag is needed to print lines and should be placed outside of the chain of commands that constitute the solution as a catch all. HTH — potong39 secs ago
@TobySpeight @Heslacher Since this isn't the first time the question has popped up I had a look around and I can't add a CR.Meta->CR.Main migration target. We can ask a CM, via a meta post, to add a migration target
However, I'm not sure one is needed. We don't get them often, and normally (above 50% of the time) I'm not asleep :)
A single migration away from meta in the last 90 days... It doesn't seem to be relevant, especially considering that off-topic questions should be closed on meta instead of being migrated (and then rejected)
I'm trying to learn C++ by making problems on HackerRank and I've come across this problem: "Cycle Detection" where I need to find if a linked list has a cycle (A linked list is said to contain a cycle if any node is visited more than once while traversing the list): https://www.hackerrank.com/ch...
@Peilonrayz Thanks for considering whether it would be useful. I didn't have a strong opinion either way, but thought I should ask the question and find what the community thinks.
I usually pick parts of the question and post my opinion about how to make it better. Sometimes/often I the have the whole code (which is targeted by my answer) at the end with a comment like Implementing the mentioned changes leads to then the code
Well, I did include a list with the positive changes at least. I'll leave it be. Trying some generator Fu in Python now because I'm having fun. I just removed the max argument from cycle, but now I need to make the cycle code even easier.
Darn, you can hardly see the difference between code and code here.
`def crypt_xor(message, key): result = bytearray(message) for i, k in enumerate((key[i % len(key)] for i in range(len(message)))): result[i] ^= k return result `
``` def crypt_xor(message, key): result = bytearray(message) for i, k in enumerate((key[i % len(key)] for i in range(len(message)))): result[i] ^= k return result ```
@MaartenBodewes I did that for some of my reviews on beginner questions to allow the OP (and other readers) the decision of reading the resulting code when applying a concept I introduced.
I've now decided to create a spoiler alert on top of the code, it is very much below the review anyway. Dang, the one liner doesn't come to me, and I know it is possible.
PS "am I doing this right?" is not really on-topic for Stack Overflow (go to CrossValidated for statistical questions, or Code Review ...). If you specifically want to know how to plot the results, please ask that question more explicitly. — Ben Bolker55 secs ago
Taking forward the combinatorial library link, I have tried to implement the nCr function. Please mention if this is prone to failing somewhere
Any other test code that needs to be added.
Any more efficient way to code this.
N.B: I am aware that overflow handling has to be taken into considerat...
@MaartenBodewes You may want to check if a list comprehension is faster than a generator expression. Because Python tends to have optimizations for lists.
# Generator expression
return bytearray(m ^ key[i % len(key)] for i, m in enumerate(message))
# List comprehension
return bytearray([m ^ key[i % len(key)] for i, m in enumerate(message)])
@MaartenBodewes No, Python lists are arrays on the backend and function similarly to how the bytearray builds a list.
Spent 50 minutes today with a coworker to figure out that everything in an app was working as intended, except that a button had white text on a white background with a white border
Wish I had one right now, my AndroidDeveloper doesn't seem to like the USB ports of the Linux machine that I created, so I cannot test on the phones themselves.
Very nice and I love that the internal implementation is shown! Note that a friend on CodeReview indicated that list comprehension is slightly faster still, so e.g. arrays(gen) is slightly slower than arrays([gen]). — Maarten Bodewes39 secs ago
I build the Shortest Path to Get All Keys algorithm in JavaScript. It's working properly, but with a really bad performance.
The problem:
You are given an m x n grid grid where:
'.' is an empty cell.
'#' is a wall.
'@' is the starting point.
Lowercase letters represent keys.
Uppercase letters rep...
I made a simple BlackJack game and I want to make it as good as possible before I move on to creating a few other games in my "casino" - let me know how I can improve it I added a few things here and there if you are interested my GitHub for this project is linked:
https://github.com/sharoika/Cas...
Currently I am creating an app in Tkinter that creates, displays, and saves sticky notes. I am new to python so I keep trying to rewrite my classes so I have my code more organized but every time I try to create a separate class that inherits from my root class, it quits working properly and won'...
Hi Everyone, this is my first bash script ever.
I would really appreciate it if you could provide me with some comments and insights regarding correct function use, logic implementation, and a lead to how to implement the recursive functionality described in the script's body.
Thanks a lot!
#...
I like Linux / Ubuntu better, much better internal system. But since they made Ubuntu a first class citizen of Windows now, I may run them together, as there are still very annoying audio bugs, login bugs and various other bugs when using Linux, and I'm pretty restricted when it comes to game support as well. Even CS:GO, although best handled well Stream, has serious issues sometimes. Kudos to them for at least trying to fix them all the time.
@MaartenBodewes My PC is Arch. I find Steam's Proton compatibility layer to be really solid, and really like being able to play every game my friends have wanted to play because of it. I'm hoping if the Steam Deck blows up, Linux support becomes a bigger issue and gets more support. However my laptop is Windows because I don't want to maintain 2 Arch systems... and, after first time setup, I think WSL is really good. The only problem I've ran into is the complete absence of systemd.
I have just finished making a maze maker. I took inspiration from this video, but its my own implementation. I just wanted to know what you guys thought of it and if there are any improvements that can be made like
Improving the way the algorithm is implemented
If the code should be less verbose...
I think it is a known issue. I think I've got it fixed, but all my trying around broke some things as well. This is always the case when I run Linux - I get an unstable environment because I try and fix things from the internet. Usually I have no idea what I'm running, I just hope that it is somewhat correct. I cannot know everything about the windows environment, all the possible startup and services, USB drivers and whatnot
Your question is too broad, but I encourage you to try again when you have a more specific question. Architecture proposals are not within the scope of stack overflow. Without knowing more about your current architecture and goals, it's very difficult to provide useful input on the appropriate implementation. However, codereview.stackexchange.com may be a potential place to find a useful review. I would hazard a guess that if you do a good job with the implementation, Go will do an excellent job for you - it excels at async and concurrency. — Daniel Farrell42 secs ago
if you post on Code Review please read the help center pages like How do I ask a good question? - in its current form this post would likely be considered off-topic because there is no working code posted to review. — Sᴀᴍ Onᴇᴌᴀ42 secs ago
So, I've done this problem on CodeWars: Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. The input will be a non-negative integer.
Examples: 16 --> 1 + 6 = 7
942 --> 9 + 4 + 2 = 15 --> 1 ...
This is a still incomplete file manager for X11. It can only navigate
through directories, select files (and do nothing with them), call a
script to open files, and call a script to produce and cache thumbnails.
Here is the git repository: https://github.com/phillbush/xfiles
To test it, do the f...
This is a simple implementation of the calendar(1) utility included in some UNIX systems (all BSDs have it, GNU has not).
Here's the manual:
CALENDAR(1) General Commands Manual CALENDAR(1)
NAME
calendar - print upcoming events
SYNOPSIS
calendar [-l...