All Questions

64,711 questions
Filter by
Sorted by
Tagged with
100 views

Distance on a ring [closed]

I work with objects that are marked by sequential unsigned numbers. When number reaches max value, it becomes 0 again. To detect breaches in the numbering, I calculate distances between them (b is ...
2k views

SQL connection string builder, initialized in two ways [closed]

For a while now I have been using string builders in my code. The way I currently do this is using the code below: ...
817 views

Reading bytes from file to compute its SHA256 hash

I need to get text hash (sha 256), so I need to convert file to its type representation. Is this a fast way to get a byte representation of a file? ...
103 views

I'm newbie in Swift and Rx programming. Is my below code is declarative ? If not, please rewrite it and explain to help me more understanding about declarative :( (my English is so bad) ...
114 views

Searching for topic categories using mysqli [closed]

Is this code safe from injection, xss and whole other attacks or no ? The below code is for search box : ...
3k views

ASP.NET MVC multi language website

What is the best way to make an ASP.NET MVC multi language website? The following code is what I use, but I need to make sure from your real-world experience that my code is the best way for ...
56 views

Improving User Class structure/design [closed]

I recently got into OOP, because I'm working on a big project and want to make sure my code is easy to maintain & scalable. My question is - how could I go about properly structuring the ...
1k views

Cartesian product in Scala

I'm using this code to compute a cartesian product: ...
728 views

Simple PHP SSH2 Class

I've written a simple PHP SSH2 wrapper class. Please review the code and point out mistakes. ...
120 views

PHP Dependecy Injection Container

A few weeks ago, I asked for another DIC review, but didn't get any response (but only for one about my error handling). So I tried to rework my DIC without any outside insight on it, and the first ...
336 views

EF Code First BaseContext-class [closed]

I've seen a tutorial where a dbcontext base class is created like so: ...
42 views

...
168 views

Python 3 code for a binary search tree [closed]

I am working on a python3.6.5 question about BST: Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left ...
57 views

Login to a school system and get account type

I'm new to MySQL database design. My question is this database is correctly built or not. We used the users table to login and get account type and here the code to login ...
152 views

Why does this scala code only execute the last future when necessary? [closed]

From https://www.chrisstucchio.com/blog/2013/actors_vs_futures.html: A very nice feature of Futures is that they are highly composable. Consider the following problem. I want to return an HTTP ...
8k views

Randomize a jQuery object list

Well this was a simplest code competition at my work. I tried a couple things, they accepted but none of them is I wanted. Because both are always giving same result. I tried to randomize like this <...
1k views

Mysql flexible insert record with bind_param or bind_value

I want to insert rows in a database table with the precaution of SQL-injection. I'm using below flexible MySQL insert function, which enters a record in a given table. Is this the best approach or is ...
76 views

Open/Close Principle in front GUI element [closed]

I'm working over project for my studies. It's a simple program about brewing coffee. I'm thinking about solution for showing single parameter in GUI. I have a source brew parameter class: ...
92 views

Reduce repetition in SCSS for panels of various colors

I have the following SCSS and I'm curious as to how I can improve it, and reduce the amount of repetition... I plan on adding more colors, but I don't wish to keep copy/pasting the same block over ...
2k views

“ChocolatesByNumbers” challenge

Here is a problem I have attempted: Two positive integers $N$ and $M$ are given. Integer $N$ represents the number of chocolates arranged in a circle, numbered from 0 to $N − 1$. You ...
90 views

Using a lot of IF in loop WHILE to print information

I made a code and it is doing what I want. But, I would like to know if I am doing it right or in the best way. Could you please give me your thoughts about it? Thank you. ...
1k views

Finding dice roll results in a combinable list of numbers

This code takes a selection of numbers between 1 to 9 which could be 1,2,3,4,5,6,7,8,9 or 1,2,4 or ...
791 views

Pascal's triangle with memoization

Problem: Pascal’s triangle is a useful recursive definition that tells us the coefficients in the expansion of the polynomial (x + a)^n. Each element in the triangle has a coordinate, given by ...
2k views

An exit condition for a do-while loop using lists [closed]

I have an integer list l and a predefined integer value row (which is never manipulated inside the code). If value of row is 5, then I want the loop to exit if <...
216 views

Find and replace a string in C/C++ without using standard library [closed]

I'm solving a problem with find and replace a substring in a string. I've solved it using Python with a couple of lines, in C++ using std library and now solved it with C by using allocation on the ...
76 views

Translate a day in year to month and day 2nd method

Take an integer representing a day of the year and translate it to a string consisting of the month followed by day of the month. For example, Day 32 would be February 1. I've already submitted my ...
162 views

Simple Python script seems to stop when N >> 1

Edit : So I let the code run for 70 hours and it did not return. Thus I stick to my point, it does get stuck on something, fails silently and let the bash hanging. From the time increase compared to ...
246 views

Euclidean distance between documents

For each function, I am manually adding another case. Can this be somehow shortened? Case and function names are the same. For example, the Euclidean_Distance case ...
7k views

Comparing 2 ints without using comparative operators

I was looking for questions that might be asked in a technical interview and I found this one: Write a function that determines if two integers are equal without using any comparative operators. I'...
182 views

Is this correct way to use loops or should it be in LINQ?

The results variable is coming from an API that have a arrays in arrays, etc. I have made a foreach with ...
131 views

...
230 views

...
138 views

volatile variables and parallel streams in Java [closed]

For the Below code want to know whether the correct procedure is followed for the java code , are there any missing points according to the java standards ? ...
553 views

Setting up tab bar, navigation, and view controllers in iOS

I am new to iOS development. I wrote this code, but the company said that this is bad architecture and is not acceptable. I want to improve this code. ...
95 views

Array to function to int arithmetic

I want to get the value of an integer from within a struct pointer. Simply: int cool = *(*(&(coolPtr->map)) + x); can this be simplified? The rest of the ...
814 views

...
452 views

Assigning movements to counters for a board game, using die rolls. [closed]

I have finished writing a program, and was wondering if I could make it any more efficient or generally more sophisticated that the current version. The below section of code is where I think ...
673 views

A struct within a class [closed]

I have a struct lying in a class as below, which I think is not good. Structs should be in a separate file, however, in this case, this struct is only used in a ...
137 views

How does this refactored code make my code better? [closed]

According to my lecture notes, there are benefits to refactoring the code from original code to refactor code. Reasons for refactoring: Replace Temp with Query You are using many temporary ...
164 views

Find target sum of 3 from and array

Input is a sorted array and a target sum. Find all sets of 3 unique elements that sum to a target. Looking for lowest order (big O). A, B, C are the indexes on the sorted array. A < B < C ...
71 views

...
168 views

On Finding Coin Jams

The problem can be found here and is essentially asking us to generate J many numbers containing N many digits, where these digits have to be either 0 or 1. The catch is that the these numbers that we ...
439 views

...
7k views

Brute force script for printing a password

I wrote a script that reads a file containing a password ("password"), loops each character in that file to see if it matches a character in the alphabet, and when every letter has been found the ...
56 views

Formatting a long filesystem path in Python [closed]

This is a follow up to Log probe requests of WiFi devices focussing on a specific element of the code. I have this line of code: ...
694 views

Retrying to read a file [closed]

I have a piece code which retries 3 more times to open a file (see below). Are there potential problems or side effects with the way it is written? How can it be improved? Also, why would one use <...
98 views

How pythonic is this code? [closed]

Here is the code: ...
182 views

Simple Python tic tac toe [closed]

I'm a beginner in python so I decided to take a simple challenge and wrote tictactoe How to write it better in future? What's wrong with my code? ...