@Hosch250 Speaking of bounties, I happened to find an old link-only answer on SO that had a +200 bounty on it. Both links were dead, and after flagging it for removal, the user lost all 200 rep.
I have written a functional GUI program using PyQt4, and I'm looking for some feedback because it's not as fast as I would like. It takes in some number of large, same-sized 2D arrays and displays a sub-image of each one in its own sub-window - at full resolution or only zoomed by a factor of 2 ...
I have written a functional GUI program using PyQt4, and I'm looking for some feedback because it's not as fast as I would like. It takes in some number of large, same-sized 2D arrays and displays a sub-image of each one in its own sub-window - at full resolution or only zoomed by a factor of 2 ...
I'm not sure when or if I'll ever feel like replying to this question... but it's got some easy things to comment on like spacing, indentation, terrible comments, and questionable method names (loadObjects() does UI stuff? tableRefresh() does asynchronous data loading?)
This works, and the UI is snappy in the simulator, but since this is my first time really using GCD, I'd just like this code to be reviewed before I start using it everywhere. Note that this is inside a PFQueryTableViewController
my function
func tableRefresh() {
// get quality of...
I agree e-mail addresses should not be posted. However, such a filter would undoubtedly hit a lot of innocent posts as well.
I do not dare to guess how many posts there are on SO alone about matching e-mail addresses. Communicating about such questions and answers is going to get though if you f...
I'm just starting with knockout, it would be nice to have a feedback, thanks in advance.
Here is my code
JavaScript
'use strict';
(function ($, ko) {
var init = function () {
registerCustomBindings();
var initialData = getData();
var dayInformation = initialData.DayInfo;
va...
Factorio is a game about building factories and about automation. Items can be crafted (just like Minecraft) yourself, or automated by assembling machines. To help me expand my factories I created a little script in Python 3 that shows me what other items that I can produce once I create factory ...
@200_success One important question wrt exceptions in this code that is reviewed.
I learnt here that In reality most applications will have to recover from pretty much all exceptions. both checked & unchecked like NullPointerException/NoSuchElementException/UnSupportedOperatorException etc...
@overexchange Yes, that is true. However, not all exceptions can be successfully handled, not all possible exceptions are known, and not all possible exception cases are possible.
Imagine this code would be sitting in some component here(say).So, at the top level throws clause/catch would be cluttered/messed-up. So, I want to learn exception handling strategy that can propagate exception as shown here
Can somebody help me guide, how do I learn this? In fact it starts with writing some toy app(like exp tree app both GUI and cmd line), If I start writing such app, I need some idea on how to write such exception handling strategy?
okay so I am teaching myself so web design and im building a random site for fun in dreamweaver. This is what i have to far what do you guys think? Also i am trying to center the container where the images scroll to auto adjust depending on the screen size to the center( so the left and right sid...
About checked/unchecked exceptions and how to implement your own.
If you want to re-throw an exception, that is simple enough too:
class Ideone
{
public static void main (String[] args)
{
int[] arr = { 0, 1 };
System.out.println(arr[0]);
System.out.println(arr[1]);
try {
System.out.println(arr[2]);
} catch(IndexOutOfBoundsException e) {
throw new EmptyStackException(); // just an example, not relevant here
}
}
}
The best way to get better is to write code, solve problems, get your code reviewed here, read code (preferably good code), read documentation, and just generally live and breath code.
Recently, I've written a code, which implements sticker window function.
There are some duplication codes as you can see. I think this code can be simpler or else other. Could you tell me your thought? Thank you.
// If 'rtParent' and 'rtChild' are closed each other as 'ENABLE_STICK_VALUE', retur...
Basically am looking for some open source java code that can show me exception handling strategy? I need help on referring such code. I would look into that code, for how exceptions handling strategy is designed.
I'm trying to line up two divs side by side with just a tiny gap between them. I'm new to this but for some reason I cannot eliminate the giant gap between two divs. When I drag the browser window to be smaller the divs close together, but when I have the browser window wider like on a laptop the...
Here is the code:
package sample;
import java.util.ArrayList;
/**
* Created by IDEA on 31/07/15.
*/
public class Hanoi {
final ArrayList<Integer> tower1;
final ArrayList<Integer> tower2;
final ArrayList<Integer> tower3;
final ArrayList<ArrayList<Integer>> towers;
public ...
I am new to Webapplications and threadsafety. Please, could somebody tell me if the following example is threadsafe? My main concern is that the AClient and ParameterValidator are autowired by Spring as singletons (not threadsafe) and as far as I understand all incoming requests will share the sa...
I'm doing code review, and seeing method declarations like that:
def __init__(self,data):
I always thought that it should be formatted like this:
def __init__(self, data):
But then I checked PEP 0008 and see no exact statement about that. There is guide about whitespace around operatos, and...
Refactoring some old code with new VS2015. Can't figure out how to use the power of string interpolation here (to remove string.Format):
public string AsVolts(double value, string format = "0.0")
{
if (double.IsNaN(value) || double.IsInfinity(value))
return "";
return string.Form...
It's easy to write a function that adds two ints in F#:
let add x y = x + y
Actually it's the same as:
let add (x:int) (y:int): int = x + y
If you need it to make generic so that it can take arguments of other type than int,
you should use inline keyword:
> let inline add x y = x + y;;
va...
Better on Code review i think. My only advice is not to limit yourself to integer keys - use another generic param to indicate the key type: IGetByIdService<TEntity,TKey>{..} — Jamiec16 secs ago
I am trying to get an answer to the two quite similar questions here:
Should I convert an entity to a DTO inside a Repository object and return it to the Service Layer?
or
Is it okay to return DTO objects from the Repository Layer?
Right now I am stuck in my Servlet (Servie Layer) th...
import this will generate the Zen of Python, which has two relevant lines:
Beautiful is better than ugly, and
Readability counts.
For me, and for many of the projects I touch, this means I should put the space after the comma.
Best of luck!
I wrote a blog post on this subject where I go more in depth because I found it intriguing. You can find my original answer below.
You can specify a custom entry point to the linker with the -Wl,-e,entry_point option to gcc, where entry_point is the name of the library's "main" function.
void...
I wrote a quick script and wanted some critique, as I don't get to practice my coding often, or even in one language I might make some idiomatic errors.
The program works and runs 145 555 entries (873 330 lines in the original data) in approx 5 seconds. It may run up to a few million entries lat...
Using Java 8 you can do this in a very clean way:
String.join(delimiter, elements);
This works in three ways:
//directly specifying the elements
String joined1 = String.join(",", "a", "b", "c");
//using arrays
String[] array = new String[] { "a", "b", "c" };
String joined2 = String.join(",",...
Anyway, instructions time change depending on the architecture, so there's no definitive answer. Choose the more readable, the one that makes the most sense, and the compiler will be more likely to understand what you're trying to do and to generate the faster code.
I wrote a script do you think it works well. I.e. do I need to close database / connection at the end? The goal is to be able to upsert many records and delete many records in one shoot.
Here is is an example HTTP POST request with JSON body to use it:
{"db" : "Memorise", "upsert" : [["Diagram"...
I would say that if ( n != m ) could be better for the compiler since you tell it that you want to know whether the variables are differrent. That's an easy job for it and you can be sure that it will use the fastest instruction for the job, be it a XOR or something else.
If you write if ( n ^ m ), the compiler could understand what you're trying to do, but it's not guaranteed. You will probably end up with a XOR instruction in the lower level, be it the fatest way to do the job or not.
This question, in it's current form, is not a great fit for Stack Overflow. Asking whether something is "the best"/ or asking what is "the best" is always leads to opinion based answers. Please isolate the issue at hand, or consider asking your question on codereview.stackexchange.com — Matt ♦9 secs ago
Other example: adding and removing elements in the middle of a list is more efficient than doing the same thing in the middle of a vector. However, if your elements are small (integers), adding and removing elements in the middle of a vector will likely be faster than in a list due to better caching.
@IsmaelMiguel Actually, from a complexity point of view, we don't care how many pointers. We know that it's a small constant number of pointers and that's all that matters. That's the whole point of complexity: ignore constant factors.
Lists use more memory, yeah. Like 4 to 5 times more memory. But that's still a constant factor. If your elements are really big, the cost of storing the pointers is not noticeable.
In C++, there's also std::deque which might be an alternative to std::list and std::vector in some cases but I never got to use it. Anyway, iy you need speed, try the different collections, and time.
@IsmaelMiguel You can see std::deque as a list of small arrays. It allows to add and remove things easily in the middle of a collection whil consuming less memory than std::list.
@IsmaelMiguel C++ doesn't define "how a class is implement", it only tells what methods it has and what are their complexity. If you know a different way to satisfy the requirements, you can implement it your own way.
I am building a chat application to communicate locally like IP messenger. When AP isolation is enabled i get only my IP and gateway. That's why i can't chat to others.I am not the administrator of the network. My question how can i check in java that AP isolation is enabled as if i can display a...
Sparked by this meta, I did a quick search for "socket.io" and came back with 21 hits. It seems to be enough to create a tag for it IMO, but I'm no web guy. I don't really understand what this framework is and if it really applies to these questions.
A lot of these questions are currently tagged...
Also, I'd fire you seems a rather silly thing to say, assuming good practices this should be caught at code review, discussed and should never happen again. This should definitely be caught since we are using the correct warning flags, right? — Shafik Yaghmour44 secs ago
I'm still trying to understand why this Qt app has a Socket.IO dependency whereas QML WebSockets also seem to be fine, but need to wait until someone is back from vacation here to get the answer
@IsmaelMiguel That's what you get when using several libraries at once and writing some parts of your code with a specific library in mind then trying to interface the different modules.
Sparked by this meta, I did a quick search for "socket.io" and came back with 21 hits. It seems to be enough to create a tag for it IMO, but I'm no web guy. I don't really understand what this framework is and if it really applies to these questions.
A lot of these questions are currently tagged...
The main advantages of a WebSocket are that it keeps the connection open (so low cost as compared to polling) and it provides a two-way channel, so you can actually push things to clients, rather than that they are polling the server