« first day (660 days earlier)      last day (3358 days later) » 

11:00 PM
I managed to avoid buying many things when I studied.
 
ok check it out now
 
link @JasonLind ?
@SimonAndréForsberg Yeah. And I'm going to argue that for programming, it might be useful to have a book when you are very first learning programming, but after your first language and after you understand how programming works, you can find everything else you want online.
For free.
 
Slap me silly and call me sally but I like those overpriced textbooks
 
2
Q: Is this pattern of Task queueing acceptable?

JasonLindThe AsyncWorkerQueue class uses TPL Data Flow and Rx to async process and cancel work in a queue. It takes in a worker factory (Func) and executes it when its turn (or not if its scheduled to be canceled). public class AsyncWorkerQueue : IDisposable { private TransformBlock<TaskFactory, Task...

 
Okay Sally.
What's especially silly is that books that are marketed as textbooks are more expensive than equivalent books that aren't marketed as textbooks.
 
11:02 PM
@nhgrif totally agree with you there. I didn't buy any programming book when I studied programming. Although I did have two programming books when I was a kid, "Delphi Programming for Dummies" and "Mastering Delphi 4" by Marco Cantù.
 
There's a difference between a pure language book and other things though. Like a framework, methodology or a specific aspect
 
One word book: Java Concurrency in Practice
 
0
Q: Letter Combinations of a Phone Number

itsmeI was asked to code a solution in Python in 15 mins. Print all possible word combinations for a given phone number. Numbers 0 and 1 will not be part of the phone number, the numbers can be repeated, phone numbers can be of any length. For example if the number is 245: All combinations of 'ABC', ...

 
@JeroenVannevel Even still, I've seen books that inside look and read like textbooks, but they're not marketed as a textbook and not sold on a college campus, and they're 1/2 or 1/3 price compared to a typical textbook.
 
Morning :)
 
11:14 PM
2 downvotes but no comments why the downvotes...
-2
Q: Batch file for looking through text files

User_143I was creating a program and I was trying to explain it to some of my coding friends. They commented that it was too tedious typing out all the "if" commands. How do I streamline this code? Note: this is a ".bat" program. Waiter.bat @echo off set /p Food="What would you like to eat? " if /i %F...

 
@SimonAndréForsberg maybe because of Food="What would you like to eat? :P
 
Is that the source code?
I don't have a clue how .bat files work.
 
@Mehrad you mean it won't work?
I also don't really have a clue about .bat files
there are no close votes on it yet though
 
.bat only runs on Windows, eh?
 
11:24 PM
@SimonAndréForsberg I was joking :)
 
@Mehrad well, the thing is... I'm not sure it works myself
 
Anyone here have a Windows machine?
You should be able to test his code now. He included an example of what Menu.txt looks like.
 
yup
just ran it
it works fine
c:\Users\Simon\Desktop>da
What would you like to eat? Pizza
Pizza | Flattened dough, layered with tomato sauce, cheese, and choice of toppin
gs.
Press any key to continue . . .

c:\Users\Simon\Desktop>da
What would you like to eat? Macaroni
Macaroni| Macaroni pasta with cheese.
Press any key to continue . . .

c:\Users\Simon\Desktop>da
What would you like to eat? asfa
Press any key to continue . . .

c:\Users\Simon\Desktop>
 
Okay.
 
I named his file "da.bat". perhaps not the best naming choice I ever made...
 
11:27 PM
Can't he just do:
finstr "%Food%" Menu.txt
Or rather...
 
@nhgrif I believe so. That would be a good review if it works.
 
findstr "%Food% | " Menu.txt
Try that @SimonAndréForsberg in place of the if statements.
 
c:\Users\Simon\Desktop>da
What would you like to eat? pizza
Pizza | Flattened dough, layered with tomato sauce, cheese, and choice of toppin
gs.
Bread | Dough that has been baked.
Macaroni| Macaroni pasta with cheese.
Press any key to continue . . .
didn't seem to work as well, @nhgrif
 
Strange...
Why does it return all of the lines in this case...?
Maybe the pipe is special in the txt file?
No...
 
no clue
no, I don't think the pipe has anything to do with it
 
11:30 PM
@SimonAndréForsberg Did you try it without the pipe?
 
wait a minute...
findstr %Food% Menu.txt works
 
Without the quotes?
 
0
Q: Working with C++'s Queues

T145So, to teach myself how to work with queues in C++, I started out simple. All I want to do is find the greatest value contained within a queue of integers. When I did this: int max(queue<int> ints) { int greatest = 0; if (ints.size() >= 2) { while (ints.size() != 0) { ...

 
yup, without the quotes
although now I can enter "tomato" and it will show the Pizza
 
Yea, you need to have the pipe at the end.
 
11:32 PM
c:\Users\Simon\Desktop>da
What would you like to eat? Pizza
Pizza | Flattened dough, layered with tomato sauce, cheese, and choice of toppin
gs.
Press any key to continue . . .

c:\Users\Simon\Desktop>da
What would you like to eat? abc
Press any key to continue . . .

c:\Users\Simon\Desktop>da
What would you like to eat? tomato
Pizza | Flattened dough, layered with tomato sauce, cheese, and choice of toppin
gs.
Press any key to continue . . .
 
Although... if you wanted something tomato-y... that's what you should order.
So I was Working as Intended.
 
Is there a way you can concatenate the pipe to the end of the input, so you don't put the quotes when using findstr?
 
@Simon, pushed an update, FYI to the UBench code.
 
codereview.stackexchange.com/questions/82426/… <-- this has some obsolete comments.
 
@nhgrif I'm also inclined to consider it a feature improvement :)
oh hey, @rolfl. thanks for the info.
@nhgrif then flag them ;)
@SirPython I was also thinking about that... no idea how you do string concatenation properly in batch...
 
@nhgrif It does? ;-)
 
set "searchStr=%Food% | "
findstr %searchStr% Menu.txt
Try that?
@SimonAndréForsberg
 
I do not understand these results...
c:\Users\Simon\Desktop>set /p Food="What would you like to eat? "
What would you like to eat? Pizza

c:\Users\Simon\Desktop>set "Food=Pizza |"

c:\Users\Simon\Desktop>findstr "Pizza |" Menu.txt
Pizza | Flattened dough, layered with tomato sauce, cheese, and choice of toppin
gs.
Bread | Dough that has been baked.
Macaroni| Macaroni pasta with cheese.

c:\Users\Simon\Desktop>pause
Press any key to continue . . .
I removed "@echo off" to see the actual printed commands
 
This is way confusing...
 
11:41 PM
@Jamal - you on top of this? -> codereview.stackexchange.com/q/82334/31503
 
You didn't copy and paste correctly though?
 
@nhgrif findstr %searchStr% Menu.txt <-- searchStr needs to be in quotes otherwise it will be very unintended behavior...
@nhgrif wasn't your code I tried this time
 
But it is strange...
 
@nhgrif your code produces this:
 
If you findstr Pizza ... it finds just one line
 
11:42 PM
c:\Users\Simon\Desktop>set /p Food="What would you like to eat? "
What would you like to eat? Pizza

c:\Users\Simon\Desktop>set "searchStr=Pizza | "

c:\Users\Simon\Desktop>findstr Pizza   | Menu.txt
and then Notepad++ opens, editing Menu.txt....
 
oh lol...
 
@rolfl Yes
 
I really don't understand how findstr works...
 
Wait, @SimonAndréForsberg try yours, but enter "Macaroni" rather than "Pizza"
The pipe is probably the problem. The pipe in the findstr argument, not the pipe in the .txt file.
 
How to break the test suite: use Console.WriteLine in the test.
 
11:44 PM
@nhgrif agreed, that outputs the entire file. for some bloody strange reason.
 
Yeah, because you're concatenating the commands
So hang on
you need this command:
findstr /C: "Pizza |" Menu.txt
 
Yea. Apparently.
Oh, the /C isn't a directory... but an argument flag.
 
suddenly I get the feeling that I should run this on a virtual machine...
Feb 19 at 22:34, by nhgrif
With the right code, I could tell you to copy & paste a snippet into your Swift playground, and wipe your entire hard drive (or whatever malicious stuff, etc.)
 
Ah, so findstr finds multiple space-separated pipes.
And since the | is in every line, you're searching for "Pizza" and "|"
But /C:"literal string" will search for a literal string.
 
11:48 PM
c:\Users\Simon\Desktop>set /p Food="What would you like to eat? "
What would you like to eat? Macaroni

c:\Users\Simon\Desktop>set "Food=Macaroni |"

c:\Users\Simon\Desktop>findstr /C:"Macaroni |" Menu.txt
that one works fine, @nhgrif
set /p Food="What would you like to eat? "
set "Food=%Food% |"
findstr /C:"%Food%" Menu.txt
pause
 
Now that's not working because "Macaroni|" is what is actually in the .txt
 
@nhgrif exactly. I just wanted to make sure it didn't print the whole file. Pizza worked fine though
so with a simple fix to the Menu.txt file, there's your answer!
 
0
A: Batch file for looking through text files

nhgrifWith the help of a Windows user in chat (Thank's Simon!), we've got a much better solution figured out: set /p Food="What would you like to eat? " set "Food=%Food% |" findstr /C:"%Food%" Menu.txt pause This will concatenated the pipe character to the end of the user-entered string and find the...

 
I love it when I can learn stuff by helping @nhgrif review code!
 
lol
 
11:52 PM
had no clue about string concatenation and the findstr command
Now... when will I have use for this next time?
 
Never.
 
What kind of string concatenation?
 
probably
@Hosch250 in a batch file
 
How does it work, with a +?
 
@Hosch250 I had to reject your suggested edit on @nhgrif's answer because your edit would remove some stuff that was added later
@Hosch250 pffft! Such luxury operators!
 
11:56 PM
@SimonAndréForsberg What?
 
set "Food=%Food% |"
 
My edits don't go in the queue.
Also, when did I edit his answer?
I'm not sure what you are talking about.
 
sorry, wrong user. I meant @SirPython
Gotta be careful with the pings!
 
@SimonAndréForsberg Oh, sorry about that. I guess I didn't read what he wrote correctly.
 
You clicked edit, then I submitted my edit, then you submitted yours.
I added a lot more after you originally clicked edit.
 
11:58 PM
@SirPython I think you did, it's just that he edited some stuff after you suggested your edit
 
Oh! I get it now.
 
No harm done.
 
@Jamal Good news!
 
> Community♦ reviewed this 2 mins ago: Reject
This edit conflicted with a subsequent edit.
 
Attention!
Everyone on their best behavior!
We have company.
 
11:59 PM
Huh?
 
Who?
 
Welcome to The 2nd Monitor, @Loufylouf
 

« first day (660 days earlier)      last day (3358 days later) »