SuppressFinalize is useless if the class has no finalizer. Similary the Dispose(bool) pattern is silly, because it will always be called with true as argument. — CodesInChaos6 mins ago
@EBrown No, but this one appears to know what he's talking about while the OP is just a noob asking stupid question. Ignore the noob, listen to the veteran.
@rolfl Then by all means, correct it. I don't have time to sit here and babysit anything. I'll just delete the fraking answer if everyone's going to gripe about it.
@CodesInChaos As far as ReadBytes, I have no need to check for what Read returns, if you want to you are free to, I personally don't care. — EBrown8 mins ago
You don't care, so don't care.
If you are not willing to learn things by writing answers too, then don't post things.
The goal of the following code is to be able to use an Xbox Controller in a Java program, it works with the jinput library.
Unfortunately this library is rather old, has little to no documentation and uses a polling system. There are some existing event-based (xbox) controller input systems, but...
@Mast It's got more of a high-level overview though, I hoped someone would also go down into the details
I personally don't fully agree with extensive builder patterns, etc. as they conflict with making a library easy to use, but I do agree that right now it's not as clear as it should be
K is equal to the index between two groups of numbers in an array. The groups are created by taking all the elements that are equal to X into one group, and all the numbers not equal to X in the other group. The index between those two groups is K.
I am doing the following Codility Test to hone my skills, or lack of them.
This is a demo task. You can read about this task and its solutions in this blog post.
A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and...
@JeroenVannevel Does if (variable != null && variable.Property == Enum.Value) have the same effects as if (variable?.Property == Enum.Value)? Does the null-condition affect that?
I have a couple statements that look too bloated for good ruby practice.
@q = @q=~/AND/ ? @q.split("AND") : "False"
@q.each { |g| @q[g] = @q[g].strip }
How can I reassign the values of @q and @q[g] without writing them twice?
I'm working on class Striped_polyline which represents a closed poly-line filled with equidistant horizontal lines1. Here is the code:
stripedpoly.cpp:
#include <iostream>
#include <vector>
#include <algorithm>
#include "Graph.h"
#include "Simple_window.h"
#include "stripedpoly.h"
int main(){...
First of all thanks a lot for your comments to Ebrowns answer! I was trying to explain to him similar points as you did, bot no result! Finally, can you please show me how to handle deallocating resources in the best way? As Ebrowns answer's approach was flawed as you indicated. If I leave it as I have now, what if exception happens, when should I call CloseDppClient on my class? — quser4 mins ago
Boy I fucking love being called out in comments on other answers.
@Mast I'm not at all disagreeing with the help-vampire part; he seems to have absolutely no critical thinking skills. (And people thought those questions in school were worthless.)
@quser The point was that when a method alters a parameter, best-practice is to use ref or out to indicate as such, otherwise your method has surprising/unexpected side effects that need to be documented - and because self-documenting code is superior to surprising but documented code, using out or ref is preferred in this particular case. Generally speaking, returning a value is preferred to using ref or out parameters. — Mat's Mug ♦11 secs ago
I have this exercise for a Java class that is asking me to define two fractions as objects and then compare them using a public boolean greaterEqual(Fraction comp) method.
I initially defined the field variables as double so that I would get the right results when I divide the numerator by the d...
Requests to speed up code don't really make for great questions on this site. Especially when you don't include data to test with or any timing/benchmarks you've done. If you need help with code that works maybe try Code Review instead. — MrFlickjust now
I've been working on Bill of Materials mini schema for a while. At first I had single Part table where I've referenced itself. I was told it would be better to have separate table because we'd need to have info like quantity and that quantity is not part of Part itself. Here's the script...
CREA...
I recently was given a task to capitalize the first character of a string provided the string does not begin with a non-alphabet. Below are the requirements and my implementation. Just want to know if there is a more efficient way to implement this.
Requirements
Please implement this method ...
I have a functional script that converts polar coordinates to Cartesian coordinates and then matches a value in a separate array to the coordinates. It works well, but I find that it takes a long time to run due to the length of the matrices being processed. Each file has four columns and 2,880,0...
@EBrown Yep, you really must avoid. If you use Resharper, it'll tell you when you enumerate a query more than once. Listen to it, otherwise you'll have a big overhead in your application.
@EBrown It works the same way as in any other Linq query. If you do something wrong, it'll tell you by throwing an exception :p But in this case, it shouldn't
Yeah, maybe in the case of pagination you don't have the choice. But it's been a really long time since I used EF (like... 2 years), so I'm not as fluent as I was before, I don't think I can help on that one
I used gradle-js-plugin to lint and minify my Javascript, and wrote some tasks to automate uploading the scripts via FTP. Any feedback is welcome, but specifically I am concerned that
The tasks I wrote myself like viewJshintResults are all imperative and not declarative
The section after the /*...
@EBrown What you can do is use an SqlProfiler (there are free one, or one included with MSSql I think) and see if the queries you make in your application are fine by you
I don't remember how to use it, but yeah it's easy.. lol (If you're talking about MSSql, but it's clear you can filter with any profiler, that's a base feature I think..)
@JeroenVannevel Well it looks like it's executing an SP called sp_executesql with three parameters.
exec sp_executesql N'SELECT TOP (1)
[Extent1].[Id] AS [Id],
-- more columns here
[Extent1].[UserName] AS [UserName]
FROM [dbo].[AspNetUsers] AS [Extent1]
WHERE ((UPPER([Extent1].[UserName])) = (UPPER(@p__linq__0))) OR ((UPPER([Extent1].[UserName]) IS NULL) AND (UPPER(@p__linq__0) IS NULL))',N'@p__linq__0 nvarchar(4000)',@p__linq__0=N'my email'
@TopinFrassi For moral, practical, and legal reasons, we are only able to review code that you wrote or code that you maintain. Code Review is not the place to ask about someone else's code.
If your question contains someone else's code…
For moral, practical, and legal reasons, we are only able to review code that you wrote or code that you maintain. Code Review is not the place to ask about someone else's code.
We also expect you to understand how your code works. If you are see...
I'm using mybatis to connect with postgres database, when I run the test all is ok:
package org.agonzalez.batisrest;
import java.util.List;..
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/spring-config.xml")
public class DaoTest {
@Autowired
private IOrdenM...
I would like to preface that I have never struggled with anything more than I have with Python.
I am trying to write a function partition() that takes a list of strings and a character as parameters. It prints the
strings in the list that begin with a letter at or after the character (according ...
This is a program that I designed to accept input from a user (kills, deaths, kills and deaths per game, and desired kill/death ratio) and calculate the amount of games (with the number of kills and deaths per game that the user entered) required to reach the user's desired kill/death ratio. It w...
I read many comments at this question that one really shouldn't use local classes for functionality like which my code provides, but I couldn't really put things into perspective and decide what better alternatives are there, if any. Some mentioned lambdas although they also pinpointed that with ...
Belgium also has forced insurance and high cost through taxes but you get most money back except for a small amount (couple of euros often) to make sure you don't abuse it
unless you get meds that aren't covered (which isn't often). I think my Yellow Fever or Hep A+B vaccin was one of these
I am trying to log all request/responses using custom OWIN middleware. Here is the code:
using AppFunc = Func<IDictionary<string, object>, Task>;
public class LoggingMiddleware
{
private readonly AppFunc _next;
public LoggingMiddleware(AppFunc next)
{
_next = next;
}
...
i wrote small js library for material design toasts(notifications).
github repo - https://github.com/madtaras/madtaras-toast
js file to estimate - https://github.com/madtaras/madtaras-toast/blob/master/lib/madtaras-toast.js
Please write what are my mistakes and how can i correct them.
In general functionality is fulfilled but i'd improve it a bit.
Below you will find incremental (further ones will contain previous improvements) list of improvements.
.1. Split get to two methods, get and peek, the former one would delete the returned flash message and the latter only return it...
public class DecisionStructues {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter 12 integers ");
System.out.print (" Make sure they are different numbers: ") ;
int number1 = input.nextInt();
int n...
In my experience (working on some relatively large 250k+ LOC Java applications) reflection tends to make code harder to understand and maintain and should be well thought through before introducing it (ignoring possible performance problems, that can easily be solved later on a case by case basis here anyhow). I can't remember a single bug due to forgetting to adapt the equals method when changing the state of a data function. Such data classes tend to be reasonably short and simple, so this is easily caught in code reviews at least. — Voo53 secs ago
Excel renders scientific notation in the engineering fashion, e.g. “4.2E-5”. That’s OK, but when you are writing a scientific paper, it’s likely that you want it to look like this: “4.2×10⁻⁵”.
I have come up with a Scala script that does the job perfectly well:
import java.awt.Toolkit
import ja...
I have an Array viewObject.terms this array can contain up to 3 items. I need to iterate through the array and save the values into a data object.
ie:
data.term_id_1 = viewObject.terms[0].term_id
data.ticker_1 = viewObject.terms[0].its_ticker
This is what I first tried, but I get the error c...
I think the most important question when reading an answer is: Will this answer make the code better? If the answer is yes!, that merits an upvote. But if the answer is meh??, I think the answer needs to be reconsidered.
Oftentimes, with questions that do have serious issues worth mentioning, an...
Please read and follow stackoverflow.com/help/mcve. Show actual and expected output. Also, please document your code, rather then adding an external walk-through. Finally, code review requests should go to the code-review group; if you're asking about functional errors, you should again post actual and desired output. We're not a testing service, so I'm not quite sure what sort of "errors" you meant. — Prune17 secs ago
Welcome to StackOverflow. Please read and follow the help documentation on posting, especially stackoverflow.com/help/mcve in this case. If you need a code review on your code, post it to the code-review site and ask for feedback; this isn't the spot. — Prune30 secs ago
This code takes really long time, Any one can help to make it faster!!
NRfit.Ridge <- function(y,X,start,lambda,n.iter=30,tol=1e-4,verbose=TRUE) {
## used X rather than Z just because it's more standard notation
n.pred <- ncol(X)
II=matrix(0,nrow=ncol(X),ncol=ncol(X))
diag(II)<-1
B <- matrix(...
I have a corrupted png image. I checked and the crc32 checksum of the first chunk (size ~65k) does not match with the one I get. I am sure of this.
Also, I have identified the 4 bytes that have the wrong value. I am sure of this.
My question: Is there an efficient way to calculate the values of...
Trying to figure out, how to fill a new array or current array with numbers, corresponding to the number of mines adjacent to it. I have been trying a few different ways and i cant seem to get down the logic. I feel like arrays throw me off. My thought process would be to compare each cell to the...