Celebrating here on CodeReview because, well.... On StackExcahnge no-one cares: member for 1 year, 8 months visited 439 days, 100 consecutive seen 11 secs ago
2
@Everyone - RELOAD!!! It's dangerous out there.... be safe!
so, after recently getting a bulk of work done on my WebAPI service layer, I thought I'd post some of my working on here for you guys to tear apart, generally, most of it 'feels' mostly ok, but I know there are areas for improvement. Hopefully no screaming issues with it:
1) Someone is going to ...
I define in the Settings Tab of a VB.Net class library some user scoped settings. I want to expose these settings to other projects that reference the class library. I chose to do this using a public Module. This works, but it requires exposing each and every setting manually. Is there a better w...
Lucky .... I had to meet my daughter in hospital today .... and my son has put himself to bed and gone to sleep (at 18:15 ... suddenly the house was quiet and I'm like ... WTF).
@Malachi if the Settings are public then it becomes an object that's usable by other assemblies that reference the project. Like using settings = MyOtherApp.Properties.Settings;
@Malachi the settings designer is just a designer - under the hood it's internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase, so making it public is just making the static class, well, public. Then each setting is a public property (with getters and setters) of that class.
you should be able to shorten this:
Dim m1 As TolerenceHelper
Dim flag As Boolean = True
m1 = New TolerenceHelper
If m1.IsInTolerence(Integer.Parse(txtT1.Text), Integer.Parse(txtA1.Text), Integer.Parse(txtTolerance.Text)) = False Then
flag = False
End If
If flag = False Then
lblTest.T...
@retailcoder I think you might have lost me.
I am going to go read about a gingerbread baby. I will be back
@rolfl I hope your daughter gets better. And congratulations on your fanatic badge. In six days I will get one too. (Although when someone close to you gets sick it makes you wonder what difference a badge does anyway, huh?)
@retailcoder Thanks for the headshot. If you look at some other of my zero-score answers (or at some questions in the Java / Android tags), I can bet that you will find some more answers to target.
@retailcoder I was a little surprised that you actually had ammo though, that's not like you...
@rolfl I haven't read it fully but I can guess why in a way. He doesn't really specify what "effeciency" means for him. He also posts a lot of code without explaining much around the code.
I really gotta go to bed now, before 3 a.m. for once. Night folks
I have become interested in reflection and I wrote a class to wrap an Object so that I can access its private instance fields. The code works great. I do not need to wory about the exceptions in the get() and set() methods because I cast the values appropriately through my wrappers accessor/mutat...
I am trying to implement the F1 score shown here in Python.
the inputs of my function are a list of predictions and a list of actual correct values. I thought the most efficient way of calculating the number of true positive and false negatives and false positives would be two convert the two l...
Nope, what makes me proud is: Only in canada would they worry about the shark.... and then, only in canada is it the big news (because nothing else 'bad' happened).
About TaskQueue.cs
I'm not a big multithreading guru (actually not a guru at anythine), so maybe it's playing a part here, but I don't get why this class has to be static, along with all of its members.
I think I would have tackled this class as a non-static class derived from ConcurrentQue...
@Malachi how's the gingerbread baby?
Should this be closed for "Unclear what you're asking"?
I've got to maintain a legacy application (actually a number of applications) and currently most of the startup-settings (like upgrading App.config when the version has changed, check Database against Datasets, etc.) happens in the MainForm or in a Singleton object called "ApplicationController" ...
So I'm making this little game for programming class. I do not know a very lot about python, so please don't be harsh, but I can take constructive criticism.
import console
import canvas
console.set_color(0.00, 0.00, 0.00)
console.set_font('Avenir', 18)
s = "Welcome to the Adventure."
width =...
If you've got a string, and you expect it to always be an integer (say, if some web service is handing you an integer in string format), you'd use Int32.Parse(). If you're collecting input from a user, you'd generally user Int32.TryParse(), since it allows you more fine-grained control over the ...
I am going to consider this machine sent code and not worry about the error handling. the OP can figure that out, "they know what they are doing, right?"
@retailcoder, scratch that, it turns out it would be about the same length anyway.
I would write it like this
Dim m1 As TolerenceHelper
Dim flag As Boolean = True
m1 = New TolerenceHelper
flag = m1.IsInTolerence(Integer.Parse(txtT1.Text), Integer.Parse(txtA1.Text), Integer.Parse(txtTolerance.Text))
If flag = False Then
lblTest.Text = "Out of tolerance"
Else
lblTest....
I'm writing an AI for an italian Card game scopa http://en.wikipedia.org/wiki/Scopa And as part of it i need to generate all moves available to the user.
A move consists of finding cards in the centerboard that sum to a card in the players hand.
For example if I have a 5 in my hand and the cen...
I'd upvote both answers, but I can't just vote on 1, so I'm spending my last vote on the question.
Answer 1: @rolfl 1,320 rep; Answer 2: @SimonAndréForsberg 1,313 rep - both have 24 bronze badges, both have joined CR in the last 30 days. This is too much, I can't decide.
I recently received a 'good, but not good enough' rating on a coding exercise I was asked to perform. It was to validate that if "Product complaint" option was selected that Product name, Product size, Use-by date and Batch code fields all needed to have values. What can I do to improve the JS to...
I'm making this little game for programming class. I do not know a lot about Python, so please don't be harsh, but I can take constructive criticism.
import console
import canvas
console.set_color(0.00, 0.00, 0.00)
console.set_font('Avenir', 18)
s = "Welcome to the Adventure."
width = 160
s =...
Perhaps the OP can be told (in a non-harsh constructive way I guess) that when a moderator edits your post with more tags, it increases the question's visibility?
All at the suggestion of templatetypedef (Thanks for your tips by the way), I am posting the code for my Merge Sort to see if I can get folks offer suggestions as to where to make comparisons or if I am making the correctly already.
I will post my Heap Sort and Quick Sorts in other posts so th...
981 questions with no upvoted answers / 896 questions with no answers - is it me or these numbers are slowly melting? How long should it take to get through the whole pile?
Here are some comments on your code.
I think your types cpufeature_t and cpuextfeature_t are probably
unnecessary as they are just uint32_t. They might be better expressed as
enums.
Functions that are purely for local use (ie. not part of the public interface)
should be static. This prevents ...
Here's some suggestions on what you can do differently to get a better result (both performance counters and code style).
The MergeSortRun class breaks many rules for naming conventions in Java.... well, actually the class name is OK (MergeSortRun), but the method (also called MergeSortRun) is v...
@Malachi: Yeah, I don't understand that, either. As I'm a mod, they can just flag me if they don't like my edits. But, it does say on Meta that sometimes you just have to let the OP have it their way. If visibility is reduced from that edit, so be it.
@retailcoder: Thanks. I'm surprised faq wasn't used yet.
one of my goals in life is to create an anti-virus that sends the virus or bad software back where it came from, to infect the user that created it and mess up their computer after it is changed
I've written a simple function for building a prefix tree:
import qualified Data.List as L
import qualified Data.Map as M
data Tree a = Empty | Node a [Tree a] deriving (Show, Eq)
partitionBy f = map snd . M.toList . M.fromListWith (++) . map (\x -> (f x, [x]))
buildTree value dt = Node value ...
I have finished this game where a user sets boundaries between 1-20 and 250-350. The computer generates a random number between those 2 boundaries and asks the user to guess (within 10 guesses) the number it is "thinking of." After the 2nd or 3rd time it ends the program with a blank. I know it i...
I need help with the design of my code, and I believe it is the reason why I cannot acheive what I am trying to do. I have been trying for quite some time to figure out why this script will not work.
What I am Trying to do:
I am trying to get a GUI to not lock while allocating processes to a b...
By the looks of it, that question will be closed (but not by me). So, I wouldn't bother fixing the indentation. Notwithstanding the criteria, that doesn't look like good code.
I am currently working on a hash table. I am doing linear, double and chain. I first started by making these structs:
typedef struct list_tag {
struct list_tag *next;
int K;
int I;
} list_t;
typedef struct table_tag {
list_t **table;
int size;
int probing_type;
int k...
So I'm writing some code to perform a quite specific task given a large numpy array with N rows and 3 columns representing points in 3D. The 3D points are to be binned along one of the dimensions between specified bin edges. For each of these bins, there is a set fraction by which I must reduce t...
My project for my class is to create a Java-based game where the user must enter a number between 1-20 and a number between 250 and 300. The computer randomly chooses a number between those 2 numbers. Then the user has 10 guesses to correctly guess what number the computer is "thinking of."
Ther...
I have created a Drupal 6 Module that sends messages through PubNub when the user updates information about a Node. I have a separate app that, when launched, calls my Drupal site and receives a JSON array containing a lot of information about some nodes. I then update the info in my other app by...
Suggestions for cleanup and optimization request.
final class Variables {
private final int x;
private final int y;
Variables(int x2, int y2) {
this.x = x2;
this.y = y2;
}
public int getX() {
return x;
}
public int getY() {
return y;...
This is my forked branch on which I have made a slideshow with keyboard controls[left to go backward and Right key to go forward and spacebar to toggle pause] only.
File 1. utils.py
import os
import sys
def isExtensionSupported(filename):
""" Supported extensions viewable in SlideShow
...
Suppose I am listening for network changes with the following listener:
interface NetListener {
void onNetworkAvailable(boolean isWifi);
void onNetworkUnavailable();
}
I want to have an object, accessible from anywhere within the app, holding the registered NetListeners, that can tri...
I am trying to store all incoming and outgoing call details in a file with number dialed or received,call duration and time.
I tried android call log API's to read call log but that happens only when my app is running and in foreground.
I want to read the call log as soon as user ends a convers...
I have something like that:
1) My custom exception class
public class SolvableException extends RuntimeException {
protected boolean solved = false;
public SolvableException(String message) {
super(message);
}
public void setSolved() {
this.solved = true;
...
I have a large number of source files where I have made use of various newer PHP features - in particular binary numbers, short array syntax, function array dereferencing, and finally blocks.
With the exception of the latter it seems to me that these would be fairly trivial to write a tool to a...
@retailcoder Yeah I have a few classes already that I am considering to put up here for review. It's about 400 lines of code though, and I should also add some description of what the code actually does and why I have written it the way that I have, you think that's too long?
@retailcoder - would appreciate your input on whether my comments on the following C# question is right (came up in the review-close queue):
I am not convinced that this code works as designed: what is the initialized 16K buffer for, why test mask != null when it always is not null. What is the purpose of first... it's dead code. I vote to close because the code is broken.... — rolfl2 mins ago
I am looking to make a generic config file using variables such as:
$PLACEHOLDER_USER
Then after moving the file into the correct position I want to replace every instance of $PLACEHOLDER_VARIABLE into the value of $VARIABLE from my settings.sh file. In the example below $PLACEHOLDER_USER in log...
Goal: typesafe PropertyChanged events, minimum effort implementation for PropertyChanged events, runtime reflection of properties.
Am I reinventing the wheel or have I created something worthwile? Would you use it in your next project?
public interface StaticProperty {
public boolean canGet()...
@SimonAndréForsberg - actually, I'm impressed with your review there. I had looked at that one and decided there was too much crud in the code, and not worth reviewing.... tl;dr sort of thing. In effect it was more hassle than it was worth, which is exactly what you say, except you do it more politely.
I'm dealing with huge amount of data. I've written following code into a function to find out similar questions. It's working perfectly but it is taking too much time in execution. Can anyone help me to optimize the function code so that the execution time will be less?
<?php
/**
* This fu...
@rolfl I was thinking about the Jackson library, which I often use for JSON (or XML) serialization, and I knew that Jackson was able to modify final fields somehow, so I had to find out how.
@Jamal did you miss it the other day, when @rolfl said he wouldn't bring people from work over here so they saw how busy he was here.. and I said "well just change your avatar so they don't recognize you" :)
@Jamal what? you mean you can even mess up people's avatars?! ...well that makes sense, if I changed mine for some playmate I guess a moderator should step in and do something right?
@retailcoder: I don't want to reveal too much anyway. I have also agreed to not share any user's personal data outside the bounds of moderation, and I will adhere to that.
@retailcoder: Well, if we'll really stay in Eternal Beta, then I can still get it for staying here for another year. And that will come after my first Yearling badge, of course.
(and yes, I plan on throwing a party for my profile)
@retailcoder hi, yeah, maybe there will be an early-adopter badge. I think its getting better and better. Its great that people got above 90% answered recently. That is a great effort considering some of the questions which you have to bash your head against the wall before you answer them.
I have a series of text boxes in a table to gather input as below:
The user will input a target and actual value for each measurement point they require. I would then like to validate the actual values against the target values based upon the tolerance inputted in the tolerance textbox. The to...
I just finished a program which enable to report all possible LCS and the location of the two strings respectively. However, the output of the test case isn't totally correct.
For example, if the two strings are "" and "DCACDCBBDBAD", the correct result should report 8 cases. My output just re...
I'm trying to solve a programming challenge for fun. The programming challenge is here(http://uva.onlinejudge.org/external/100/10029.html) and my solution for the same can be found here).
My solution can be found below: currently it causes a time limit exceeded.
#include <iostream>
#include <st...
I attempt to create a reusable and scalable Cron Wrapper in PHP.
I'm at the begining of the project and I wanted have some tips/ critics / improvments to make before going too far.
The final objective is to have a complete cron wrapper which allows to lauch :
'one-shot' task (like huge DB exp...
Sometimes I stumble upon follow-up questions, where code is being posted again after having gone through a review (or two). I think that such question should clearly state that they are follow-up question to a previously asked question.
A good follow-up question should include, in my opinion:
...
Looking for reviewers to suggest optimization and improvements, and to evaluate coding practices.
final class Variables {
private final int x;
private final int y;
Variables(int x2, int y2) {
this.x = x2;
this.y = y2;
}
public int getX() {
return x;
...
Suggestions for cleanup and optimization request.
final class Variables {
private final int x;
private final int y;
Variables(int x2, int y2) {
this.x = x2;
this.y = y2;
}
public int getX() {
return x;
}
public int getY() {
return y;...
There was a fair amount of bck-and-forth on the first wuestion which I guess the asker did not appreciate, so he posted a new question (after editing the first one to the point where I grudgingly voted to re-open.
Sometimes I stumble upon follow-up questions, where code is being posted again after having gone through a review (or two). I think that such question should clearly state that they are follow-up question to a previously asked question.
A good follow-up question should include, in my opinion:
...