I am working on a Spring-MVC application in which there are around 2-3 methods which are quite big and complex, but only one of them worries me, especially for maintenance or changes. As changes in the method can immediately change some critical functionality in the project. The application is ba...
I am using the ancestry gem to organize my post categories tree.
I have 8 parent categories, and they all have many child categories.
To retrieve an array of child categories, I use:
parent_category.children
I defined these relations in my category model:
has_ancestry
has_many :posts
h...
I have started learning Java recently and I solved the following problem on Hackerrank.
The challenge is to :
You are given NN sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the small...
@BernardMeurer not when you make its IDE halfway decent with custom folders to organize your stuff, code inspections, unit testing, IDE-integrated source control, refactorings, and enhanced navigation :)
Could someone create an empty console app and add VSDiagnostics as a NuGet reference and tell me the layout of the files&subfolders in /packages/VSDiagnostics.1.9.3/ ?
How do you make sure the Code Request is linked? I have opened a couple of code review requests and I cane see "Associated Context" info containing references to the shelveset and changeset respectively, but I only see links to Code Review Responses under the the "links" tab. — Techromancerjust now
if (fromUserDate.after(savedDate)) {
groupNoteHistory.setWhatHasChanged("generalchange");
noEdit = true;
}
if (savedDate.after(fromUserDate)) {
groupNoteHistory.setWhatHasChanged("generalchange");
noEdit = true;
}
This sort of thing can be merged:
if (savedDate.after(fromUserD...
@Maxhirez: FW/1 does have examples in Github. I recommend trying stuff and posting it here or on codereview.stackexchange.com . Lastly, in my profile there is a link to my Gibhub work which almost all FW/1. — James A Mohler21 secs ago
I am not sure if its the correct place to ask that question. My apologies if its not.
I was reading the other day an article that mapmakers in the past where inputing a fake city(a city that doesnt exist) in the map that they created. And they did that in order to understand if another person wh...
Could someone create an empty console app and add VSDiagnostics as a NuGet reference and tell me the layout of the files&subfolders in /packages/VSDiagnostics.1.9.3/ ?
Well, says if you can scrape off 5 mins on weekly basis then it's worth spending "21 hours"; the less extreme variant of this is that if you could save 1 minute, it's worth spending about 4 hours
Fairly new in VBA. I have a userform that populates a Date asks for a user, combobox 2 checkboxes and 2 option buttons. My issue is with the check boxes, I don't want to be able to check both of them. I have written logic that text to see if both are checked but do not know how get them back to...
I am writing a method to get data from database using third party assembly. Is it good to declare the method as static as below, because there are no instance varialbes.
public class Department
{
public static DataTable GetDepartments()
{
Sql sql = new Sql();
List<SqlParams>...
sort :: (Ord a) => [a] -> [a]
sort [] = []
sort (x:xs) = insert x (sort xs)
where insert el [] = [el]
insert el (x':xs')
| el >= x' = el : x' : xs'
| otherwise = x' : (insert el xs')
When I run this code I get an infinite list of el. Why? Doesnt...
to be honest, my company enforces a stupid style guide (at least, you'll find it stupid, others might say "man, isn't C# awesome"), so I tried using an online formatter but it was pretty bad
because I don't feel like formatting code like
if (condition)
{
//true case
}
else
{
//false case
}
so, because it's long and that's not needed and rarely helps
Welcome to CR! This answer will cover your question. I downvoted your post because you're asking what boils down to a yes/no question, as opposed to posting your actual code up for a peer review. Please see our help center - questions about best practices in general, are off-topic on this site. — Mat's Mug ♦24 secs ago
grr... it would be considered a dupe on any other site
I'm not hammering because, well, it's debatable whether the code is there for being reviewed, or whether it's there only as an illustrative sample to support the yes/no question.
This is a follow up to my previous question, Base-changing numbers in Java
I have followed @Pimgd's advice in the answer to that question, and I'm posting the improved code for any further review.
/**
* Converts a number in digit representation from one base to another
* Not guaranteed to wor...
Uh-oh. A "hot fix" was released to all of production an hour ago, now DBAs are up in arms because it might be causing entire production servers to crash. #Fun
Note, this is from a COMPLETED course. This is not a ploy to get help with homework as I have already received a 100% on this assignment (last year). I just want become a neater programmer.
package java_labs.GameOfLife;
import java.util.Scanner;
import java.io.*;
public class GameOfLife {
...
I return all documents from the collection products where info have tags which name contain password. Then I want to destroy values of all of this tags.
db.getCollection('products').find({info:{$regex: /<.*?password>/i}}).forEach(
function(document) {
var info = document.info;
document.i...
@Mat'sMug Oh no, not me, I'm not feeling meta today. I'd make multiple mistakes in the post and the focus would be off. Remind me next Wednesday if it hasn't been taken to meta by then.
@Mat'sMug Yes, but I didn't recognize this particular one. Never seen it before.
> This will replace <password>asdfghj</password> in the info XML to <password></password> for each record that contain a <password> entry in the info field (assuming the password value doesn't have a < in it)
Note, this is from a COMPLETED course. This is not a ploy to get help with homework as I have already received a 100% on this assignment (last year). I just want become a neater programmer.
package java_labs.GameOfLife;
import java.util.Scanner;
import java.io.*;
public class GameOfLife {
...
I changed my mind and hammered the static database question as hypothetical code. there's no db connection happening, Sql isn't defined anywhere, it looks like it would be a SqlDatabase object but then it can't possibly work as posted.
7FFFFFFFFFFFFFFF
Infinite loop handled via java.lang.IllegalArgumentException: Not enough available characters for substitution. Number of available characters is 65451 , minimum required number is 70000
0
-0
--1 handled via java.lang.IllegalArgumentException: The supplied number (-1) for base conversion is invalid.
1-1 handled via java.lang.IllegalArgumentException: The supplied number (1-1) for base conversion is invalid.
I don't like --1 handled via java.lang.IllegalArgumentException: The supplied number (-1) for base conversion is invalid. that case
I wrote a simple algorithm for finding all possible letter combinations of a single word. I want to know if my code can be improved in any way, although I'm mostly interested in efficiency.
You can ignore my notes if you wish, they are mostly for myself and the questions in them are not the ones ...
I have got an array of javax.security.cert.X509Certificate and need to convert it into an array of java.security.cert.X509Certificate.
My thoughts when I implemented the following code was that I must keep the order of the certificate thus I used a LinkedList. In the first step I am converting ...
My website receives a POST request. I use the following code to process POSTed parameters: $raw_data = file_get_contents("php://input", true, stream_context_get_default(), 0, $_SERVER["CONTENT_LENGTH"]);
In order to POST a reply, I need to contact another website for information to be included in...
Occam's razor (also written as Ockham's razor, and lex parsimoniae in Latin, which means law of parsimony) is a problem-solving principle attributed to William of Ockham (c. 1287–1347), who was an English Franciscan friar and scholastic philosopher and theologian. The principle can be interpreted as stating Among competing hypotheses, the one with the fewest assumptions should be selected.
The application of the principle can be used to shift the burden of proof in a discussion. However, Alan Baker, who suggests this in the online Stanford Encyclopedia of Philosophy, is careful to point out that...
I have created a program which takes a value x and uses this value to create a power of ten value like so 10 ** x.
This has then been used as the maximum number of a range 1..(10 ** x), which has been expanded using the splat * method to create an array of numbers, and then assigned to the vari...
I'd like to learn if my rewrite is worse than the original, less clear or less "idiomatic".
I've found this code that handles updating two dimensional matrixes in Elm:
type alias Matrix a = Array.Array (Array.Array a)
type alias Location = (Int, Int)
get : Location -> Matrix a -> Maybe a
get l...
import socket,time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('',0))
port=s.getsockname()[1]
s.setblocking(0)
lines=[]
while True:
try:
data, addr = s.recvfrom(1024)
if addr not in clients:
clients.append(addr)
if not lines:
...
Alright so I googled a lot about creating multiple items with appendChild, but I'm not understanding how it works. My appendChild just replaces instead of adding many.
var startGame;
var cards = 16;
var newDeck = [];
startGame = function(){
var startBtn = document.getElementById('start');
...
we were appending a documentFragment when I was like, why don't we just append the element to the Select tag instead of to the fragement and then the fragment to the select tag
I have a form code behind and it has what are called "Common Utilities". Basically the original author made a super class that is embedded into the main form code behind. What is the best way to refactor this? And what methods can stay in the main form? I think my issue is in each of these me...
At that point you might as well include the entire class; reviewers would be able to work off the full context. Also, please edit your post's title to tell us what your code is doing, not what you want to get out of a peer review. If your title looks like a question, it's most likely a bad title for CR ;-) — Mat's Mug ♦15 secs ago
No I have not heard of that - does that cover what is going on here and if I implemented it would that require an entire rewrite of the application? — VinnyGuitara4 mins ago