I'm writing classes to decode and persist Message's sent via TCP. Each message contains many DataField's. I have a simple class DataField class that holds some meta data, including a
private byte[] _content;
public byte[] Content
{
get
{
return _content;
}
set
{
...
@DanielMinnaar Yes, this is the workflow of TFVC Code Review. It is used to review the code before check in. You can refer to this link for details: visualstudio.com/en-us/docs/tfvc/get-code-reviewed-vs. The changes are stored in shelveset which is similar with changeset. And you can also suspend the work when you wait for the review feedback. So you don't need to worry about losing data. — Eddie - MSFT38 secs ago
I am attempting to find folders based on their last modified dates.
I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time
srcFolders = "C:\Users\Test\Desktop\Folde...
Define "correctly" because it could mean just about anything. If you can provide details someone may be able to tell you. Also, "correctly" may be too subjective for this site, you might try codereview or Software Engineering instead. — D.B.42 secs ago
Hey all I'm new to this site. But what I want to know is there anything out there that I can use to translate my cache data. Maybe like a android source code translator or something?
--- Day 5: How About a Nice Game of Chess? ---
You are faced with a security door designed by Easter Bunny engineers
that seem to have acquired most of their security knowledge by
watching hacking movies.
The eight-character password for the door is generated one character
at a...
I am supposed to create a guessing game in java where the user can either choose 5 guesses, 10 guesses, or 20 guesses. I need to create a loop for the guesses but I can't seem to figure out how to.This loop will iterate as long as the user hasn't guessed the number and hasn't reached the limit of...
This function finds the 8 char passcode from a given "doorId".
Is there a way to find the passcode in an undetermined number of steps without using a while? Maybe involving streams? val passcode = stream(logic).take(8).
def findPassCode(doorId: String): String = {
var passcode = ""
var coun...
public class Game {
private int rolls[] = new int[21];
private int currentRoll = 0;
public void roll(int pins) {
rolls[currentRoll++] = pins;
}
public int score() {
int score = 0;
int frameIndex = 0;
for (int frame = 0; frame < 10; frame++) {
if (isStrike(frameIn...
In February I was hired as a Software Developer Apprentice, I mainly code in c# which I have learnt on this apprenticeship. I am currently rewriting a programme the company currently uses. Within this program I have to use iTextSharp that I have never learnt, to create a PDF using all the winform...
If I was like that, I would never have completed my internship, even.
There were at least two times in those 12 weeks, or so, that I didn't know what I was doing when I started the day, and felt like I knew less at the end of the day than at the start.
For me, though, if I say I'm going to do something, I'll do it.
That's actually how I get my papers done when I'm procrastinating--I tell my mom that I'll get them to her for review by a certain date, and I do it.
I have an ideal code which I would like to test out a way to produce the same results in the code without the use of arrays. At the moment I'm not too sure how the best way to approach this code would be, as I'm also trying to make the code simpler to deal with!
It's about a bowling game that gi...
I'm wondering if the use of a dictionary for all the data members of the class I'm working on is bad design
class RunLengthEncodedParser:
"""
Parser for Run Length Encode (RLE) strings / files.
More information: conwaylife.com/w/index.php?title=Run_Length_Encoded
"""
def __init__(self, rle_string):
self.rle_string = rle_string.strip()
self.lines = rle_string.splitlines()
self.fields = self.get_fields(self.lines)
def get_fields(self, lines):
"""
This method performs all the string parsing required to get the various
fields of data into a dictionary to be used by the calling code.
Come to think of it there is not really a reason per se to use a dict, since this class isn't meant to format the data in a specific way for output, rather just to parse data fields from a string to make it accessible to the calling code
I used a dict, like you, because I like it, they're pretty, but they make the code probably more complicated than it needs to be
Iam trying to understand the Implementation of strnicmp from linux source code.
http://lxr.free-electrons.com/source/lib/string.c
I just tried to implement it without extra variable c1 and c2 and added some condition in while.
int StrNiCmp(const char *s1, const char *s2, size_t len)
{
if(!...
Yep. And with this, my program is officially complete! I'll probably move on to code review if they have any expert opinions on my straight forward code. — Aroueterra21 secs ago
Here is my code for simplifying a Unix path. Any advice is highly appreciated, including higher efficiency from an algorithm time complexity perspective, or any bugs.
'''
Simplify Unix path
Given an absolute path for a file (Unix-style), simplify it.
For example,
path = "/home/", => "/home"
path...
I would like to re-render my WPF chart control when data source is changed. My minimum requirement for a data source is IEnumerable<Point> but it could be also ObservableCollection<Point> or BindingList<Point>, so collection change notifications are sometimes becoming available.
Chart Serie clas...
Working on below problem to sort array by low, medium and high -- in-place tweak original array. Here is my code written in Python 2.7 and looking for advice, especially any algorithm implementation efficiency advice. My current bottleneck of implementation is, I have to do partition twice, by lo...
name: Gosper glider gun
comments:
['This was the first gun discovered.',
'As its name suggests, it was discovered by Bill Gosper.']
author: Bill Gosper Nov. 1970
size_x: 36
size_y: 9
rule_birth: [3]
rule_survival: [2, 3]
pattern_raw: 24bo$22bobo$12b2o6b2o12b2o$11bo3bo4b2o12b2o$2o8bo5bo3b2o$2o8bo3bob2o4bobo$10bo5bo7bo$11bo3bo$12b2o!
human_friendly_pattern:
........................o...........
......................o.o...........
............oo......oo............oo
...........o...o....oo............oo
Link to API Homepage
Link to github page
I would like to know all the bad things I have done in my code and ways to rectify it.
Thanks and Regards,
Dhanushu
I wanted to be able to parse Run Length Encoded (*.rle) files into something usable for a cellular automaton simulator (e.g. Conway's Game of Life and such).
Here is my main method which has the code I used for manual testing. The example file is taken from the above linked wiki.
def main():
...
This is my crude attempt at implementing a counting sort algorithm. My goal is to be able to sort lists of ints, negative and positive. As you can see I've employed such hacks as return res[1:] to get by. I'd appreciate any feedback I can get to make this a more pythonic implementation.
def find...
if __name__ == "__main__":
try: # create inside of PROJECT_HOME if it exists
PROJECT_HOME = os.environ[PROJECT_HOME]
except KeyError: # otherwise in user's home directory
PROJECT_HOME = os.expanduser(~)
home = os.path.join(PROJECT_HOME, 'test_directory_tree')
What i s...
I recently got feedback for a programming assignment that was positive but mentioned that 'some things could be done better', and I was wondering if anybody here might be able to give me a more specific idea of what could to be improved & why.
There's quite a bit of code, but as I'm at a very i...
I am learning Rust and finding it quite a difficult but rewarding and fun challenge to learn how to write idiomatic and succinct, clean code in it.
I have written the following simple naive JavaScript scanner code as an exercise to learn some basics of Rust. While it works it feels like it is f...
Write a C program to create a simple calculator that performs arithmetic operations (add, subtract, multiply, divide, modulo, and exponent) using switch case. The calculator should read two numbers and an operator from user. The calculator should perform operation according to the operator entere...
I have completed the following coding exercise. However, I got poor result for testing. I need some help to find out what is missed, incorrect, or incomplete in the testing section. I would appreciate it if anyone could please point out any mistake in the testing section or possibly any improveme...
The problem is from the cracking code interview problem 3.3:
Stack of Plates: Imagine a (literal) stack of plates. If the stack
gets too high, it might topple.
Therefore, in real life, we would likely start a new stack when the previous stack exceeds some
threshold. Implement a ...
I am attempting to find folders based on their last modified dates.
I can get the dates and folders (or directory names) but I'm unsure as to the best way to check that they are before a certain date.
So far I have:
import os, shutil, stat, errno, time
srcFolders = "C:\Users\Test\Desktop\Folde...
@Graipher Indeed. And @MathiasEttinger there's no reason to delete your answer. At least, that's my opinion ^_^ As Graipher suggested, just edit it a bit :p
i have this piece of javascript code (using jQuery) which is 158 Bytes :
$("#b").click(s=>{t=$("#a").val();o=[...t];for(p=0;p<t.length;p++){r=Math.random();if(.1>r)if(.03>r)o[p]=t[p--];else r>.07?o[p]="":o[p]+=t[p]}$("p").html(o)})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2...
This is a project i have been working on. Any recommendations for improvement
#A variable to count the number of bags processsed
count = 0
#The function to check the weights of the bags and display the number of coins needed to be added or removed
def check(bag_weight, coin_type, bag_weight1):
...
I have 3 questions to the following code.The goal is to assign a HEX-Value to a byte in a byte array and then send this byte array to a serial port. If the value is bigger than 255 the corresponding HEX-Value is supposed to be split into two
Example: 750 = 0x2EE so A[0] = 0x2 and A[1] = 0xEE
...
I have a java application that migrates data from one database to another.
I have to do update data in my database with data from another database. Another database provided by the customer.
Now it is this way:
I make a request from java application to my database(oracle) to get the address and...
That's not what this area is for.. This is to address specific problems. You should post over at the code review stackexchange site.. And for future reference you should paste your code into the question, properly formatted. — Pro Grammer5 secs ago
A couple of quick code review comments: 1) your subscribe() method seems to have the return codes swapped, 2) your unsubscribe() method does not decrement size. — jarmodjust now
I am a beginner in C and I am trying to write a C code to generate a graph G(V,E) but facing the following problem:
The code generates a table [Max(t-1)][2] with repeated pairs and duplicates and I need to remove them. The pairs in this table represent the edges.
What I want to do is to define ...
I replaced the thread by a task so there's no thread locked when there is no job to execute for hours.
Now i'm not sure if the lock without an AutoResetEvent is lock safe when AllowParallelExcuteion is set to false.
public class BezJobManager : IBezJobManager
{
private CancellationTokenSou...
If someone successfully set up a phishing website on a fake wireless network for say, bankofamerica.com, and lets pretend that SSL was not used, would they be able to run a script on the server that reads the cookie contents of anyone who connected to it (for example, a long-term authentication t...
This question is fine and on-topic, but please note that when you have questions about how to improve working code, codereview.stackexchange.com might give you better and more detailed answers. — Lundin1 min ago
If your code is working and you want to optimise it, this post should be on code review. Lundin said it first. — Brandon Ibbotson56 secs ago
I am designing the application in Asp.net MVC, which will have multi tenant database structure. My concern is, what is best practice to store user details for tenants. Whether in shared database or respective tenant databaseS. Or just store tenant connection string in master database and actual u...
@MichaelWalz I went back and forth with whether to comment or answer. I decided on answer because there is no real way to get an efficient solution as far as computational complexity is concerned and outright code review is a separate problem for a separate site. Good arguments can be made for commenting too, I agree. — Andrew16 secs ago
A python program made with a friend to draw n dimensional hyper-cubes in python using turtle. Any suggestions for improvement.
import turtle
from turtle import *
import time
import math
n = int(input("How many dimensions?: "))
length = int(input("How long is each side?: "))
angle = (math.pi/18...
I'm new to this site... I've been practicing for a coding interview and I had to do the following program (I'm using C# btw)
Given N and M find all stepping numbers in range N to M
The stepping number:
A number is called as a stepping number if the adjacent digits have a difference of 1.
e.g 1...
@Dex'ter I've got a laptop. Two ESXi systems running the core of my network infrastructure (DNS and web proxy), several servers I use regularly (gitlab, owncloud, my Ubuntu builders for packaging, etc), and quite a few other development testing systems
my laptop always works, the rest of the stuff needs to be online :P
(only the network equipment have backup power right now, and that's not enough)
Program to calculate primes. It is not very efficient once it gets to bigger numbers, does any one have any suggestions as to what I can do?
import math
f = open('Primes.txt', 'w')
def Primes():
PrimeList = [2]
i = 1
while True:
Prime = True
i = i+2
for n in ...
I didn't know whether it was best to start with the general task I'm trying to solve, or the meat of the programming problem. They're both below but the former is rather long and solving the latter may not require it, so feel free to skip at will.
The task to be solved
I'm running a relatively ...
Following these two SO questions:
Find duplicates for mixed type values in dictionaries
Group similar dict entries as a tuple of keys
I came to the conclusion that the solution I proposed is mature enough to be reviewed here.
The idea is to find duplicates in a dictionary such as example b...
Here is a code I would need to make far more faster: it is made to analyse more than 3000 DNA sequences of more than 100 000 characters each.
The matter is I have to compare it by pair, so that would be around 3000*2999/2 = 4498500 calculation and each takes 1 to 2 seconds...
Could you think ...
Walter Bright is the father of the [D programming language](http://en.wikipedia.org/wiki/D_(programming_language)).
I think it's interesting to note that most of these famous developers have rather low reputations (Jon Skeet excluded of course) it almost makes you think they have better things t...
> it almost makes you think they have better things to do with their time...
This question belongs on Code Review as there is no immediate problem. However, as the Code Review guys have wisely barricaded themselves from accepting everyone-else's dross, that is not a reason for closure that I can specify. So I have just voted it as being off-topic for Stack Overflow. — Borodin55 secs ago
Some code that does not seem to be working properly. It is not yet finished so don't worry about efficiency.
import time
CellListIn = [[0,0,0,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,0,0,0]]
NextListIn = [[0,0,0,0,0],
[0,0,0,...
I'm voting to close this question as off-topic because it belongs on the Code Review board. — Bob Gilmore36 secs ago
@BobGilmore No! Code Review is not a debugging service. Aside from that, it's stripped from it's context and would make a lousy question at Code Review. Please take a look at their help centre. — Mast51 secs ago
@Borodin Based on this Code Review meta post I wouldn't be surprised if they refuse migration. This question belongs on SO as far as they're concerned. — Zaid32 secs ago
For code reviews, please go to [codereview.stackexchange.com](codereview.stackexchange.com) — Algirdas Preidžius32 secs ago
I'm voting to close this question as off-topic because this question should be on CodeReview SE — Fred Larson52 secs ago
@Borodin to follow up, I seriously had no clue Code Review even existed. Thank you for letting me know about it. There are so many stackexchange sites, I feel really swamped, but that is useful for me going forward because I know it's something where I make big mistakes. — aschultz26 secs ago
@Hosch250 That question turned into a mess. I'm not sure it should've been handled the way it did, somewhere in that list of edits it probably went against intent.
@FredLarson That's still not a valid close reason. Close if it's off-topic here, it's quite irrelevant whether it's on-topic somewhere else, Code Review or elsewhere. — Mast6 secs ago
@George That hint was already provided by Algirdas. Closing it as off-topic because it might be on-topic somewhere else is a bogus practice and should cease. — Mast10 secs ago
@Hosch250 I'm not saying you did anything wrong. But the revision history looks messy at best.
I was testing the RGB color mechanic on excel. So I did the following.
sub paint()
red = 255
blue = 0
green = 0
Max = 48
For col = 1 To Max
For Row = 1 To Max
Cells(Row, col).Interior.Color = RGB(red - col * Int(256 / (Max * 2)) - Row * Int(256 / (Max * 2)), green + col * Int(256 / M...
I wrote a script that adapts html tabs for different screen resolutions. On small screen it's an Accordion and on wider it's a Tabs. The script is for production site, and I'm not so good in JavaScript yet as i wanted, so asked your help. Please, show me the weaknesses edges. Thanks.
(functi...
Looks like I should have post this on code review. before I start a war, if it needs to be closed. Go ahead. I'll post it on code review. — Big Head43 secs ago
I wrote a simple c++ program. The idea of the program is to serve as a data accumulator collecting Monthly expenditure from a user and later display it.
I wanted to implement classes/methods and just basic stuff that I understand to help me get better at writing better c++ programs.
Anyway, thi...
The code I have is based on BFS and a little bit of dijsktra and returns the shortest path of an unweighted directed graph as an integer. I was wondering if someone could take a look at my code too see if any thing could be changed or improved:
public int bfsshortestpath (V source, V target) {
Map<
I recently started working with asyncio and coroutines. I have a coroutine that runs every 0.25 seconds to print "running ..." on screen indefinitely. When the script receives a SIGTERM or SIGINT it will exit gracefully.
I figured out that there are two ways to do that:
Method A: Run a while T...
While solving one question I got stuck with a time limit error. The main objective in question is to count numbers in an array \$A\$ that are either divisible by \$P\$, \$Q\$ or both.
Input format:
The first line contains a single integer \$N\$ denoting the size of
array \$A\$. The nex...
I have this short Python script for making images brighter:
import skimage.io
import math
import sys
def square_root_filter(input_image_file_name, output_image_file_name):
image_data = skimage.io.imread(input_image_file_name)
image_data_height = len(image_data)
image_da...
today I've reached my record in procrastination and coding speed: I wasted 44 hours for nothing and in the last 4 hours I read documentation like 15-20 pages a minute
@Incomputable Well, if you post it here, we can poke holes into it. Then it will leak... whatever it is that leaks out of programs. Ewww. GET IT OF ME.
@Sumurai8 you won't be able to sleep after the nightmare you will see. Though I wouldn't say it is overly complex, just lots of repetition and may be not so idiomatic (it is Qt). I'll perform first iteration of upgrades and post it here
I actually got surprised how not intuitive interface can be. I think that Qt is a company that could win a prize on the most weird interfaces ever created
I am thinking about a game engine like this:
I am trying to implement a message based communication:
Every ReceiveMessage() method processes the Message or forwards it into the right direction based on the message's recipentType.
Example:
EngineCore's infinite loop sends RENDER messages towa...
I am writing a class library and I have made a single class to handle all rest traffic to the API server. I am seeking input on if this appears to be a good implementation and anything that could be changed to streamline this.
public class Web {
private final String account, username, password...
im using the following code which is working.
The code provide range of random values but unique one i.e. it doesn't return the same values until the full range was provided ,what do you think and doest in ES6 there is shorter way to achieve this?
var range = [10, 20];
var not = [];
function r...
what do you think about my code? I am a beginner and just started doing some algorithmic exercises to sharpen up my python skills.
Here is code for problem #1:
"""If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
F...
that answer said: I'll look into it on monday. I wrote a mail this "morning" and again got an answer saying "I should get to at least some of it today". And I haven't heard back ...
alas, I'll just bugger him again tomorrow if I don't hear back. I even warned him ;)
I'm also now refactoring the optimization phase of my BF compiler in order to separate two parts of optimization and as a result have less bugs, but now that thing is bugged and I'm freaking done with it (for now)
I am building a screen recorder extension for Google Chrome, it works as expected but I am deeply considered about the performance since it chucks data collected through screen sharing and microphone. I would love to get your feedback on how to test my code and how to know its limits through test...