« first day (1130 days earlier)      last day (2892 days later) » 

10:01 AM
@Mast brings up a valid concern, although from my experience, it's not been a problem on CR, so far
Mind I'm not a mod so I don't know what might be going on behind the scenes
If you are concerned it might be a problem though, please bring it up on CR meta
 
10:16 AM
0
Q: Tabs Between Method Calls for Readability

BassieI was writing the below section of code which adds some user properties to an Active Directory user, and got wondering - surely we can improve the readability of this : var firstname = newUser.FirstName; var lastname = newUser.LastName; var email = firstname + lastname + "@mydomain.com"; var do...

 
Hey this is a start, right? I've actually never created table-valued functions before, so this is good learning
 
@Phrancis I'm not entirely sure whether I can follow what it does, but it looks awesome.
It's definitely a start.
I'm having trouble setting-up the board. IIRC correctly it zigzags.
 
Yeah, I didn't know the syntax yet for functions, the thing that threw me off is setting the table in the returns clause, I'm used to procedure syntax where it's not quite like that
 
40 39 38 37 36 35 34 33 32 31
21 22 23 24 25 26 27 28 29 30
20 19 18 17 16 15 14 13 12 11
1  2  3  4  5  6  7  8  9  10
 
I'm not sure why you need to seed it this way, just seed it with consecutive numbers
 
10:22 AM
@Mast Jesus, what the hell happened here?
 
You only need to change the order once you display it
 
32 mins ago, by Quill
34
Q: Exchange votes or favours

Jacob VlijmProbably the most risky post I ever posted on AU, nevertheless need to get it of my chest... Don't ask me how I got the impression, nor whom it involves, but there seems to be a tendency lately that people "exchange" favours. No one on AU has any objection to an occasional sympathizing vote, n...

@Phrancis So fill it the ordinary way and change the direction of the numbers afterwards?
 
Yep
 
That seems inefficient, but it's probably easier to do.
 
My version is likely not even going to have a "board"
 
10:24 AM
I'll probably have an ASCII board.
@Phrancis Table and cells?
You got a 2D board by default :P
 
@Mast Well, right. But that wouldn't serve any purpose, I'm instead going to store each move into a table
Since it's all dice rolls anyways, the board is just for human use, the computer doesn't care about it at all
 
0
Q: PHP Class code that allow developers to register taxonomies in a CMS

Mohsen ElgendyBuilding complex applications can sometimes be a pain when extending or editing later on; I read online about the S.O.L.I.D principles of OOD, I want to understand if I am following a good approach that I can follow when developing the rest of the app. I need answers to the following questions ...

 
Hmmm, true.
There is no board.
 
Right. Only cell numbers
 
I could make it a hash...
Every cell has an action.
 
10:27 AM
That's kind of-ish what I'm thinking of doing
 
Monking @janos
 
thanks @Mast for your concern, I approved it, it's fine
btw monking :)
 
hey there @janos
 
hi Quill, how's it going?
 
good :) you?
 
10:31 AM
hi janos
 
right now I'm actually starving... (before lunch)
hey Phrancis
 
I hate to ask, but can a mod unfreeze SQL Helpline room? I forgot to post bump messages in there recently...
 
nice to see you too Phrancis :)
 
lol, likewise
 
how to unfreeze?
 
10:36 AM
I, uh... dunno
 
lol
 
Maybe in the room menu on the right?
 
reading the FAQ....
 
Mug did it for me before
 
Was the SQL Helpline still in use?
Last question I can find is this and there was no response on that.
 
10:37 AM
It's used on occasion, it has a feed of all SQL questions, I just forgot about it for a while :(
 
found it, unfrozen
it was in the access menu
 
Thank you @janos
 
@Phrancis you're a room owner, I wonder if you could have done it
we can try that next time
 
Sure. I don't have an "access" menu
 
@janos I think Room Owners lose power when the room is frozen.
 
10:39 AM
I have "control access" from the "room" menu
 
Monking
hey @janos, been a while since we've seen you
 
One more VTC
 
Zak
@Mast @janos beats us all to it. As usual.
 
@Mast @janos I think that's the case
 
@Phrancis on the control access screen, next to [save changes] and [delete] there was [unfreeze] button
 
10:42 AM
hmm
 
now it's [freeze], but I guess you don't have that
 
I think the idea of automatically freezing a room after inactivity is that room owners (nor regular users) cannot revive it
 
makes sense
 
Yeah, I suppose
Even though the messages are probably just single rows in a SQL database, I could see not wanting to revive old/inactive rooms without a reason
 
10:46 AM
Oops, forgot to ask for a reason. So it's because "Phrancis said so" :)
 
Close enough :)
 
time to go for lunch
 
can I do something like select max(columnX, select y from z)?
 
no
 
10:47 AM
boo screw you sql
how do you translate that to a proper query then?
 
make a case statement
 
I though SQL had a max function
 
It does, but it can only take one argument
select case when select max(Foo) > select max(Bar) then max(Foo) else max(Bar) end
kinda clunky, I admit
 
Zak
@Mast Wow. Those are some big corrections.
 
or something like select max(select columnX union select y from z)
 
10:50 AM
That could also work^
Except I'd give a syntax error as both select statements need to have a from clause if you're accessing a database object
 
@Zak Yea, there must have been something really fishy going on over there.
 
Exception being if you select a constant like select max(select 42 union select max(A) from B)
 
@JeroenVannevel Select y from z where column = x?
 
that doesn't do my max stuff
 
Wrap that in a max query.
 
10:56 AM
@Mast that won't work
 
SQL can nest.
 
@Phrancis I ended up with
-- TicketsAvailableFrom =
-- (select
-- case
-- when ListingCreateDate >= (select max(OnSaleDate) from [Event] where ) then ListingCreateDate
-- else (select max(OnSaleDate) from [Event])
-- end
-- ),
Looks the same, right?
 
Looks about right, yes
 
@Phrancis Why not?
 
yes the 'where' is unfinished. I'm aggregating my separate queries
 
10:57 AM
0
Q: Calculates the sum of all primes less then 2,000,0000 in Swift

JKTHello this is a swift program I wrote to calculate the sum of primes below 2 million, but it is tediously slow and I do not have the patience for it to complete. I am curious about what makes it so slow. func initArray (p:Array<UInt32>) -> Array<UInt32> { var arr = Array<UInt32>() ...

 
does it evaluate those things twice then?
 
@JeroenVannevel the query optimizer probably optimizes it, but it may not, really depends. Check the execution plan
 
might do
 
@Mast you can't have aggregates like max() in a where clause, if that's what you were thinking of
SQL queries syntax is made to be human readable, but the execution is not in the order that is displayed in the code
 
@Phrancis No, I was thinking about putting the max around that.
 
11:01 AM
@Mast like your query being a subquery in a max() aggregate?
 
stuff like DECLARE @dates TABLE is purely in-memory on my machine, right?
I'm working against QA db and I don't want to mess up stuff
 
@JeroenVannevel In memory on the server, whatever machine that happens to be
 
but it's removed after the query?
 
Yes
 
all good
 
11:02 AM
Just be careful not to allocate really large tables to memory, on servers that matter
 
20k records at most. should be fine
 
Yeah, most likely
 
If your server crashes then you allocate too much memory
 
@JeroenVannevel Consider using a temp table instead of a variable, if query speed is a concern, with this many records
 
nah it's not. I just want to do some one-time analysis
the longer it takes, the longer my break is
 
11:05 AM
lol
 
I write unoptimized code now
 
Temp tables can have indexes, so if it's a performance-critical query you usually gain a good bit of speed using temp tables. It does create some IO on the server but usually not bad at all
 
You can't have an order by clause in a query that's nested in an insert?
 
Correct
 
I guess it does make sense
 
11:07 AM
If you need to order the rows before inserting then, you need to use a table variable or temp table
 
seems like a silly thing to make an error
a warning I'd understand
but sorted inserting does make sense
 
You just gotta understand that databases are very dumb things
They'll accept anything as long as the types fit
 
LOL
Computers in general are very dumb things
So, that shouldn't surprise you, I suppose
 
and smart people behind dumb things can still do dumb things
 
11:12 AM
Indeed
 
Everyone is dumb
 
At least people have some capacity for judgement and thinking, which computers don't
 
@Phrancis Something like that, yea.
 
If computers could think critically, all programmers would be out of a job
 
At least computers have an off switch.
 
11:17 AM
@Mast Alright, in any case though, SQL's max() function can only take one argument, so you'd still have to make a way to assemble a result set that the query engine case use, and if it's aggregating from multiple tables, it has to perform those operations separately
It's the nature of SQL scalar functions
 
@Phrancis So, it can be done but would involve a lot of hassle?
In that case it's probably better to do it different.
 
Unfortunately, SQL doesn't have a varargs type of function or procedure
So, yes, it's a good bit of hassle
 
most people
@Mast Until they adapt themselves to disable the usage of the off switch
 
It's really not that hard if you know ahead of time how the database "thinks", but if you are used to more flexible type of procedure/function input, it can be a bit annoying
 
Referring to this techradar.com/news/world-of-tech/… not sure if I got the most reliable source there though
 
11:24 AM
@skiwi Which is why you make those things in pure hardware, unreachable by software.
Should suffice for most computers.
 
Unplug the power cord, boom done
 
Imagine a human-like robot that actively prevents you from reaching its off switch ;)
(Which is running on batteries)
 
user image
2
@skiwi Oh, so that's why we keep using volatile batteries.
 
I guess C4 is a decent last option
 
@Mast Lol :D I watched that so much when I was younger
 
11:28 AM
@Mast I asked about the hanging of the man on site. Hopefully someone has some suggestions.
 
Meh, I have a 20cm pile of paper on my desk
 
0
Q: The right way to hang a man

N3buchadnezzarProblem: I have seen a few questions around hangman. Usually this is done in a very hackish way, which usually can not be generalized any further. My thought or question is about the creation of the gown, which is a central part in any hangman game. I want to create the ASCII image below ___...

 
@skiwi More than enough to start a fire
 
Just don't light it as a stash. Get some air in between. Spread it out a little.
 
I think, this question should be in the Code Review section. — Jeroen van Langen 41 secs ago
 
@skiwi Did you know Adam and Jamie aren't friends in real life?
 
This might belong on Code Review instead. — DonBoitnott 32 secs ago
 
@overactor As long as they don't show it on the set, meh.
 
If the code works but is just slow, that would be OK for Code Review — Phrancis just now
 
I agree
it was surprising to me though
 
11:39 AM
0
Q: Convert the for loop to accept ID type

Omer JanjuaI want to be able to reuse this method so it's not restricted by the Event class being called in the for loop declaration. The problem is the compiler has no idea what id actually is, so I cannot use . notation on it. I need to cast it to a whatever type of Event class i'll be passing it, inste...

 
@Mast does CO post all new questions? :p
 
0
Q: Parallel.For vs Parallel.Invoke

TheLethalCoderI have a bunch of methods that are exclusive to each other and as such can run in parallel. Is there a good way of doing this? So far I have the below two implementations, but I am not so sure if I should go with one or the other. Using Parallel.For: Parallel.For(0, 2, i => { switch (i) ...

 
@N3buchadnezzar Yes, its a feed
 
11:55 AM
@overactor Actually no, but doesn't really matter I think, can't be friends with everyone
 
Monking all
 
Monking
 
lol
> A teacher about writing code (on paper) on an exam: "The parser will be my brain, and I am more flexible than your computer. If you make syntax errors, I might nto even notice, and I will certainly not care."
 
0
Q: Should a code review answer contain fully rewritten code

Thijs RiezebeekOften when I am reviewing code on CodeReview.SE I focus on readability of code, SRP, testing and things of that nature. For example, as I am writing an answer, I point out bad variable, function and/or class names and suggest (better) alternatives. I clearly state why bad names are bad in general...

 
> You've earned the "beginner" tag badge
3
 
12:10 PM
@syb0rg ?
 
@syb0rg Congratulations, you are a professional beginner now!
 
@syb0rg Congrats!
 
Lol, you need a score of 100 in 20 different answers to get it
I have a score of 200-something and 20 answers
 
I initially read that as 100+ for every answer of those 20
 
12:12 PM
Incoming baddie
I'm apparently the top performance asker? codereview.stackexchange.com/tags/performance/topusers
 
haha, nice find
There should be a tag to indicate that the solution might involve overengineering, maybe I could top something then :P
 
-1
Q: What's wrong with this binary tree code?

Gus AndrianosApparently my professor gave me bad code, right before the exams. struct node{ int ID; float Datum; struct node *left; struct node *right; }; int insert(struct node NN, struct node **R){ struct node *cur,*F=0; cur=search(*R,NN.ID,&F); if (cur) return 0; cur=(struct node...

 
I think I'm going to try and target some more tag badges, I don't have many and they look nice on my profile
 
I got none, should probably at least get bronze Python.
 
@EBrown here
 
12:26 PM
> I don't envision anyone over here suing you in the near future. I may sue Undo, and possibly ArtofCode, but only if I get super-bored, and most likely for reasons unrelated to their use of SO/SE.
 
Lol, I found something from vwo 4 on my desk, my school history is like havo/vwo 1 - vwo 2 - vwo 3 - vwo 4 - vwo 5 - vwo 6 - uni 1 - uni 2 - uni 3 - uni 4 - uni 5
 
why am I doing all this in sql
 
(That's one year each)
 
I can just connect LINQPad and write LINQ
 
@JeroenVannevel So why didn't you?
 
12:31 PM
because I just realized it
 
@skiwi Must've been using the shadow map to stay out of sight.
 
and my sql looks too pretty to let go
 
So be a stubborn masochist and keep going in SQL.
 
@Mast I removed some mat from my desk today, it was under that :D
 
Has that mat been there for 7 years?
 
12:34 PM
1
Q: Helper utilities for easier benchmarking the efficiency in C

coderoddeI have this tiny library for measuring the execution time in milliseconds and returning the duration plus the result: execres.h /****************** * File: execres.h * ******************/ #ifndef EXECRES_H #define EXECRES_H #include <sys/time.h> typedef struct { unsigned long long milli...

 
hello mates. Anybody willing to help me with some C logic ? ^^ dpaste.de/F3cV
 
possible answer invalidation by Nishant on question by Nishant: codereview.stackexchange.com/posts/131258/revisions
 
@Cajuu' One sec, I'm answering the C question above your post
 
@syb0rg sure, no problem ^_^
 
12:38 PM
Warning: Null value is eliminated by an aggregate or other SET operation.

(37747 row(s) affected)
hmmm
Please tell me it talks about rows affected when you insert into an in-memory table?
 
@Mast Yes
 
@JeroenVannevel Every row inserted is a row affected.
 
Zak
@JeroenVannevel Doesn't it talk about rows affected for any query?
 
@Duga seems ok
 
@syb0rg as an idea, I just want to print the lines from file1 which are not in file2.
 
12:45 PM
0
Q: Designing 3rd party API abstraction to be testable

mabiI'm implementing an interface to the Force.com REST API, with very specific ideas about which parts of the API I need. My problem is with testability of consumers of this API abstraction. The first thing I came up with was a Gateway, one method per action: interface SalesforceApiGateway { f...

 
Hi @marsze... yes I've read that a few times... I don't need this to be 100% reliable, this is to assist with a manual code review. There are a LOT of nested For loops many of which should be refactored out to their own function, hence the question. RegEx is the only tool that I can implement quickly and easily, imperfect as it is. — SlowLearner 39 secs ago
 
@Cajuu' So do you have an error?
 
Hi @ThomasAyoub - first time the web page didn't load properly (text only)... stared at it for ages then gave up. Looked again and sure... it seems to work. I am attempting to put the RegEx into MZ Tools 8 - Code Review function, should (as far as I understand it) be using the .Net RegEx... although your Expression seems to meet my need I can't get it working in MZ-Tools :-( (yet) — SlowLearner 9 secs ago
 
@syb0rg nope. My brain just got stuck from there. I just don't know what to do from there.
 
@Cajuu' The Linux comm command does pretty much the same thing, I'd suggest looking at their source code: opensource.apple.com/source/text_cmds/text_cmds-88/comm/comm.c
 
12:57 PM
I feel like I'm really close but I don't know how to go on from that. I know this, I just wanted to have a smaller piece of code for this case.
 
@Cajuu' Well are you just printing the lines from file1 not in file2 to stdout?
 
@syb0rg yep
 
@Cajuu' Okay, so don't check the strcmp() to see if they're equal, check to see if the return is not 0
Then print the line
 
@syb0rg you mean something like this ? dpaste.de/EfTC
I tried but it's not giving the right output ^^
 
I wouldn't expect it to, there are some other things wrong with your code
But it's a step in the right direction
@Cajuu' Have you ever used a debugger before?
 
1:04 PM
yes, I also ran gdb on this but I didn't succeed to go further
 
@Cajuu' How did you run it? What were the steps you did?
 
well, gdb on the output file and the set a break point to several lines
just the basic steps
 
Were you stepping through the code and printing out the contents of variables?
Verifying that they were what you thought they should be?
 
yep
 
What is the program outputting now?
 
1:08 PM
it's outputing each word from file1 several times each
it's like the strcmp isn't even evaluated
 
Morning
 
but it actually is...
 
@Legato Morning
 
morning
 
Is it called anything special when two dices show the same number of eyes?
 
1:10 PM
@Cajuu' When you break on the strcmp and step, what are the contents of both variables right after?
Before it gets printed?
 
each of them is the first line of each file
 
Can you paste them here?
 
what ? the files ?
 
@Cajuu' No, the gdb output from printing the variables
 
0
Q: C# Model-View-Presenter Winforms App First Attempt

Michael Brandon MorrisThis is my first attempt at a Model-View-Presenter pattern Winforms application. The model is a class that stores a bunch of primitives, and the view is a Form that provides a ListBox for selecting individual Data items, whose members are then displayed in text boxes. DataModel.cs using System;...

 
1:17 PM
@Mat'sMug Can you take a look at this answer for me? codereview.stackexchange.com/a/131329/27623
Not sure if it's an actual answer or not...
 
sure, in a sec
@syb0rg this is it, a little cut off: (gdb) print buffer_line_template_file
john
(gdb) print buffer_line_data_file
man
(gdb)
 
And john is the first line of file1?
And man is the first line of file2?
 
yep
 
And it prints "john"?
That's what I'd expect to happen
No?
 
well, yes
 
1:26 PM
And then it's going to go through all the lines in file2 and compare them to john again
And if it's different, print out "john"
 
yes, that's what it happens
well, that should happen
 
So you want it to break out after one different line?
 
well, I know how to break it, and if I do, the output will be all the content of file1
just not multiplied like it's right now
the flow as I see it is:
 
You could keep track if there is a match between file1's line and all of file2's lines with a flag
 
-1
Q: Minesweeper counting mines

ZacharyI have a large piece of code for minesweeper, and I can get it to mostly work but sometimes certain buttons do not count up or down left. I also can't get the check win for the difficulties to work even though I've checked it out with other working sources and had no difference. This is the code ...

 
1:29 PM
After comparing them all, if there were no matches, print out the difference
I think that is the behavior you are looking for?
 
take line1/file1 and loop through all the lines of file2 to check if there's no matching line. If there's no line, print line1 from file1 and go to the next one
yes
 
@CaptainObvious No.
 
@Cajuu' Yeah, I'd add a flag to keep track if there are any matching lines and after iterating through all of file2 check the flag and print out the line if necessary
 
@syb0rg I tried but I guess I did it wrong because I wasn't able to have the correct output
 
bool match = true;
if(line1 != line2) match = false;
if(!match in both files) print stuff
 
1:36 PM
that Boolean should be declared before the second while() loop, right ? And the rest of your pseudocode would go inside my if(), right ? ^^
 
bool should be at top of method, yes
Set match in the strcmp
Check match after inner loop
 
"bool should be at top of method, yes" -> what method ?
 
main
 
1
Q: Heavily templated mathematical vector class

LukeGI started to write a library for linear algebra for personal use, but also for revitilization of my C++. Below is the first class of this library, a templated vector class, which is templated over the type of the elements as well as the size. It supports all common operations of vectors as membe...

0
Q: Python: Winning Poker Hand Euler54

PaRaXeRoXThe problem can be found here. The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands...

 
@syb0rg I'm sorry but I don't get what you mean by: if(!match in both files)
the strcmp ?
 
1:42 PM
@Cajuu' So after looping through all the lines in both files and comparing them, the flag is going to be either true or false
If it's true, there was a match between the files
If it's false, there was no matching line, and therefore we should print out the oddity
 
yes, I understood this. I don't know what you meant by that if condition
 
if(strcmp(...) != 0) match = false
That's the only comparison you should need in your inner while loop
while{while{} if(!match) puts(line1)}
 
oh, got it. something like this: dpaste.de/ujpr
 
The stuff you find when cleaning up is amazing
 
@Cajuu' Move that last if one brace lower
 
1:50 PM
right, silly me
well, it's still printing all the content of the first file
 
Oops, I set up stuff wrong
Initialize the flag to false, break from inner loop as soon as the flag is true
Otherwise we overwrite the value
 
Like this ? dpaste.de/qYcg still the same. If in the last if I put if(!match) I don't get anything
 
The strcmp should be checked to equal 0 now
 
@syb0rg not very clear, question is OOOOOOOLD and CW anyway. deleted.
 
@Mat'sMug Cool, I was just worried it was a valid review I was working to delete
@Cajuu' Also, last flag check should be lower still
 
1:58 PM
@syb0rg you mean something like this? dpaste.de/bhhR
 

« first day (1130 days earlier)      last day (2892 days later) »