@Mat'sMug Sounds nice but not really useful for that particular question :D! But thanks anyway! I'm still tempted to do a bit more C# these days and I may switch to C# soon for my job so hey maybe I should grab it
I am just learning C# and am trying to write a random color generator for use with threadcrafting for fun. I've got it mostly operational, but it always repeats the same color however many times my integer flows through the loop. What is the best way for me to get this to generate a random color ...
The site should be accessible only to signed-in users. I'm making sure I publish and enable data manipulation to only those, but I wanna make sure even the app structure won't be visible.
What I did was creating an autorun that checks for changes in signed-in user and reloads the router. The rou...
@Vogel612 I've changed job and I'm preparing myself to be a dad so I'm doing a lot of gaming and programming as I can before I don't have any sleep :D You were working full-time before right ?
Ohh I know! I can't wait :D ! This will be worth it :D! And we're young that's one thing I like. We'll have plenty of time and energy to deal with everything :D
Would anyone explain why someone would do a reload page to switch from the C# code example to Vb code example
I have written a program in x86 assembly (Intel syntax/MASM) that interprets a string of brainfuck code (which is hard-coded) and prints the final stack to stdout. Note that it does not include an implementation for , and . instructions at this time. This is my first major foray into assembly, so...
This is what I have tried so far: codepen.io/alehl/pen/GqRqZv but I am missing something. I've been staring at it all day without being able to figure out what's missing.
I am a beginner to java, and I have a pretty simple calculator:
import java.util.Scanner;
class learningtest{
public static void main(String args[]){
String operator;
double f1,f2,answer;
Scanner scanner = new Scanner(System.in);
System.out.println("What op...
I have written a CSV parser to read in 12609000 lines of CSV data. Each line has 16 fields of both string and double type data. The following code takes about 40 seconds to parse the data. I would like to know if there is a better way of doing this which can make it even faster. I have seen recom...
I have created a UI shown in the screenshot below but the thing is, I am initalizing too many JPanels within a panel in my codes to achieve the UI which will leads to bad code design and also slows down the performance of the program.
Is there any good practices to follow in writing such UI like ...
Assuming everything else works as expected, is the following a correct - but not the most efficient way - of implementing Dijkstra algorithm? Because I have tested it on several examples and it gives correct result. But I can't imagine Dijkstra is that simple.
public static void FindShortestPa...
I found this method here. So I wonder what are better (or more intuitive) methods for finding all permutations of a given string? public static void perm(String s) { alternativePerm("", s); } public static void alternativePerm(String prefix, String s) { if (s.length() == 0) { System.out.println(prefix); } …
Summary: Is my server handling every error and corner case possible? If not, what did I miss?
Details
I'm trying to write the most basic socket server I can, so I can learn TCP and the pitfalls of parsing network data. I'm also worried about security (DDOS mitigation) and making sure the server...
Given constant external space (yes no HashMap), how would you improve the following code (code-wise or complexity-wise with stress on the latter) to find the majority element in an array?
/**
* Created by mona on 5/27/16.
*/
import java.util.Arrays;
public class FinaMajority {
public sta...
I have written a simple JS module "loader" (loader is in quotes because it doesn't actually load the files) that is designed to resolve simple dependencies between modules. It is heavily inspired by module.js and takes some of it's design from it.
Here is the code itself:
(function() {
functi...
I took Huffman source code from Introduction to Programming Comprehensive 9th ed. Daniel Liang. I enabled to show encoding, but i unable to show decoding. This is my code to decode:
String text1 = taText1.getText();
int[] counts1 = getCharacterFrequency(text1);
Tree tree1 = getHuf...
I'm reviewing code by another developer. I'm not too familiar with the semantics of UPDATE FROM when used with a JOIN, but here is the query:
UPDATE
Vehicles
SET
Vehicles.Manufacturer = VehicleMakes.Make,
Vehicles.Model = VehicleMakes.Model
FROM
VehicleMakes
INNER JOIN...
After getting banned from SO , I came here to seek help
The problem is i had few questions that didn't work properly as the code was right and probably I can blame JDK for that so I got few negative votes.
But now everything is working fine and I just want to go back to SO I mean I want to get ...
New here! Trying to traverse through a binary tree in level order (breadth first traversal). I have written code but I get a different output to what is desired.
The tree
2---+
(l) 29---+
(l) 26---+
(r) 4---+
(r) 2---+
(l) 9---+
Im using a Binary class below
class Bina...
I'm new to this so sorry if it's a ridiculous question or if it's the wrong place to ask.
I'm trying to enter an equation with 5 variables into MATLAB, each an array of 5 values. I have an additional variable which is incremental and ends up being 2000 values.
How would a loop be used to have 5...
Ok I am trying to record some session data using static methods. I have 3 counters:
CounterA, CounterB, CounterC:
public class CounterA{
private static List<SomeData> data = new ArrayList<Data>();
private static final AtomicInteger counter = new AtomicInteger();
public static void...
I wrote the following code for solving the Rod Cutting Problem using Dynamic Programming.
Rod Cutting Problem: Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and sel...
This is the first time I'm trying to use promises in javascript so I'm not sure if I have done it correctly but it seems to work. The problem is that I have ended up with a "nested when" and it doesn't look that great. Probably there is a nicer solution out there. I would really appreciate some f...
I am working on genetic algorithm using the following code. The variable "best" stores the best chromosomes from the previous generation and adds it without modification to the new generation. The problem is that if I allow crossover, the "best" changes it value to the best of the current generat...
I have a list of factories each factory has an item of its own and a list of other items from competitors.
I need to sort list of factories based on price of their items and also sort list of other items from competitors for each factory.
What I am doing require to sort collection of factories ...
ID must be 5digits in length for eg:77721
And it's sum digits 1,2,3. Eg :7+7+7=21
Sum must be equal the number represented by digits 4 and 5.
Eg : 66618 is valid ,.12345 is not valid
How should I write the javascript code in order to check the customer id by the user in the input bo...
I have chosen to do it in a some "Retro-Style". So that it shall remind one of old green-screen monitors.
Version with working Ajax-Request and Sass-Code on Codepen : http://codepen.io/mizech/full/gMYMdB/
Any hints and suggestions concerning webdesign, programming, structure are welcomed.
...
> Trait objects are both simple and complicated: their core representation and layout is quite straight-forward, but there are some curly error messages and surprising behaviors to discover.
Binary gap as defined here https://codility.com/programmers/task/binary_gap/
As the title implies, I try to write a program to count how many numbers with a binary gap less than or equal to 3 in the range from 1 to N. However, I notice that my function "bingap" will not work if variables "ans" an...
@DanPantry do you follow the difference between reference assembly and implementation assembly?
The former only contains the API while the latter contains the API and its implementation of each method call
the post highlights what should be considered API
Because there are some fairly esotheric rules regarding structs that mean private members are part of the public contract due to extra constraints put on structs
ergo: in some situations, private members of structs should be considered part of the public API; otherwise you end up with a difference in behaviour
I've been working on my own website, and decided to write an own framework for it. One of the items in the framework is a view/templating system, used to easily maintain presentation files (HTML, PHP)
For this purpose, I used object-oriented PHP programming and tried to apply the SOLID principle...
When your encryption code is finished, and if it's of any real importance, perhaps you should consider posting it on codereview.se for a review. Encryption can be hard to get right, easy to mess up, and nasty if you mess it up. Artjom's comments show it's quite nice to have it reviewed by more crypto literate people. — Arjan28 secs ago
We don't currently have the ability to have the pull request automatically complete if the build is successful. It's something we want for ourselves (we use branch policies requiring a build and code reviews), and I hope we get to it soon. — Buck Hodges5 secs ago
There are a couple of commonly quoted solutions to this problem. Unfortunately neither of these are entirely satisfactory:
Install the unlimited strength policy files. While this is probably the right solution for your development workstation, it quickly becomes a major hassle (if not a roadblo...
I am solving this problem on spoj. The problem essentially tells to find whether graph is bipartite or not. I have written the code and tried many(really many) test cases but it seems to work properly, but on submitting it gives wrong answer which implies this is code has a bug.
What I have done...
@Mast We allow code that is too slow, or uses too much memory. It could be one of those cases... But as it doesn't say either of them I'll vtc. I may ask a meta question about this.
> A value of type &&&&&&&&&&&&&&&&Foo can still have methods defined on Foo called, because the compiler will insert as many * operations as necessary to get it right. And since it’s inserting *s, that uses Deref.
@JoeWallis It somehow passes his test cases but not the one from the online judge. Which means the code does not produce the right answers. Which means it's broken. Which means it's off-topic.
@Mast Nor I. I just don't think saying "So it doesn't work. Cut the crap..." is good, when it could be perfectly on-topic if it were a test that tests speed or memory usage.
@JoeWallis I phrased it more politely on the question itself, but you're correct.
Title must have made me grumpy.
Comments like this don't help either:
@Mast Please tell what is broken code. Please go through the question at least once and please clearly mention what I have done wrong — Siddharth1 hour ago
Assume class Animal which does Eat, Sleep and Make Noise.
Assume class Mammal : public Animal which also does MakesBaby
Assume that Mammal also does Eat, Sleep and Make Noise which it inherits from Animal.
This code is extended from code presented in this question which was answered yesterday by ...
Im starting with a php so I can save data to a mysql database. I read a lot and seems the "escape" strings is not so safe.
this is my simple code.
<?php
session_start();
date_default_timezone_set('America/Argentina');
require_once("config/db.php");
$link = mysqli_connect(DB_HOST, DB_USER, DB_P...
I created my first java application for a college assignment. I tried my best to design my application using best practices of MVC design patterns. I have read about it on stackoverflow and other sites. My question basically is: Do I follow the best practices? Every feedback is much appreciated. ...
Both combinations are not something you encounter a lot in production code AFAIK.
I've done it once, Python on client-side and Node.JS on server-side with a SQL database. But the project wasn't considered a success for multiple reasons.
In a txt file there are IDs and next to them there are their neighbours like this:
1 1
1 2
1 3
2 1
2 4
2 8
3 5
Using AVL trees I store the IDs in one AVL tree and for every ID in this AVL
I make another AVL tree in which I store its neighbours.In the end I make another txt file that in...
0
down vote
favorite
In this program i am using the recycler view . It has AlbumListHolder which contains imageview(mAlbumProfileImage) .I want to implement longClickListener on the imageview of listHolder to set the image from camera . So i am confused how to use onActivityResult to set the imag...
Given that your code works fine, and you're asking people to help you write something new, this is not a question for Stackoverflow (you have no actual problem) but more a question for codereview. — Mike 'Pomax' Kamermans26 secs ago
I have this block of code which clearly looks like duplicate, but I don't know how to refactor.
float offsetDifference;
nfloat newLogoHeight;
nfloat newHeaderHeight;
nfloat newLogoWidth;
if (offset > _previousOffset)
{
...
I wrote a Code for the Knight's Tour Problem. I googled alot to try to make it as efficiant as possible. I got the Buffer. I also thought about using the Heuristics Algorithm. I don't know where I could put that in the code. But that's the second thing I want to do. Now my main question. I want t...
First, I'd say that the answer you link to overstates that particular issue and that the primary evil of global state is that it introduces coupling in unpredictable ways that can make it difficult to change the behaviour of your system in future.
But delving into this issue further, there are d...
@Phrancis In that answer they state that in databases you only change behavior and not data, but didn't your old company do both some time ago?
@πάνταῥεῖ you are not. but it is not also my job. This is not a code review website. The OP need something. I did it with the min efforts. Your comment is appreciated since it add a good thing. You can downvote if you find it a bad answer. You can also edit. You can do nothing. That is all the story :) — Humam Helfawi56 secs ago
...when you have something that works, and the question is whether it can be made to work better, that really isn't a fit for StackOverflow at all -- there's a separate CodeReview StackExcharge for that class of question. — Charles Duffy59 secs ago
Mocking repositories is not trivial. I assume that when you say change data source you mean replacing the data access layer, for instance by NHibernate. That too is not as easy as it looks because of leaky abstractions. — Gert Arnoldjust now
@skiwi I think it's a bit of asking the wrong question, comparing an OOP concept like globals, to how a database works. Since the database is only concerned with persisting and retrieving data, yes of course you can change data, and often do, but I don't think that's what the author of that answer/question is asking about
In fact, depending on the setup of the system, a database may only expose very limited parts to certain processes/programs, while as far as I know, globals are accessible by every process (right?)
Looks like you should rather ask your question on Code Review where you can have your code reviewed. If you explicitly tell that you don't want memory leaks, people might look at that specifically. — Morwenn18 secs ago