@rolfl Yeah, I saw that, but I think in this case LETTERCOUNT is the better choice. In this case, it's really only unclear what letters you're counting, but LETTERS could be any of three things: a count, a collection, or (given that it follows immediately after LETTERA, which means 'A') it could really mean 'S'.
Ugh too late, closed. The point is, if an error is recoverable in an error-handling subroutine that does Resume Next, then the Case 11 is the result of the method's code is allowing a division by zero to occur. Fix the code! Avoid the division by zero instead. The only errors that should cause an unexpected jump are those you couldn't handle explicitly in the code - why read the division by zero result in a subroutine? If x > 0 Then y = 1/x Else y = 0 End If` cannot raise a division by zero error, and it's clear what the value of y is in that case. Code Review Chat — Mat's Mug11 secs ago
Then I startred looking, and I added other things in... then, damn it, I had to do the ideone.... and then suddenly it was a full-fledged C# answer, which was not my intention.
@Malachi True. The problem is that so many people have been taught to use it so badly. I can sort of understand how that's come about (classes that purport to teach C++ are often also implicitly treated as an introduction to low-level programming), but the result is pretty awful anyway.
@Malachi The x86 has a flag that's only used for the BCD arithmetic instructions to signal when there should be a carry from the bottom 4 bits to the top 4 bits in a byte. e.g., when you add 1 to 0x9, it becomes 0xA. Therefore, that sets the auxiliary carry flag. If you then execute an AAA, that will be adjusted to become 0x10, so it's now a proper "10" in BCD.
There are instructions to do similar adjustments after subtraction, multiplication and division (AAS, AAM, AAD).
Since almost nobody ever uses any of the above, modifying the auxiliary carry flag has no effect on most code.
@rolfl Most chips do something similar. The big split is over whether just moving a zero into a register should set the Z flag or not. 6502's and Motorolas did. Intels don't.
The other big exception was the DEC Alpha. They decided constant updating of the flags register limited instruction-level parallelism, so they eliminated it. When you care about whether a result was zero (for example) you execute an instruction that does a comparison, and puts the result into a normal register you designate (and conditional jumps and such can be based on normal registers, not just a special 'flags" register).
the playfair isn't completely finished, I am going to have to research that cipher again and try to figure out what I was trying to do in the first place, or maybe even start over
@rolfl Silly fact of the day: at least according to a guy I used to know, when measured in the right way, hard drive prices have been very close to constant over time. At least until fairly recently, they were pretty close to $250/pound almost forever. All that changed was how many bits you could fit into a pound of drive.
@Malachi In my experience with C++, the problem isn't so much that it's necessarily hard relative to other programming languages, so much as inefficient.
And I don't mean inefficient in terms of memory usage or anything like that.
@nhgrif no it will pick a pattern at random and mow the whole yard as efficiently as possible
what little arduino code that I did, didn't seem too time consuming, but I was being semi-instructed at the same time, now I would have to do it all on my own.
I've written these two command-line tools to be used to facilitate forestry surveys.
For a little background, the idea here is that often a landowner needs to know precisely how much wood is coming out of his dirt. Not only that, but he has to account for the fact that you can't turn a cylinder ...
def load_trees():
trees=dict()
You only use this variable in the case that you sucesfully opened the file. I'd move it after the open.
try:
with open("trees.txt","r") as treefil:
I recommend not shortening names like this. Call it tree_file it not really any serious amount of...
Time to reward myself for actually coding today and seeing what I could learn today. that means Playstation time. Heck I even played cars with my little man today, we crashed them together, it was AWESOME!
this week, I think my goal is to read through more of my C# book and figure out the playfaire cipher application.
I just posted an answer to a question that already has an accepted answer... and I really hope my answer doesn't go unnoticed. There were two existing answers, both of which missed a really important fact...
The posted answers are missing an important piece of information that I feel needs to be added.
While it is true you don't need any specific device in order to submit to the app store, assuming you're developing your project with Xcode, it is NOT true that you can get an app on the app store wit...
@Flambino I was just trying to follow the Javascript syntax that I found for the global replace, how do I search for the value of the variable in a regex in javascript?
Well... I know some Java... just enough to know that if I knew more I'd be tempted to answer Java SO questions more frequently. And no offense to Java, but the crowd that asks SO Java questions are a bunch of rocks.
How many times per day do we need to see a == vs .equals() question for string comparison in Java? How many times per day do we need to see a NullPointerException or IndexOutOfBounds exception in Java without a stack trace?
3
And the one that's been trending lately, the problem trying to use instance methods from class methods. Whatever phrasing it is that Java typically uses to complain about this error, I've seen that as a question topic a handful of times this week.
I'm trying to get my program to iterate through a loop after a person gets the correct answers to the first question. I feel like there is a better way to do things syntactically.
math_questions = [
{'question1':'1*1',
'answer1':1,
'quote1' :'What you are,you are by accident of birth...
Using Python/Cython, I am trying to construct an efficient way to index boolean values. I have been trying to use the bitarray and/or bitstring packages to construct a fast, non memory intensive way to hold a lot of booleans. My goal was for a list like object that could be sliced as such, and ac...
A friend helped me put the following code together. As can be seen, it's made up of a series of repetitive functions, loadContent(1), loadContent(2), etc. thru to loadContent(6). I've just shown the first two functions but they're all the same.
The code works fine but I'm wondering if anyone cou...
I got bored with opening and closing files whenever I need to write to one, so I wrote a FileWriter class that's used like this:
Public Sub TestWriter()
On Error GoTo ErrHandler
Dim writer As New FileWriter
If writer.OpenFile("c:\test.txt") Then
writer.WriteLine "foo"
En...
I read this question, and the answer helps me but not completely. What if I have 20 repositories with different responsibilities, like for example:
ICountryRepository
ICityRepository
and
IUserRepository
IPersonRepository
I can have all the methods of this repositories in the BaseController, b...
I am writing a function which takes the filename of an image as a parameter and returns a dictionary of the frequency of pixel colours in the image.
Example:
count_rgb_frequency("image.png")
Returns:
{(0, 0, 255): 50, (255, 255, 255): 2450}
For this code to work, pygame and ImageLibrary.py...
In my current project, I'm working on a rather simple JavaFX GUI containing a TreeTableView.
To initialize the View I have the following code.
cmdNrColumn.setCellFactory(new Callback<TreeTableColumn<Command, Command>, TreeTableCell<Command, Command>>() {
@Override public TreeTableCell<Comman...
Huh... my boss at work appereantly has an email archiver which means that any mail sent between a specific date (mentioned in auto reply) is simply being discarded?
Anyone familiar with such email archiver?
It seems a bit weird that email is simply discarded to me
usually such an autoresponding tool is used for a longer period of absence (where naturally there can't be an answer) where the length of the period is named in the auto response
I am not sure if I got you right: Usually the process is something like this: Your boss thinks: I will be away for some time and cannot read/answer incoming mail. However, people that don't know this might wait for an response, so I setup a tool that autoresponds with the information how long my period of absence will be (to let them know when to expect replys)
now he might incidentally have thought of some clever joke form of this autoresponse (and maybe to scare newbies from writing to much in this period)
"Thank you for your message. Due to absence and poor internet coverage I can not read your message and reply. For that reason, it will be filed immediately. ... After <date>, you can reach me back at this address."
That was the reply what I got, with non-standard info stripped
Under the covers, parse int has to look at each character individually in order to parse an integer out of it anyway, right?
It's not some magical way of avoiding looking at all of the characters... it's just a way of avoiding writing the loop to do it.
And if you don't actually need the int value, just need to know whether or not it is an int, then the manual loop will be faster when there is an exception because you just break the loop right there and return false.
I have this table(inradar_ad) with almost 300k entries.
I wanna know, why my query takes 160 secs to run.
I tried limiting with LIMIT 10 to see if I get an speed boost, but didnt. Why is that by the way?
I posted the code here, because I think it's better for you guys read, I guess.
Thanks ve...
Some of our clients have SQL Server 2008 R2, some have SQL Server 2005. Our test database is on SQL Server 2008, but our beta testing company is on SQL Server 2005... so we may not catch something in development that is a discrepancy between the two, but we'll know pretty quickly after we release to beta testers.
On Friday... with had a problem updating a stored procedure.
We could drop & create just fine (which is what we almost always do), but if we tried to modify, it wouldn't work unless we put a semicolon after SET NOCOUNT ON
I should probably learn MySQL. I only know SQL Server, and I always hesitate to leave MySQL answers because I have no idea the differences between the two, and frequently with SQL, performance is one of the primary concerns.
@nhgrif MySQL has a very relational approach, from observing SO, I find it quite common to see cursors, etc. If you do that in MySQL I think you're frowned upon
@user3263252: The code formatting should be fairly simple, you just copy the code from your IDE and paste it into SE and then mark it there and press the button to format it as code
@Nobody There's a MOM's Organic Market in the other direction. I live in a major metropolitan area - it's easier to find good places to shop than to find good places to fish.
@user3263252: I mean the button labled with {} but obviously you already used the shortcut (and it seems to do some auto formatting, it has been some time sinceI used it)
still this should also work: you mark the code and press the button (or CTRL+K)
To make sure we are talking about the same: You are in the mode where you edit your post (on SE), then there is a bar of several icons (that are clickable) above the text field, one if which is labeled with {}
@Nobody I don't know where that {} label is. I tried using ctrl+f to find {} in the page. I really can't find it. Maybe its there, my software just didn't read it for me.
I would like to a review on my Console class I made in JavaFX 8. It features the following:
A text field where you can enter input, the input gets copied into the text area.
A text area where you can observe output and see the input.
When you press enter, you send the message.
When you press ar...
I would like to a review on my Console class I made in JavaFX 8. It features the following:
A text field where you can enter input, the input gets copied into the text area.
A text area where you can observe output and see the input.
When you press enter, you send the message.
When you press ar...
@Nobody "Indent four spaces to create an escaped <pre> <code> block:" Im not sure, but isn't this what ctrl+k does? And you don't need to circle something in red, I wont see it anyway.
Do you think it's permissible to have some unit tests for GUI component that simply confirm that a) the methods return and b) they do not give any exceptions?
This electronics company is doing a big dare here...
If The Netherlands win the world champonships soccer, then everyone who bought a TV between now and when the championship starts, gets their money back
I posted a vb6 / vba /error-handling question to take the meta-debate onto the main site.. in an on-topic way ;) (and I'll post a selfie later, there's plenty to review wih that code!)
I need help with a simple Google Apps Script I've written. The script finds days on which no all-day events have been scheduled, across multiple calendars.
I'm fairly certain the main issue is the fact that I'm making an API call to get all owned calendars, then I'm making 5 API calls on each of...
I wanted to do some statistics over the history of a Git repository. At first I tried using GitPython, but it wasn't as trivial as I imagined it to be. In the end, I just call the necessary git commands with the submodule module.
Can this code be considered clean and readable or does it have som...
The control flow for addToList() looks a little strange. It appears that if any of the first five lists cannot be added, the sixth list will be added automatically. I'm not sure if that's ideal, in case you have an invalid stopNumber. It also looks less-maintainable since you'll have to change...
@Mat'sMug Well there are six stop numbers from 1 to 6 and I need to display all the items from each stop number in the jsp page so I thought of putting them into separate lists so I can just call each list then access all items in the third jsp page. Haven't able to do that though.
@user3263252 @JeroenVannevel's answer cleanly addresses that point - it's pretty much always a code smell to have a numeric suffix to your identifiers ;)
I am writing a text classifier and in order to do so i need TF/IDF values per every word of my signle text. Then i need to use the cosine similarity:
This requires processing of a big data storage ( all of the texts that already exists in my database ). The problem is that my code is doing his ...
I wonder if there are sites that allow you to take interview questions and give feedback on it?
Is it something we could organize on CR? We'd need a set of sample questions hosted in a reliable place, and (maybe?) a reviewer who has actually reviewed interview questions in a company?
Hey so I'm pretty new to programming (been learning for about 2 weeks) and my goal is to eventually design a revision style multiple choice quiz that randomly generates questions and repeats the questions that you have gotten wrong. This I can do, however I have come to a dead end! I would like t...
This code crashs on ubuntu but not on mavericks, why?
#include <stdio.h>
#include <stdlib.h>
struct Vertex{
char vertex;
int value;
int quantAdj;
char cor;
struct Vertex *pred;
struct Vertex *adjacents[];
};
typedef struct {
int value;
struct Vertex *ori;
st...
The program is running fine but I was just wondering whether there was anything I could do to make it more user friendly or efficient. Please note that I have only been programming for a couple of months so am not too experienced! Any help is appreciated! Thank you!
from random import randint
im...
I'm trying to post a little tutorial on the new Spliterator class. There are many tutorials these days on using stream starting from a standard Java collection, but I want to explore the creation of a stream using data coming from the web (so no stream fully backed by a collection).
I decided to...
I actually intended to call them Open and Close, but they're indeed reserved keywords, so I added this File suffix - I agree it's redundant though, and I'll +1 for adding a Write method (WriteToFile? ...Write is reserved as well!) when votes reload ;) — Mat's Mug31 mins ago