« first day (678 days earlier)      last day (3344 days later) » 

7:00 PM
That's like saying: I want 1-liter bottles of milk, and I keep getting 1 liter of milk in a 2-liter bottle....
 
Right of course, but the question is about converting from an int to a char
it's just a side remark, really
 
so, instead of giving me 1-liter bottles of milk why don't you give me 1-liter bags of milk because that will save me from having to check if will have enough space.
29 secs ago, by Jeroen Vannevel
Right of course, but the question is about converting from an int to a char
But, if the question is about converting ints to chars, how does casting the int to a ushort help you cast it to a char?
Now you just have to check the bounds of the ushort cast ;-)\
which takes you around the circle, if you can trust your data, just do a raw cast (char)int .... but, if you can't trust your source, you need the checks, but the winning solution is not tu use ushort, the winning solution is to us char all the way through, and not do the cast ever.
 
What I think they mean is this:
public static char ToChar(ushort value) {
    return (char)value;
}
 
I know that's what they are saying, but I call BS on that.
public static char ToChar(char value) {
    return value;
}
3
If they can do ushort, then they can do ^^^
 
True
Well, I blame OP. Should learn how to use his datatypes correctly
 
7:04 PM
That is one curious ToChar() method.
 
exactly.... and, if they don't want the checks, just do (char)int and live with the bugs if your int is out of bounds.
 
Isn't it a good thing that the murders are typically onesided?
Programmers murder bugs a lot more than the bugs murder them.
 
-1
A: Let's play some Swift Poker

ericguThere is a issue with using ForwardIndexType Protocol in Extensions: Card import Foundation enum Rank: Int, ForwardIndexType { case Ace = 1, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack,...

I don't understand that answer.
 
It's not an answer
it's just a code sample
 
/s/sample/dump
 
7:07 PM
I will look when I get home though. The question may be broken now.
Xcode updated. So the question may need to be closed as historical.
Language update, etc.
 
bbl
 
your daily dose of baymax
has arrived
 
Rep capped first time ever. Gonna make more answers about s
10
 
@nhgrif Congrats!
 
0
Q: Event Listener and Publisher

CalprattThis is my first attempt at creating an event system. My plan is that upon publishing, the listener receives both a reference to the model and to the publisher. This allows the publisher class to have multiple owners, and provide a way for listeners to know exactly how they were called. To do t...

 
7:15 PM
@Trenin - while what you say is true, any effort you go to in order to supply the function with ushort instead of int, would be better served by creating char instead of either int, or ushort, and then not calling a char ToChar(char) function completely.... In other words, either he has ints and can't change that, or he can change that, and then should change to char, not ushortrolfl 25 secs ago
 
7:26 PM
Hi @BigAlMoho. First - this should not be a new Stack Overflow question; it's essentially a dup of your existing question. Second - you may find a better audience at the Code Review Stack Exchange site. That site's purpose is exactly what you're looking for -- peer review of existing code. — Lynn Crumbling just now
If you post to Code Review, make sure you include all the code you want reviewed, this may be closed there for being just a small code snippet. Also, please make sure you give context as to what your code is doing. — Phrancis 59 secs ago
 
@nhgrif What @bazola is currently doing is not related to Cardshifter.
Jan 26 at 20:31, by Simon André Forsberg
"DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE" - who is public license and why would I want to do anything to him?
 
Jon Skeet - Abusing C#
 
@nhgrif btw, in the LibGDX version of Cardshifter, we use a very compact serialization that I made. Using pure DataOutputStream that writes on the byte-level.
 
.net event handling is really stupid.
Horrible.
 
7:43 PM
4
Pizza

Proposed Q&A site for cultural historians, foodies, psycho-geographers, and anyone interested in the cultural, historical and culinary aspects of pizza and its regional variants both within Italy and in the global Italian diaspora

Currently in definition.

 
It won't get going.
 
@nhgrif I feel it's overly complicated. C# or VB?
 
It's not overly complicated. The problem is it handles the event whether it is user input or programmatic.
 
Does anyone here have an example of what business requirements should look like? because I have no clue...
This is my assignment: https://docs.google.com/document/d/1AxnLAt5_fYahCPO5qz3od0CJcyb6yKKAaEz0HPLwmu8/edit?usp=sharing
And this is my poor excuse of an attempt: https://docs.google.com/document/d/1DIUVMsMzpOXYk1e_1anQ0yGNF_SrLEhdDOBjLa6OkIQ/edit?usp=sharing
I'm not sure what I'm supposed to do :(
 
So, if I have 5 numeric edit boxes, and a lost focus event on all 5 to validate the input... If the user enters bad data, I want to refocus the bad box.
Then the event fires again for the other box.
Because I programmatically changed focus.
 
7:55 PM
@nhgrif There's a way around that. Just can't remember what it is off the top of my head.
 
The only solution is an instance variable called "nonUI" that I flag to true when I want to programmatically do something that would trigger an event (and then check this flag in event handled)
 
Some would argue an event should fire whether it's programatically triggered or not.
 
Or in this case, I can use a static function variable.
 
That doesn't sound right. I thought there was something in EventArgs.
 
I don't know. I looked at eventargs docs and nothing looked obvious.
 
7:57 PM
@RubberDuck Are you thinking of event.handled = true?
 
@Hosch250 Maybe. I can't remember atm.
 
That makes it so it doesn't continue propagating upward or something, I haven't looked into it in depth.
 
Stack Overflow suggested RemoveHandler, do stuff, AddHandler
Which... Is stupid... But I would do it if it were just one control.
 
@nhgrif the problem seems to be that you're implementing logic in the handlers
Oh wait
Nevermind
 
No, I'm not. The handlers are calling a method which does the logic.
 
8:06 PM
So you went with WinForms... WPF makes everything much easier.
But it's a steep learning curve
 
no... I working in an ongoing project.
 
So indeed, correct way would be to unregister the event if you don't want it handled.
 
This is the... 24k line file...
 
Ah
 
Right... And that's dumb.
It's working but now there are other problems.
 
8:09 PM
Talking about this, I had to create a boolean flag in WPF to cover this problem too.
I should post this here.
 
I just committed a comment: "when this is rewritten, there is no excuse for it to be twenty-fucking-four-fucking-thousand lines long"
 
Something about whether I programatically or manually called a method.
 
@nhgrif are you not handling the Validate event?
 
706 messages in one Friday, what the ...?
 
I don't know the event life cycle. The order of events isn't so obvious with .net... Which is the other problem.
 
8:12 PM
@skiwi Day's not over yet
 
@Mat'sMug Oh right
 
@nhgrif I hear ya
 
@nhgrif I wish I had stars for that.
 
But the lifecycle is WinForms, not .net - shoot your shit at the right framework! ;)
(WinForms is outdated crap)
 
> Sesquipedalophobia: Fear of long words, which has morphed into the contrived hippopotomonstrosesquipedaliophobia
 
8:18 PM
this might help:
0
Q: Keep Focus on Textbox after user tried to move to other control (on failed validation) in winforms, .net 3.5 WEC7

travellerI want to Validate Userinput when he continues to the next TextBox, and keep focus on the last editied TextBox, if the inmput is invalid. I tried the Validating and LostFocus events, but in both cases, if I try to refocus the TextBox, for which validation failed, the next textbox has already got...

(no votes anywhere though)
 
It might. But I'm working on another issue.
This file is 24,000 lines of code that needs to be completely scrapped and rewritten entirely from scratch. It's all terrible. But until we have time to do that, I'm going to fix it with as few new gray hairs as possible.
2
If any of these 24,000 lines were individually posted as an answer on CodeReview, I'd downvote them all.
4
 
> CoWorker: question......I can use class modules to do alot of the work so the form modules can remain cleaner?
me: YES
Sorry. I got excited. =)
 
I hope that anyone involved in the original creation of this file works in fast food.
2
 
@RubberDuck a Eureka moment?
 
I'm building a starwall.
2
 
8:24 PM
if (!NavButtonUsed && Forward.Count != 0) { Forward.Clear(); }
 
@Mat'sMug I guess so. =)
 
Is it better to check whether I actually need to .Clear(), or no?
Presumably, .Clear() checks this itself?
Am I wasting processor time, or no?
 
Okay... QAT just reported that the field wasn't taking input now... Numlock was off...
 
@nhgrif that sounds like the "issue" I had with my laptop the other day (died on me, ...wasn't plugged)
 
This sounds hilarious.
 
8:33 PM
0
Q: Better design to have sync and async methods by implementing future interface?

davidI need to make a library in which I will have synchronous and asynchronous methods in it and this library will be used by our customer in our company. Some customer will call the executeSynchronous method to get the same feature and some customer will call our executeAsynchronous method and with ...

 
Thats a duplicate of the post done earlier
I replied to it
 
every time I unfold a new method, I realize the last method wasn't that bad... Not now that l've seen this new pile of terrible.
 
@nhgrif Call it a day man. You don't need that at 4:30 on a Friday.
 
We're trying to release to customers soon. Also, I'm cst... And got in 2hrs late.
And... I'm actually not really that stressed... Just this is bad code and I'm not making it better, just making it work.
Also, if I leave this unfinished, it'll be on my mind all weekend.
I just got a work email in Comic Sans.
4
 
No comment.
 
8:43 PM
@nhgrif Almost sounds like someone trolling you
 
@nhgrif It sounds like it would be faster to rewrite it than to debug it.
 
@Hosch250 You are wasting time by over-thinking things.
 
@SimonAndréForsberg OK.
 
@Hosch250 if (!NavButtonUsed) { Forward.Clear(); } is much more clear and you won't feel a thing in performance difference.
 
@PaulGriffin Very nice answer! Have you considered checking out the Code Review SE site? — Phrancis 34 secs ago
 
8:47 PM
I figured as much.
I already changed it and was able to merge two ifs, which was worth it.
 
Yeah. I'll rewrite 24,000 lines next week. That sounds fast.
 
@nhgrif you'll probably delete 20-some K lines next week
 
@nhgrif 600 lines per hour. Assuming a 40-hour week.
 
^^ 10 lines per minute
 
No, in like 4 months I'll rewrite this into like 5000 lines... But across multiple files.
By the way, I can't even look at the designer, because it was a really good idea to put about 30 layers of controls and just change the visible property, wasn't it?
 
8:51 PM
@nhgrif Is this that VB app?
 
omg
 
Because that sounds like something far too many VB "devs" would do.
 
that also reminds me of my old job
 
Note the gd quotes.
 
do
not
overlap
controls
dammit
 
8:52 PM
...waiting for the actual period...
 
lol
 
Those are line numbers.
 
@nhgrif man, the guy who did this has to be flippin' burgers today
 
8:53 PM
@Mat'sMug I bet ya he's not.
 
MyForm.vb.clownswrotethis
 
He's out there messing up someone else's code base right now.
 
@RubberDuck might be at my old job
 
lol
On that note, I'm gonna go grab a brew. Been a long week.
 
'cause I know they'd hire 'em
 
8:54 PM
@RubberDuck At least let's hope he's not working at Google.
or IBM.
 
I'd bet my U hired him if I didn't know they preferred Java and PHP.
 
or somewhere else.
 
24k lines and VS doesn't have symbolic break points.
 
@Hosch250 reading that. reading it again. and again. still don't understand what you are trying to say.
 
I'd bet he's working at my U, if I didn't know they prefer Java to .NET.
I believe they use PHP for the web and Java for the classes.
 
8:56 PM
I should get paid by how many lines I maintain. This file is 24k and it's just one file.
 
@Hosch250 thanks. That made more sense. And now the original message also makes sense.
 
@nhgrif Does it look like this? codereview.stackexchange.com/q/83961/34073
 
What?
 
That question - does the code you are trying to fix look similar?
 
@Hosch250 I don't think anything gets near as crappy...
 
9:08 PM
Well, I'm on my phone, so I didn't look at the code...
 
Instead of doing the if statements inline, they nested them all and made a terrible tree.
I wonder why I never catch these in code reviews:
if (d >= 1 && d <= 30 && m >= 1 && m <= 12 && y >= 2000 && y <= 2015) {
    return true;
}
else {
    return false;
}
I don't write my code like that.
 
@Hosch250 That's in itself an interesting statement already
 
They are supposed to return whether the date is "valid."
I've written date checkers that accounted for leap years and everything in less space than they took.
I should create a Date class in C++ or C# just to brush up and post it for review.
 
I've got something ready for review that's going to WTF everyone's minds...
 
I won't read it then.
 
9:16 PM
Won't make a difference, the compiler will optimize either way- unless the variable is volatile, in which case it will load its value from RAM each time. In general this is really dangerous code though- I can see 3 or 4 race conditions just in the snippet you gave me. If you don't have experience with multithreading and race conditions I suggest getting a code review from someone who does. — Gabe Sechan 27 secs ago
 
Anyway, I'm going for a walk on this glorious 60° F day.
Maybe it'll clear my headache.
 
I don't think there is anything harder than writing a fully correct date API
 
hey man thank u so so much god bless u and protect u — fahad 17 hours ago
 
0
Q: Trouble with calculator app

Mrfunny744Making calculator app in python, but dosen't do any ADDING. Code: num1 = input() num2 = input() answer = num1+num2 print (answer) Say for example num1 was 3 and num2 was 6. The answer would be 9, but for some reason it prints "36" Also how could you add things like multiply, divide and subtr...

 
9:44 PM
0
Q: Refactoring JavaScript to make code testable

BlexySo what I'm building is a URL builder. A marketing person inputs a url and can test that url to see it's valid, then they select a demand channel and then hit 'Generate Campaign URL'. I've omitted the other form fields, as I'm only interesting in refactoring the code for the onclick event of the ...

-1
Q: Translate sql query to linq c#

Lecubunplease help me to convert this query to linq c# select od.ProductID,p.productName ,sum(od.UnitPrice * od.Quantity) as total from products p join [order Details] od on od.ProductId = p.ProductId group by od.ProductId,p.productName order by productID asc

 
9:57 PM
@CaptainObvious Kill Close it with kindness.
 
@Phrancis I didn't know you could write SQL with C#, can you?
 
Yep
 
Well, well, well.
 
C# -> LINQ -> SQL
 
Learn something new every day.
 
10:00 PM
It reads weird when you're used to writing SQL, it's like in reverse
protected void LoadSales()
{
    StoreDataClassesDataContext db = new StoreDataClassesDataContext();
    var query = from s in db.Sales

                select new
                {
                s.SaleID,
                s.SaleDate,
                s.Total
                };

    dgSales.DataSource = query;
    dgSales.DataBind();
}
 
10:16 PM
0
Q: jquery .load() div content from URL with hash-sign for id

einserpaschi have my page so far: einserpasch.com the crucial markup is this: <ul> <li><a href="#content_01" id="content_01"> !?! </a></li> </ul> and the div-container at the end of the document: <div id="haupt_iframe"> </div> on clicking on the sub-menue items the jquery funktion loads content fro...

 
@Phrancis I'd write that with method syntax, like var query = db.Sales.Select(s => new { s.SaleID, s.SaleDate, s.Total });
 
DVLR'ed.
Will vote later.
 
10:39 PM
5 @SimonAndréForsberg on the wall today
ooh that feels good!
in Room for david and Mat's Mug, 1 min ago, by david
do you know any Java folks here who can help me to review my question?
1
Q: Having sync and async methods by implementing future interface

davidI need to make a library in which I will have synchronous and asynchronous methods in it and this library will be used by our customer in our company. Some customer will call the executeSynchronous method to get the same feature and some customer will call our executeAsynchronous method and with ...

^^ awaiting Java reviewers :)
TTQW
 
Hurrah.
I can't wait until it is time to quit school - somewhere around May 1st.
 
School's out for summer~
 
Nice for you.
 
No I was singing
 
Oh, OK.
 
10:53 PM
I have school until early june :P
 
11:16 PM
@Mat'sMug OH RLY?
 
With c, is it bad practice to name the pointer to char pointer args (arguments) instead of argv (argument vector)?
 
Try posting your question on Code Review instead. — Mast 1 min ago
 
/var/log/apache2/error_log is the closest thing to Big Data I've seen recently
 
You should probably post on code review, as @Mast suggested. You could also look at how SymPy does it: docs.sympy.org/0.7.0/modules/geometry.htmlKyle_S-C 1 min ago
 
11:31 PM
Most of my "triage" queue on SO is php or sql. I guess I'm not the only person who skips those.
 
@SimonAndréForsberg +10 now...
 
@Mat'sMug the Simons are getting bigger
 
Only because the mugs have gotten smaller ;)
 
I'm voting to close this question as off-topic because it is better suited for code review--it is a "how can I improve this working code?" without any specific problems. — Iguananaut 1 min ago
 
Anyone up to a basic UI question?
 
11:41 PM
Sup?
 
Of course it is about my app...
Uploading picture.
What do you think about the black line extending all the way across, but not the text?
Should the black line only be as short as the text?
Both ways look a little peculiar to me.
 
Hmm no idea!
 
This is my two cents: I think the black line extending past the text implies the text at some point extends to that same length.
 
OK, let me post a screenshot of the other way.
 
A member of my family does a lot of copy writing. At one point he said it's easier to read text when there is empty space on the right side... or was it left
 
11:46 PM
I used to have the text extend all the way across, but that was bad.
It is hard to wrap back around when you have lines that long, so I made the lines shorter.
 
It's also hard to read text with long lines.
 
That is why I shortened it.
 
0
Q: 1-D Intersection of lines given begin and end points in Python

user1502381I have a fairly basic question here. I want to find if two lines on a 1-D plane intersect. I know of two simple ways to solve this, but I wanted to know if Python has a more elegant way to solve this? Ex: x = [1, 10] # 1 = begin, 10 = end y = [15, 20] z = [5, 12] #Method 1: Works. Is quick. Lo...

 
@Hosch250 I personally find the second example more amiable. It says, "There's nothing but the text below here."
 
OK.
I like it a bit better myself.
Should I perhaps do a black/gray line down the outer edge?
Probably not?
 
11:54 PM
@Hosch250 Is the headline part of the text or part of the navigation? If it's text, then it must also obey the max-width. You could even get rid of the border entirely. If it's part of the navigation, then it should fill up the whole width, but a different background colour would be a better cue than the underline.
 
@amon It is the page title.
It changes on a per-page basis.
 
Like a bold title with no line?
 
What if I put ads there? Should it have a border to separate the ads then?
I tried it without the line, it doesn't look as nice.
 
11:57 PM
@nhgrif Their chat is dead.
I can create a new room, though.
 
Post a question.
 
OK.
Did you know that I can't view the link you posted?
I can only see it in the starred message.
 
RELOAD!
There are 1204 unanswered questions
 

« first day (678 days earlier)      last day (3344 days later) »