« first day (2418 days earlier)      last day (1606 days later) » 

12:00 AM
RELOAD! There are 6300 unanswered questions (90.0886% answered)
 
12:36 AM
 
12:59 AM
0
Q: Sum of primes under a certain number

J. CricksI have tried two different methods to find the sum of primes under a certain number. However both of these methods end up taking a very long time for large numbers. How can I optimise either of these two methods? Method 1 (Sieve of Eratosthenes): import time import math primes_in_range = [2] ...

 
2:01 AM
0
Q: Backtracking with Trie for Boggle

xyzThis is the code for backtracking with Tries. But the code is not able to find all 3 strings as mentioned in dictionary It is unable to traverse for SEE, SEEK. Could you help me figure out where I am going wrong. #define R 3 #define C 3 using namespace std; int used[R][C]; struct Node { ...

 
2:19 AM
thank you, posted on codereview — victor 54 secs ago
 
 
1 hour later…
3:23 AM
0
Q: Is there a memory problem? Confused with OOP style

pythonlover12345I developed an application for processing data. Below main function is called first when data was pushed to my application. def main(data_to_be_processed, target_method_config): module_name, class_name \ = target_method_config.get("module_name"), target_method_config.get("class_name...

 
3:44 AM
0
Q: T9 search function

Smith LoThis code I try to write based on last week codewars event that I joined which I can't figure it out during the event. The question is: T9 Autocomplete The file contacts.txt has names and phone numbers. The format is: column 1 = name column 2 = phone number Your program shou...

 
 
1 hour later…
4:59 AM
Monking
 
0
Q: read an excel that contains population data of counties and compute summaries by state, county

Siraj SamsudeenAs part of the exercise in the book "Automate the boring stuff with Python" chapter 13 on Excel, I had the following exercise: Reads the data from the Excel spreadsheet Counts the number of census tracts in each county Counts the total population of each county Prints the results Here is the ...

 
5:29 AM
0
Q: Further Optimizing a Segmented Sieve of Eratosthenes

daOnlyBGI've implemented a Segmented Sieve of Eratosthenes that assumes each segment is about length \$ \sqrt{N}\$ for some upper limit \$N\$. I further optimized the function by skipping all the evens when sieving. I'd like to know if anyone has any views or advice on further optimizing my implement...

 
6:16 AM
Your question is not providing enough information. This is confusing: Each data_to_be_processed was needed completed process, so I thought it would be fit for OOP code style. That's why I mapped data_to_be_processed for one object. Also check codereview.stackexchange.com, it might be better for your question. — Joe 50 secs ago
 
6:32 AM
Monking
 
6:52 AM
0
Q: Creating a round robin MySQL connection manager

Hooman BahreiniBackground I am working on an e-commerce website, my web server is written in ASP.NET MVC (C#, EF6) and I am using 3 instances of MySQL DB. These DBs are in a cluster (Galera Cluster) and they are automatically replicated. The problem the I want to solve is load balancing the the request among ...

 
7:06 AM
@CaptainObvious maybe my answer to this question will get me the Snaphat hat
 
7:16 AM
I'm voting to close this question as off-topic because you're really asking for a codereview.stackexchange.com. — deceze ♦ 8 secs ago
possible answer invalidation by daOnlyBG on question by daOnlyBG: codereview.stackexchange.com/posts/234164/revisions
 
7:33 AM
Oh, I see. I'm gonna delete this and re-upload at codereview.stackexchange.com. Thanks! — pythonlover12345 7 secs ago
 
-1
Q: How to throw exception in a switch case?

Bastien VandammeI would like to have some feedback on the best way and good practice to handle the default case in a switch: switch (name) { case "ant": return new AntProcessor(); case "parrot": return new ParrotProcessor(); ...

0
Q: JAVA Class for User-defined Binary data type

Riley JonesI have written a program for a user-defined binary data type in JAVA. It has static methods for purposeful usage methods for binary arithmetic methods for bitwise operations It's working as intended, but I feel the code is a bit too verbose. Any suggestions on how to shorten it? ...

 
@Heslacher found a bug in that, but it's subtle enough to not warrant nuke-closing
@Duga no invalidation from what I can see
 
I can't believe that I forgot about var!
 
also if your code works, maybe it's not the proper site to ask a question. Better suited for codereview.stackexchange.com — Jean-François Fabre ♦ 11 secs ago
possible answer invalidation by Hooman Bahreini on question by Hooman Bahreini: codereview.stackexchange.com/posts/234168/revisions
 
@Duga IMO thats ok
 
7:54 AM
-1
Q: Is this memory inefficient? Confused with Python OOP style

pythonlover12345I developed an application for processing data. Below main function is called first when data was pushed to my application. def main(data_to_be_processed, target_method_config): module_name, class_name \ = target_method_config.get("module_name"), target_method_config.get("class_name...

0
Q: To search a json string value in a list

saurabh kumarI am trying to search a json string(events) from a given list (eventSubscriptions).Here is what I have tried. import com.fasterxml.jackson.databind.ObjectMapper; private boolean isEventsOverlapping(String events, List<EventSubscription> eventSubscriptions) throws IOException { List<...

 
8:15 AM
1
Q: Updated: Questions on implementing Builder design pattern

simplisagarI am in the process of using Java Builder design pattern to write a connector class that has optional member variables and need some suggestions. My question from here Standard practices for employing Java Builder design pattern has been updated and the code now presented is not psuedocode but is...

0
Q: Immutable-Object-like Structure in PHP

BenniI made a closure-based PHP structure that behaves mostly like a classical object. To change the object's state, one must derive a new copy by passing the altered state to the newCounter() 'constructor'-function. If you alter $state inside a method without returning newCounter($state), the origin...

 
8:44 AM
Monking
 
8:56 AM
0
Q: Add index to duplicate entry in List<T>

phwtI wrote this piece of code to append index to any duplicate entry in List<T> like in the sample below. Input ["dupe", "not dupe", "dupe", "also not dupe"] Output ["dupe1", "not dupe", "dupe2", "also not dupe"] But the problem is it's O(n^2) in the second loop and I'm working on a large lis...

 
I think this would be better here codereview.stackexchange.com. Since you already have a working solution. — Cosmin_Victor 8 secs ago
Just a comment with regards to readability: For me, using var x = y == z; is idiomatic C# code and not something out of the ordinary, quite the opposite. I would comment on the more verbose way in a code review and propose the shorthand. — germi 26 secs ago
 
9:17 AM
0
Q: Str string contains value faster

Martin DorinI'm pretty new and I would like to know if I can make this code work faster. I created this code, and I would like to know if I can do something to get it going faster. Textbox2.Text like = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 Textbox1.Text like = 1,2,3 / 2,3,4 / 5,6,7 and so on. ...

 
9:58 AM
0
Q: CeWL written in Python

LinnyThis is my implementation of CeWL, a ruby application that returns a list of words which can be used for password crackers. My main concern is performance, as it takes a couple seconds to run. I presume it's mainly within the get_words function. Any and all feedback and criticism is appreciated ...

 
This would be better on the code review with code that someone can actually see to get peoples opinion — Mark Davies 7 secs ago
 
10:19 AM
0
Q: Interview Code Test: Webservice Checker

JensI recently applied for a job as a C# developer in a software company. Based on the first phone call, they wanted to check my skills with a code interview in Java. Since i haven't programmed Java for years i tried my best and i'd like to submit my solution for review (for personal improvment), bec...

 
Monking
 
JAD
@CaptainObvious C# interview asking for code interview in Java :S
 
@JAD and it's appropriately overengineered.
nice
 
JAD
not enough interfaces
> Date now = Calendar.getInstance().getTime();
See, no dependency injection on the IDateTimeProvider
 
10:49 AM
@Vogel612 User is German, of-course it's overengineered.
 
 
1 hour later…
12:02 PM
0
Q: Multiple conditions for same table in EF

MathematicsI am getting products using given parameters (name of real entity and columns changed for illustration purposes), public IQueryable<Product> GetProductsByPara(string price, string weight, string dimensions, string trend) { var result = dbContext.Products.Where(a => a....

 
12:46 PM
I think this belongs to codereview.stackexchange.comAnk 50 secs ago
 
1:04 PM
0
Q: Command line python script to generate image with n digits from MNIST data

schuimerA Python script to generate an image with a given number of digits from MNIST data on a single row. Via arguments, the following can be specified (all optional, with defaults if necessary): width of resulting image(s) minimum margin between digits maximum margin between digits number of MNIST ...

 
1:46 PM
This is not a site for sharing code you have written. If you have a specific problem to ask about, you can do so. If you are simply looking for improvements, try codereview.stackexchange.com. — chepner 49 secs ago
 
2:27 PM
0
Q: How to refactor linq statement (replace where with firstordefault(condition))

Roxy'ProHow could I modify this statement so I could move Where() condition which is related to products in FirstOrDefaultAsync method I've allready tried but it doesn't work because if I move it down than condition will become related to Brand class... var prod = await _context.Products.OrderByDescend...

0
Q: Run multiples threads

WarokI'm creating my own little toolbox for pinging IP (for the test, only in localhost). For now, scanning a class A IP range is pretty fast, but for a B range (65025 adresses) it's very long, Here is my code : #!/usr/bin/python3 import threading import os # Define a function for the thread def ...

0
Q: Debug TODO program JS

МишаняThis my code: let createOne = document.getElementsByClassName("butt")[0]; let menu = document.getElementsByClassName('topper-div')[0]; let cancel = document.getElementsByClassName('cancel')[0]; let apply = document.getElementsByClassName('apply')[0]; let titlee = document.getElementsByClassName(...

 
2:38 PM
@CaptainObvious broken
 
@Heslacher Just needs one more VTC.
Egads, my hats are multiplying.
And now I am the court jester.
 
3:08 PM
0
Q: ruby script for automating software install on a brand new Linux OS

Mateusz KoniecznyI have some scripts to automate software install, apply some configurations and so on after installing a new system. I used to have them as bash scripts but it was generally a poor idea. I have rewritten first segment into a ruby script. I am generally happy about it. But three global variables...

0
Q: Segmentation fault - Dijkstra's algorithm

Parth ShuklaI am making a ros node to implement dijkstra's algorithm on a 1000x1000 pixel map. The map is in the form of a row dominant matrix and I have declared visited, distance and prev in the same form. Distance stores the distance of each index and is initially declared with a huge number. visited is...

 
3:29 PM
0
Q: callback function with no dynamic memory allocation

shangaoren filehunteri tried to make a callback type for embedded, i know std::function and lambda but i know that there is some dynamic memory allocation that i want to avoid, i came to thant implementation : #pragma once namespace interfaces { template <class returnType, class ... parameterType> class ICal...

 
"yes but its so ugly." - Sure, but does it work? If yes and you just want to know a better way, then I think it fits better over at Code Review instead. If no, tell us what issues you're facing (errors? invalid response?) — Magnus Eriksson 46 secs ago
Again, if the code works, post it over at code review to let others review it and come with suggestions on how to improve it, if needed. If it doesn't work, post the code and explain the issue you're having, — Magnus Eriksson 57 secs ago
 
3:49 PM
0
Q: String parsing algorithm in Rust

RedDreeI have written a recursive parsing algorithm for strings with nested brackets (I needed it to solve a molecules to atoms task). I would love to see how I could make it more idiomatic (I am a noob at Rust an exploring a lot of APIs and other people's code) and/or efficient. Here are some example...

0
Q: Converting phone numbers to words with Python

MikeFor fun, I wrote a script to convert the last four digits (or fewer) of a phone number into a valid word. I wanted to see if my personal phone number could be converted into something like "999-9999-BEAR." I used the unix words file as my dictionary. I'm wondering how I could make this simpler, ...

 
4:31 PM
0
Q: Adding IP to ubuntu linux using bash

user367435I had wrote a shell script to add IP to Ubuntu method 1: ./script_name ip.txt method 2: ./script_name answer all question ask by script. script is printing IP on screen then select all IP and open interface file and append the IP. #!/bin/bash #add ip from file for ubuntu #add ip from range for ...

0
Q: HTML game engine within angular

sirzentoI currently have a very very basic js script that runs something 30 times per second. This is later to be used in a game engine. But now I'm not quite sure how I can best do that. This little script alone cost me some time to write. What could be improved here? function main() { var framera...

 
4:51 PM
0
Q: PowerShell script creates a computer list from an AD OU, and add exclusions to a specific file via Invoke-Command

xerxes2985My code is working, however, in the foreach section, when it runs the invoke-command if I don't use "-ErrorAction SilentlyContinue" the red error text that states a computer cannot be connected to shows up. The code still works fine, I just wanted to know if there is a way to add "nicer" text, so...

 
5:56 PM
That's because in my solution, I am reloading that 300GB file for every single worker created. Did you attempt to post on CodeReview[codereview.stackexchange.com/]? — wundermahn 44 secs ago
 
Greetings, Programs.
@Edward I met Stroustrup once at a conference.
 
(I want to avoid doing a code review here, since that isn't the purpose of this site. But, I'll see you over there :)) — wundermahn 18 secs ago
 
6:14 PM
0
Q: Feedback on Python Hash Table Implementation

Samuel Padilla I implemented a python Hash Table using only lists. Here is my implementation: class HashTable: # Initialize the table with a fixed size of 54 slots def __init__(self): self.Table = [None] * 54 def _get_value(self, key): #This is my hash function. # It finds the hash of every string. to...

 
6:34 PM
0
Q: Applying a machine learning model and generating a hyper plane which can classify different classes

Lalit Jainmy code: import matplotlib.pyplot as plt import numpy as np from sklearn.linear_model import SGDRegressor alpha_lst = [0.0001,1,100] outlier = [(0,2),(21, 13), (-23, -15), (22,14), (23, 14)] for i in range(len(alpha_lst)): plt.figure(figsize = (17,14)) k = 0 X= b * np.sin(phi) Y= a * np.cos(p...

 
6:46 PM
ask at code review — Orkhan Alikhanov 32 secs ago
I'm voting to close this question as off-topic because it belongs on Code Review. — Trenton McKinney 39 secs ago
Though the code is working I don't think it belongs on Code review. The issue here is using the wrong set of tools to solve the problem. Since there are no code restraints, it's less of a "code review" and more of a, here's my attempt, but how should this really be done, the answer to which is groupby + named aggregations. There's a dup somewhere. — ALollz just now
 
7:11 PM
@Edward Which edition, I have the first edition and the one for C++11.
The first edition was what was available when I started programming in C++ in 89.
 
0
Q: Maximum sum combination

nz_21I am trying to solve this question: https://www.codechef.com/problems/TADELIVE Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. It's known that the amount of tips may be different when handled by different delivery man. More specifically,...

 
@CaptainObvious To me that looks massively broken. Anyone else have an opinion?
 
7:35 PM
"can check this by calling printf". No you can't. It's not guaranteed to seg fault and in fact in many cases it may not. That's what is referred to as "undefined behvaiour" in C. Unfortunately the language doesn't have any easy way to check whether a pointer is valid before accessing it. There are some platform specific ways. But in general C programmers need to rely on development best practices such as code reviews, testing and debugging to root out memory issues like this. There are also tools such as [valgrind](valgrind.org) which can help. — kaylum 21 secs ago
 
@Peilonrayz Stephen fixed that.
 
0
Q: Source Control and Unit Tests

FlameHorizonContext This post will be related to the code request I asked for, some time ago. I would like to focus this time not strictly on the implementation of the SourceControl module, but rather on the Unit Tests. Link to the previous question can be found here. Dependencies To start working wit...

 
@pacmaninbw The first couple are a bit behind the time I'd say.
They're not wrong, but it's simply no longer industry-standard C++ what's in there.
 
7:50 PM
@pacmaninbw I mean the C++11 version which is titled "The C++ Programming Language, fourth edition"
I have the whole series back to the 1990 "Annotated C++ Reference Manual" but they're just of historical interest any more.
Still have my original K&R as well, but it's not really useful for modern C.
 
@Edward @pacmaninbw Can't miss it, has a large C++11 logo in the corner.
 
0
Q: Create 1% Sample Using Multiprocessing in Python

giacomo1488I'm trying to process a large dataset (300GB, myfile.txt in the script) line by line using multiprocessing. I want to define a 1% random sample based one variable (contained in unique_ids_final.txt). My first step is to define the sample and then I want to read the data file using multiprocessing...

 
8:06 PM
Monking
 
Monking
 
8:18 PM
0
Q: discord.js/node : filter().map() best method

PaddI'm learning javascript with discord.js and node and I'm always looking for the "best" code. Is this the "best code" for my map() ? ([role] required, (role) optional) // Get [role] (@role) args let roles = msg.mentions.roles.filter(role => (args[2] === `<@&${role.id}>` || args[3] === `<@&${role...

 
8:44 PM
This would be a better question for Code ReviewG. Anderson 17 secs ago
 
8:59 PM
0
Q: How to make this recursion function for prime number more efficient

MM1I have this code: def has_divisors(n, i=2): """ Check if a number is prime or not :param n: Number to check :param i: Increasing value that tries to divide :return: True if prime, False if not """ if n <= 1: return False if i + 1 == n: return True if n <= 2 and n > 0: return True if ...

 
9:10 PM
@Edward I too still have my original K&R C book, even though as you say it's not really useful anymore. I never bought the second edition which covered the switch to ANSI C, the company I was working for bought several and the internet is better than books that go out of date.
 
@pacmaninbw I still like physical books aesthetically, but agree that especially for rapidly changing computer information, internet resources are usually hard to beat.
Since I travel a lot, I tend to keep local copies of some of those internet resources, such as cppreference.
 
I still buy books, mostly SF and Fantasy. A few computer references are still good.
Do you buy ebooks?
 
That way I can still work even without internet connections.
I sometimes buy ebooks, yes.
 
I'm thinking about some pdf forms of computer references. I need a laptop with a bigger HD first.
 
I find that all of my reference material fits easily on a 256G drive.
 
9:15 PM
All of my IEEE mags are downloaded onto a separate HD.
I only have 256G on my primary laptop drive and the OS and visual studio burn up a lot of that drive.
 
I keep a bunch of IEC, IEEE, IETF standards and then a bunch of stuff in the category of "other".
Organizing it is not trivial, but I think I have a system that works pretty well for me.
@pacmaninbw You can buy a 128G microSD card for under US$25.
 
I also have a method of organizing it that works for me.
 
What's your method?
 
Currently have a 1TB external drive that's only about half full.
 
Mine's a simple directory structure.
 
9:19 PM
Mines also a simple directory structure
IEEE -> Publication -> year of publication.
Same for ACM.
 
Mine's by topic and then by source, but similar idea.
I've been wondering about using this:
It's an investment in time, but might be worthwhile for easier searching.
 
@Edward If I shared my documents that might be interesting, but I think it would be overkill right now.
 
Probably right. At the moment I use this:
1
Q: Create HTML page to document contents of directory

EdwardI often work on embedded system projects in which I have a number of documentation files, such as microprocessor datasheets, schematics, bills of materials, etc. I find it convenient to create a simple little HTML file that contains the file descriptions and a hyperlink to each file. I used to ...

 
Now that can be useful.
 
It's been useful for me. Since my native habitat is Linux, I use links to have the same document show up multiple places without actually storing it multiple times.
I think Windows has such a capability but I spend little time with Windows.
 
9:34 PM
I like using office, VS isn't bad. I'm slowly switching over to Jet Brains products for code development and that will work on Linux. My last Linux box died in March, I might buy a new Windows laptop and convert the old one to Linux. Do you prefer Ubuntu derivatives or Red Hat?
I had 3 CentOS boxes running for a while.
 
I've been using RedHat for decades. They're local to me here in North Carolina has a lot of ties to my alma mater, NCSU.
They also do a lot of very solid work on the kernel and contribute a lot back to the open source community.
 
Do you do any pro bono work on Linux open source?
 
Yes, all the time.
Usually I don't think of it as "pro bono" but as "this damn bug is really annoying" and one thing leads to another. :)
 
:)
Now that one I get!
 
My latest contribution was a bug report to the mutter project that was actually spawned by me trying to review a Qt project here.
3
A: Hunt the Wumpus Game (C++ with QT)

EdwardIn all this is a good effort and helped me discover and report a bug in mutter, so I learned some things, too. There are still some things that I think can help you improve your program. Fix the bug It's a minor bug, but if the player decides to play again, the Room::clear() method doesn't com...

I only filed the bug and haven't gotten around to fixing it yet, but hope to have some time over the holiday to do so.
 
9:47 PM
Sounds like a good plan.
 
I like the fact that work pays the mortgage and buys my food, but it sure takes a lot of time.
I'd retire tomorrow if I didn't value food and shelter.
 
possible answer invalidation by ebe on question by ebe: codereview.stackexchange.com/posts/233910/revisions
 
Had to sell my home of 19 years earlier this year because work was no longer paying the mortgage. I think I'd get bored if I really retired.
 
Oh, I'm sorry to hear that.
I used to wonder if I would get bored, but I have a lot of interests and they all take more time than I have.
My goal is to retire with both time and money left.
Not a particularly original goal, but it keeps me focussed.
 
It's almost EOD for you, have a good evening I'll talk to you soon.
 
9:58 PM
See ya!
 
10:41 PM
Seems like your question is more suited for CodeReviewnorok2 52 secs ago
 
10:55 PM
I ended up writing a container which integrated map and list into one: codereview.stackexchange.com/questions/233177/… No duplication — Oliver Schonrock 1 min ago
 
0
Q: Simple image segmentation app

Tom CI often segment images by hand to generate training data for machine learning models. To this end, I created a little TkInter app that displays images and allows me to export labeled polygons to JSON. I'm looking for feedback on the design of the project and coding style. import tkinter as tk f...

 
11:34 PM
@Edward Same
 
0
Q: Faster way to concat dataframes with different columns vertically

52gewg44I am trying to concat two huge dataframes (around 15GB) like the following: a_df: A B C D 2018-10-16 a16 b16 c16 d16 2018-10-17 a17 b17 c17 d17 2018-10-18 a18 b18 c18 d18 2018-10-19 a19 b19 c19 d19 2018-10-20 a20...

 

« first day (2418 days earlier)      last day (1606 days later) »