Intent
Increase code usability/readability of functions with many default parameters while maintaining as much compile time safety as possible.
Motivation
It is very common to create functions that have many default parameters that extend and customise their side-effects. A problem arises in fun...
I'm creating a buffer to be accessed by some threads.
struct buffer {
struct items[32];
int numItems = 0; /*will keep track of number of items in the buffer
}; and will be updated by threads when accessed.
We'll include mutex locking*/
Sho...
Simply i'm working on quiz application for training purposes and i think i'm done with most of it.
but the problem is that i'm not comfortable with what I've done, i seems to be complicated and unprofessional and i would like to make it more organized and simple to understand.
first the database...
Does anyone remember when I was having trouble with my computer taking ~30 minutes to go to sleep? Well it happens when I Shut Down as well. #GreatJobMicrosoft
I would just like some input on how I may improve my code(in terms of content not formatting) without changing the output:) It's just a simple magic 8 ball program using dialog boxes.
Here's my code:
import java.security.SecureRandom;
import javax.swing.ImageIcon;
import javax.swing.JOption...
Leaving comments and code like //If user inputs 4 this case will run. and case 6: doesn't endear you to code reviewers. It would be better to delete the comments than to have inherently incorrect comments in the code. — Jonathan Leffler5 secs ago
Either you are requesting a code review and this is the wrong site, or you are requesting help to fix a bug and then you should clearly state what the bug is. How to Ask — Julien Bernu34 secs ago
This is my code. In less that 5 seconds on normal PC. I found the answer
package main
import (
"fmt"
)
const (
a = 8
b = 8
maxLevels = 64
)
func main() {
c := make(chan [a][b]int)
for x1 := 0; x1 < a; x1++ {
for y1 := 0; y1 < b; y1++ {
...
Your code is very un-Ruby-like. I suggest you consider posting it at SO's sister-site, Code Review. There you will get useful suggestions for improving it. — Cary Swoveland26 secs ago
My goal with this bit of code is to check if my processor supports rdrand and, if not, execute some other random number generating function. To check if rdrand is supported, the 30th bit in the ecx register should be set.
I guess my one of my dilemmas is whether or not I should explicitly check ...
I'm voting to close this question as off-topic because review requests for working code should go to codereview.stackexchange.com — GhostCat13 secs ago
So what my code does is to share some value with it's neighbor.
It's kinda hard to explain,
i have commented the code so it shouldn't be impossible.
The names "Instructions, Registers" can be ignored, just see them as "names",
what's important is how they are shared. which can be seen in the c...
I have a large project which uses recursive make.
I'm using a config.make file to keep the configuration settings (for a example what are the install locations).
When it comes to inner project directories what is the best thing to do.
* Copy root config.make file into inner directory and inclu...
I am trying to optimize the filter method for RecyclerView Adapter in Android. The list is used as an ArrayList. I have seen this post but they are filtering from the original list every time. They are not using old results if a character is added. Please suggest code optimizations for this metho...
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.com. — Anmol Singh Jaggi33 secs ago
Hi @elnaz ! If your code is already working correctly, but you want to improve it, the best place for that would be [the code review site](codereview.stackexchange.com). — Anmol Singh Jaggi51 secs ago
It looks fine and clean. But you can review your code in codereview.stackexchange.com,if needed. — Achilles55 secs ago
My project is using a specific version of JDK which is jdk-6 and the default JDK_HOME path will vary from distribution to distribution, so I wrote a script to guess it. Is there any way to do this better?
#!/bin/bash
JAVA_HOME=""
JDK_TEMP=""
shopt -s extglob
JDK_ROOT_DIR=( /usr/java/ /usr/java/...
Rectangle.__init__ still looks weird: self.bottom = right self.right = bottom. With left, right, bottom, top, rect2 has zero width (just saying), and the other rectangles have top < bottom. (If and when you edit this, have a look at Andrew Svetlov's edit to save vertical space, and consider to follow user7138814's suggestion.) — greybeard47 secs ago
The base64 decode algorithm is taken directly from Base64 wiki page. This exercise is meant to help me learn Rust, so any pointers in that general direction are very welcome. :)
fn main() {
println!("{}",
hex_to_base64("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706...
By the way, if you're able to fix your problem, I strongly suggest you to have your code reviewed at Code Review later on (as soon as it works). — Zeta35 secs ago
@Vogel612 what we are doing is a SDK for a driver, so I don't have that as an option. We have customers who are using JDK-6. But I can use the JDK 7 for compiling which is compatible with JDK 6, but again it is adding more complexities when it comes to building with ant. — sandun dhammika13 mins ago
I've a standlone Java application, which is basically starts and manages two socket servers. I'd like to configure server ports in .properties file, and for the sake of purpose have the following class.
class ApplicationConfig {
private static final Logger LOG = Logger.getLog...
Find the sum of the first 50 natural numbers .
Print the following numbers : 1 3 5 7 9 11 .
Print the following numbers : 20 17 14 11 8 5 2 .
Find the sum of any 10 unmbers entered by the user .
Read 10 numbers,print the maximum one.
Print the sum of even numbers in [1100]
Resd n, Find the valu...
Fab, that's the main thing. Wanted to ensure the right process for the job but as it was mainly an amend to someone elses code (that I linked to) I felt codereview was not quite the right place. — indofraiser1 min ago
What is the question? Your code works or not? You want code review? Saying "Its due: 5/12/16 15:30 GMT" is not helpful and is likely to aggravate, we are not obliged to meet your deadlines — Chris_Rands52 secs ago
This should be ask on [codereview] How did you repaing your balls ? From scratch or just the changes ? — AxelH9 secs ago
@Cerbrus there is no such thing as migration to CR. The only way to migrate to CR is through moderator intervention. Accordingly you should just close the question and if necessary flag for mod-attention. This is also the documented "workaround" while CR does not accept user-based migrations. There's a bunch of previous discussion around this on MSO under codereview-se — Vogel61231 secs ago
Hello guys im sort of new to C and would like to know how to create a Calculator and a Help function using functions.
If it was with Switch Case - it would be easy to do so ,but the assignment is with using function.
For eg, if we give the input as such
add 12 14
26
mul 3 2
6
...
I've written a program that solves questions of:
Addition
Finding the hypotenuse of a triangle
Checking if the triangle has a right-angle or not.
I've also written it to be viewed in English or French. There's a few errors regarding int and while but it still works all the same. In case of an...
This essentially builds a single heap from all of the items. The algorithmic complexity is O(n log n), where n is the total number of items. You can take advantage of the fact that the lists are sorted, and do it in O(n log k), where k is the number of lists. See codereview.stackexchange.com/questions/101078/… for an implementation. — Jim Mischel30 secs ago
@AntP Code doesn't lie? I'm used to bugs but code that claims to only display something but turns out to actually exit the program? Yeah, that's not exactly honest. — CandiedOrange10 hours ago
The James Webb Space Telescope (JWST), previously known as Next Generation Space Telescope (NGST), is a Flagship-class space observatory under construction and scheduled to launch in October 2018. The JWST will offer unprecedented resolution and sensitivity from long-wavelength (orange-red) visible light, through near-infrared to the mid-infrared (0.6 to 27 micrometers), and is a successor instrument to the Hubble Space Telescope and the Spitzer Space Telescope. While Hubble has a 2.4-meter (7.9 ft) mirror, the JWST features a larger and segmented 6.5-meter-diameter (21 ft 4 in) primary mirror...
My part is all Scala, but most of the server side stuff is Java, the data processing (image calibration) stuff is python, the user side of MAST is something else, but I'm not entirely sure what - maybe some Microsoft techology.
They tend to let the head of each project choose the technolgy(ies) used, which results in a very mixed bag.
I'm starting to learn algorithms, so I need help to solve or hints to solve matrix using divide and conquer to get index of column that all contain 'y' in O less than O(n^2).
Like this:
NNNNNYNNN
YNNNNYNNY
YYNNYYNYY
NYNYYYNNN
Output should be : 5
I'm compressing an array of strings in an Android app. Is there something you would suggest?
public static String compressArray(String[] data){
String jsonData = Arrays.toString(data);
try {
String compressedData = compressString(jsonData);
int compressedLength = compres...
@skiwi Scala seems to be pretty close to regular Java for the most part. Smart choices are sometimes necessary with collection choice as performance can vary based on use - but that's true for most languages.
Scala is almost 100% Java compatible, so you can use Java libraries if you want.
The only incompatibility I've ever seen was easy enough to work around.
Hmm okay, as far as I know Groovy has quite a lot of dynamic features, and it uses some terrible mechanism to select which method to take on runtime, costing a lot of performance
Nice try on parenting, but there can be legitimate reasons for ignoring warnings you may not realize. Why do people on SO always have such an attitude? It is perfectly valid technical question with perfectly valid exact answer, this is not code review or kindergarten. Btw. you also forgot to mention that one should always write tests, choose descriptive variable names, ... — Steves9 secs ago
I'm writing some code for professional purposes, and I'm tempted to refer to "callback hell" somewhere in the comments.
Will this be seen as professional for the code review ? My code will possibly be reviewed by people I'm not used to work with, so I don't know how they feel about it.
What you are asking is more of a code review, hence this question should be asked on Code Review instead of stackoverflow. — dejavu_cmd_delt5 secs ago
@dejavu_cmd_delt The code in the question does not work as intended. And so if it were asked on Code Review I vote to close it. Please check our help centre on what topics you can ask about. — Peilonrayz39 secs ago
I've just solved this problem and I hope you guys give me any feedbacks to make my code be better. Thanks a lot!
Problem: There are strings. Each string's length is no more than characters. There are also queries. For each query, you are given a string, and you need to find out how many ti...
Basically, if the function parameter is None, I ignore it, else I concatenate all arguments like arg1:arg1_value AND arg2:arg2_value AND arg4:arg4_value considering arg3==None when the function got called.
def _get_query_string_for_get_config(self, host, app_name, instance, config_source, config...
There are APIs like the Except extension that require the IEqualityComparer<T> to work. I find it's too much work for such a simple task to implement an interface so I thought why not automate it.
I implemented this interface in a reusable fashion so that I can use it with any value and any nu...
This an attempt of a cookie wrapper of sorts. It has no real purpose nor do I encourage anybody to every use it in a production environment. It was made for fun, at best for practice.
The purpose is to make working with cookies somewhat easier. It's built from several parts:
I've could build a ...
This program is intended to speed up the load times of some animations i am currently rendering on a mobile device. Currently I am creating animations frame-by-frame and adding them to an AnimationDrawable or some other animation object(i am using xamarin ). Once this is finished rendering, (if i...
I'm making a text based java game to help me learn java. I would like to know if I am doing things ok and if there is a better way to do the things I'm doing thanks. I have two separate files;
adventure.java
package sam;
import java.util.Scanner;
public class Adventure extends TheGame{
public...
Digitaria insularis is a species of grass commonly known as sourgrass. It is native to Central and South America and the southern parts of the United States and has been introduced into other parts of the world. It was first described by the German botanist Friedrich Karl Georg Fedde in 1904.
== Description ==
Digitaria insularis is a tufted perennial with very short, swollen rhizomes. The stems reach a height of 80–130 cm and are erect, branched from the lower and middle nodes, swollen bases, with woolly bracts, glabrous internodes and nodes. Sheaths papillose - pilose in their majority, ligule...
@N3buchadnezzar I think I got the answer, I think Python is messing up your encoding. Take print(list('zæøå'), list('z\xe6\xf8\xe5')), do it in both IDLE and your program and you should get different results. I get (['z', '\xc3', '\xa6', '\xc3', '\xb8', '\xc3', '\xa5'], ['z', '\xe6', '\xf8', '\xe5']) and (['z', '\xe6', '\xf8', '\xe5'], ['z', '\xe6', '\xf8', '\xe5']), to fix this use ALPHABET = list('abcdefghijklmnopqrstuvwxyz\xb8\xc3\xa5')
rather than ALPHABET = list('abcdefghijklmnopqrstuvwxyzæøå')
I have a text file with a certain data structure that looks like this. I have intended it to make the structure clearer, but in reality they are all aligned, and there are no bullet points. Ellipses indicate the repetition of a pattern.
variableA 3
Type1
variableB 1
x y
1 5
2 10
3 15
....
my server receives requests in one thread and responds in another. I am using thread pools of pthread-s for both receiving and sending. The performance is not that bad, however...
When I am doing the same algorithm in one thread only(MULTITHREAD not defined) so that both recvs and sends are in t...
Got it: ! defines that the next bit is a function, then you can put any ASCII next as the function ID, excepting ~, which defines the start of the code for the function, then ^ ends it.
Plus, interpreters are supposed to be designed so that they ignore invalid characters, it won't break the compilation process, it will just have completely unexpected output.
@Mat'sMug You have comments in your BF interpreter? I just throw unrecognized stuff away
And I wonder what features we can remove from BF whilst still allowing for the same programs... Removing either of + or - and either of > and < should still work in wrapmode, right?
how about ^{body} to push a set of instructions to the current pointer value, and then % to call whatever set of instructions is at the current pointer value?
Question
Is it possible to stream an uploading file over PHP, so that an other client can download it while the first one is uploading?
I don't want to save the file permanently on the server. How can I do that?
Why PHP?
The downloading client shouldn't need an additional software to get the ...
I'm trying make a php server for voice chat using socket. i can send to client a plain data such as html etc.. but i want to send voice data and i'm firstly testing it with a mp3 file. my server code:
<?php
error_reporting(0);
set_time_limit(0);
define('IP', '192.168.56.1');
def...
Now, since there's no server state involved (it's literally just sending audio from A to B), I would expect that each session could open it's own connection to the server and stream through it.
its simplish in php if you were just uploading an audio file then downloading it, but uploading and downloading at the same time is too complex for php's little mind
Now I would think the server could do one of two things: transfer the data between clients through server; serve as a third-party to negotiate a connection between clients and the server.
@EBrown I have absolutely no idea. I have limited experience with Python. But I expect that Python has some UDP streaming capabilities which would be a big step in the right direction
@SimonForsberg @EBrown I've written this a long time ago. Don't ask me why it does what it does and keep in mind this is pretty much the first professional Python I wrote. I didn't know CR back then. Python 2.7, use at your own risk.
I got sent a challenge from a friend;
You are given a file that contains numbers, one number per line. Convert the numbers from the file into roman numerals.
Test input:
45
65
23
98
123
7754
Expected Output:
XLV
LXV
XXIII
XCVIII
CXXIII
MMMMMMMDCCLIV
I think I've succeeded in doing this s...