« first day (683 days earlier)      last day (3335 days later) » 

9:02 AM
0
Q: Compare collections

MikroDelI have two Collections and want to compare them. var valueFirst = new ValueFirst(); valueFirst.Id = 1; valueFirst.Amount = 12; ... var valueSecond = new ValueSecond(); valueSecond.Id = 123; valueSecond.Amount = 12; var firstCollection = new FirstCollection<ValueFirst>(); firstCollection.Add(...

0
Q: creating a sokoban game

mertimiksOkay, so I want to code the first 5 levels of http://sokoban.info game, create the fork of this game, and then connect to facebook. Does anyone know where I should start with this task?

 
9:24 AM
I think, you need to put your question here : codereview.stackexchange.comJenis Patel 25 secs ago
 
9:46 AM
I almost got populist on StackOverflow. Almost ç__ç
27 to 15. I guess that I need 31 for the populist badge.
 
I have a mad.
I commited code yesterday trying to fix CORS and cookie based authentication.
Someone said tehy "fixed" it
their idea of fixing it was removing the abstraction and dependency injection I had used to put a hardcoded reference to the CORS origin in the code rather than in the config file and remove the ability for angular to send cookies to CORS requests
2
So, basically, they moved stuff around a bit and hid the problem by removing the code that exposed it and then said they "fixed" it.
 
tell me again: why did you hire these people?
 
I didn't.
The best bit is, is that i tested it then and it STILL Has the same problem as yesterday: cookies are not being sent with CORS which means the CORS API does not realize the user is logged in.
my mind is boggled that they removed withCredentials though
" By default, in cross-site XMLHttpRequest invocations, browsers will not send credentials. A specific flag has to be set on the XMLHttpRequest object when it is invoked."
so yeah we're trying to authenticate cross-site, lets remove the flag that lets us do that
 
I think this is the moment where you can go "file a complaint"
 
we already have a meeting after lunch to discuss this internally
Why on earth they have decided to use cookie based authentication when they know that all of the consumers of the API will be using it through HttpClient in C#
and ALL of them will be doing it cross origin
is beyond me
 
10:07 AM
0
Q: From sounds (Hz and seconds) to musical theory

Alberto CapitaniThe following procedures are an attempt to connect some physical aspects of the sound (frequency and duration) to traditional music theory. Each procedure is accompanied by one or more examples. The names of the procedures are in Italian, but thanks to the examples should be understandable to t...

0
Q: Simple Factorial Interview Task

OmidI did this code for an interview. Can you tell me how it looks? I didn't get the job, so I'm wondering what I could do better in my code. ** * TASK 1: IMPLEMENT: C - binomial coefficient * * C(n,k) = n! / [ k! (n - k)! ] * Where x! is the factorial of x * * Use a recursive solution. If ...

 
I'm not sure that this question is appropriate here. Perhaps code review would be a better site. Your final question is certainly opinion based. First two questions. 1. Yes, this is OK. 2. No, no problems. — David Heffernan 1 min ago
Maybe this is a topic for codereview.stackexchange.com ..? — fuubah 1 min ago
 
10:40 AM
as you are asking how to do this you need to ask this in Server Fault, not Stackoverflow. Stackoverflow is for code review — idarryl 1 min ago
 
0
Q: Is this an acceptable way of calling common async code from a derived method?

Steven RandsI'm implementing a number of classes in C# that have async methods. However, each of these methods needs to implement some boilerplate code that is common to all. Therefore I've implemented the common code in an async method of a base class; the async methods on the derived classes then call this...

0
Q: Simple thread-safe loading cache based on RxJava

Alexey DmitrievI'm sketching a simple thread-safe cache which can load missing values. It is based on RxJava's Observable which also means that it should be possible for a client to join a request for value which is already in flight. I'm writing it in Kotlin. My major concern is how to make it thread-safe w...

 
better use codereview.stackexchange.com for such questions — dit 1 min ago
 
10:56 AM
0
Q: Where should logic of variable instantiation be?

Low Kian SeongThis is from the Python's builtin xmlrpclib.py class ServerProxy: """uri [,options] -> a logical connection to an XML-RPC server uri is the connection point on the server, given as scheme://host/target. The standard implementation always supports the "http" scheme. If SSL ...

 
@Duga Stackoverflow is for code review - wait, what!?
5
 
wat
 
Nice.
Did you Europeans hear about my website? No real content yet, but nonetheless:
 
@JenisPatel This seems to be just example code, which is off-topic for Code Review. If this would be posted to Code Review, we would need to know the real code and the real context behind it. — Simon André Forsberg 20 secs ago
 
@nhgrif yes, I did hear about your website!
 
11:14 AM
@nhgrif yes sir, :)
 
Monking
7
 
11:37 AM
Monking guys
 
My monking deserves a star?
6
 
@skiwi I guess so. Maybe it deserves two....
 
0
Q: Large readable if statements

Mike EasonI have a method which creates some default values in an ObservableCollection, nothing too fancy, but I'm trying to decide how to write the if statement. private void CreateDefaultParameters() { //If there are no parameters, then create default ones. if (this.Parameters == nul...

 
4.
 
11:51 AM
There surely are some starhappy people here
 
I wouldn't know who.
3
 
0
Q: Script to toggle touchpad

maki57This sequence properly shows whether the TouchpadOff option for synclient is on or not (outputs either a 0 or a 1): synclient | grep 'TouchpadOff' | tail -n 1 | awk '{print substr($3, 1)}' Trying to make a keyboard shortcut to toggle the touchpad with a basic script based on that line, I wrote...

 
12:21 PM
Quiet this morning.
 
> clicky clack of dozens of keyboards
 
12:51 PM
So, although all of the generic type blog entries will most likely be in Swift, I do intend to cover a wide variety of programming topics.
In fact, I sort of intend it to be a sort of general programming topics type blog. Like the sort of tips that I could leave on a code review post for a language I don't know at all.
And there should regularly be beginner friendly topics.
 
0
Q: N+1 query on ruby on rails. How to add includes() methods on instance of a model

Cássio GodinhoI have a has_many through relationshipt between my cities and travels that looks like this class Travel < ActiveRecord::Base has_many :cities, through: :destinations end class City < ActiveRecord::Base has_many :travels, through: :destinations end And on my Travelcontroller I have a method...

 
@nhgrif I find that if something is well written, most ideas about programming aren't restricted to the language it's written about.
I mean, OOP is generally OOP, Functional is generally functional. The core abstractions apply.
 
1:07 PM
Greetings, Programs.
 
@Donald.McLean Greetings, User
 
Well, that's the goal. But there will likely be some iOS dev specific stuff.
I intend to make that relatively rare though... I think.
 
1:25 PM
@RubberDuck about that question yesterday
 
Fight the fight!
Monking @Malachi.
 
that is what this new one is supposed to look like
(Fake Case)
Monking
time to get some coffee and check on my Raiding Fleet
 
That makes a bit more sense, but..... still.
 
@Malachi what's that?
 
1:49 PM
It's raining, it's pouring, the programmers are snoring.
Who spam voted me yesterday? Was that you @DanPantry?
 
@nhgrif am I in trouble? If so, no
 
Not in trouble, but all your votes were reversed.
 
Awright
Guess you'll have to get it legitimately then ;-)
jk
 
-100 Serial Voting Reversed
 
LOL
 
1:55 PM
 
@RubberDuck IKR
@DanPantry what I deal with on a regular basis....
 
RIP
 
I added pictures
 
2:20 PM
0
Q: Netflix Login script

ibtjwMy question is what are my options on how the loginToNetflix method is called? Is there a more clean and elegant way of accomplishing this? Any input is much appreciated, thanks. loginToNetflix(credentials.username, credentials.password); function loginToNetflix (username, password) { casper.st...

 
ya. that's kinda how it works, right?
 
0
Q: Pinch, swipe and doubletap/click prevention

MichelPartly for fun, I wrote my ow script to detect pinch, swipe and doubletap/click to be used on touch devices as well as desktops. It works OK, but there is always room for improvements. So any comments are welcome. From start to finish (I.E. if there is an actual click/tap) it runs in ca. 380 ms....

0
Q: 3 selects on a page and 2 of them need to be observed for changes

RodThere are 3 selects on a page. 2 selects are populated and 3rd empty. Onload takes both populated selects and combines them into 3rd select with groupings. An external event is simulated with button on page, which adds an option to one of the populated selects. I am using DOMSubtreeModified eve...

0
Q: Displaying and updating JSON in a table with Angular

Jose the hoseGood afternoon folks. I have put together some Angular JS that basically displays json in tables and allows the user to select a row from the table to change the value of an item in the json. Although it works I'm not really happy with it as it seems a little messy. I will explain how it works......

 
Monking all.
Happy Wednesday
 
thanks, monking and happy wednesday to you ;)
 
2:35 PM
Happy Wednesday :)
 
0
Q: How to fasten up this loop heavy code?

PhunI try to transfere Matlab calculation to C and call it using .mex for speed gains. My goal is to perform for a matrix \$ B\$ which has roughly the dimension 10000x1000 \$ \frac{1}{\text{size(B,1)}}\sum_{i=1}^{2+l*t} \text{mean}( (B(:,i)-B(:,i+1))^2)\$, for \$ l*t<\text{size(B,2) and chosen } t...

0
Q: My Rational struct, version 1

Rick DavinI have written a Rational struct for working with rational numbers, i.e. Rational(int numerator, int denominator). A recent post regarding rational numbers peaked my interest. I particular like the answer by @aush with his RationalNumber class. I am inclined to think of a rational number as ju...

 
Happy Wednesday too! :)
 
Well, I go away for a couple of days... and... everything is still in order.
Life goes on... nice./
 
@rolfl have you heard? importBlogKit.com
 
I like it when you are not away !
 
2:42 PM
@nhgrif Nope had not heard... is that yours?
Also, this is sure to make the rounds at some point.... so I thought I would get the chat all fired up with it:
5
Q: Congratulations! You're about to graduate... with a twist

Robert CartainoI wanted to pass on the announcement that this site has been cleared for graduation… congratulations! Graduation comes with it some perks — a listing in the footer of the other sites, you can start migrating content to and from this site, we have things like "community promotional ads" which are...

^^^ That is Network Engineering
> We are going to try a new workflow where we are essentially graduating this site before the design is ready. Graduation will work exactly the same in every other way, but we don't yet have an ETA for when your design will be finished. We felt it unreasonable to continue holding you back while we catch up on that backlog, so we're going for it!
@Mat'sMug / @Simon / @Malachi / @all ^^^ FYI
 
@rolfl yes. I bought it and spent about 5 hrs on it last night. Need to get some actual content on it this weekend.
 
oooh shiny!
oh wait, it's not on our meta
 
No, it's not ours, and this announcement for NE is apparently going to have little/no impact on the plans for CR.
 
nope, that's Network Engineering beta.
 
except...
 
2:46 PM
@rolfl so what you're saying is, that they graduate before us, because we're waiting for the design and they don't?
 
> The first indication that you have finally graduated will be the removal of that "beta" label (yay!)
 
@Vogel612 - essentially, yes.
 
they're changing the workflow.. I understand we're no longer waiting for it either
 
But, we will likely get colors before them
@Mat'sMug - only NE is in this new workflow.
 
this looks like a pilot
 
2:47 PM
no other sites are in that flow, and it is an experiment
 
hmm
 
so if things go awry over there, they won't do that again
 
can't we get the removal of that "beta" label too?
 
but if it works, then it might even come for us?
 
cross your fingers!
 
2:48 PM
@Mat'sMug the beta label seems to be tied to some internal flag
 
looks tied to some .png to me
wipe the png, gone the label
 
if that label gets removed, the privilege requirements get upped, too
 
The beta label is tied to privileges and elections
 
since that is exactly what happened when there was this whole graduation thing
 
@Mat'sMug - to be clear, this will have no impact on CR until the NE pilot proves to be successful
 
2:49 PM
yeah I get it ;)
 
By the time that proves successful, or not, we will likely have our colors anyway
 
right
 
oh so there is an ETA for the colors? or is that just your guess?
 
If it is successful, and we still don't have colors/graduation, then we will likely be added to whatever workflow makes sense.
 
and if it's not everything stays the same..
 
2:51 PM
@Vogel612 no ETA
 
I have no ETA on colors, other than that I expect the order for design processing will be little effected by this.
In essence, being in this new workflow will probably be a mixed blessing.... on the + side, you get elections, etc. On the - side, the design is probably even more delayed than before.
 
is the design team's stack overflowing?
3
 
Recent migrations, BTW:
0
Q: Search strings within a list from strings within a dictionary with the least complexity

DorkI have the following input: newValue = [['men', 'John Doe,Chris perry'], ['women', 'Mary,Anne,Lita']] - list within list keywords_list = [('MEN', 'john,zack')] - tuple in a list (Dictionary on which .items() is used.) Expected Output: newValue = [['men', 'John Doe'],['women','']] What I ...

1
Q: ThreadPoolExecutor singleton

Adroid FreakI'm trying to build a ThreadPoolExecutor singleton to use it across my app, I'm very new to this concept and after going through Google docs I have created this, public class MyThreadPoolExecutor { // Sets the amount of time an idle thread will wait for a task before terminating private...

1
Q: Factory pattern for creating sub classes derived from interface with generic type

Edwin BoykinWould like to know if the factory pattern I've implemented for my stat library is the correct way to go. I have an interface IPlayerStatsManager where the type parameter is an interface as well (IPlayerStatsModel). The IPlayerStatsManager is an interface that lists the common operations that can ...

 
something's not right
//concrete implementation
public class BasketballPlayerStatsManager : IPlayerStatsManager<BasketballPlayerStats>
{
    public BasketballPlayerStatsManager(DbContext context)
    {
    }

    public async Task<BasketballPlayerStats> GetPlayerGameStats(...)
    {
    }
}
> Here's the code (some of the implementation removed for brevity)
ah
 
you write the auto-comment?
 
2:57 PM
I just copy-pasted from the OP
 
@Mat'sMug I do hope they use a Queue and not a Stack
else we're gonna wait a looong time for new colors
 
lol yeah
first in last out
but an overflowing stack sounded funnier
@rolfl what's your moderator-hat point of view on that "implementation"?
I'd call it a design review and reject migration
 
looking.
 
or are we too picky?
 
no I think not.
OTOH I doubt it's that much of a problem for OP to add the stripped implementation
obtw, that java question is easy prey IMO
 
3:00 PM
but OP doesn't have an account...
 
mostly since it's
 
@Mat'sMug - it's an in-between amount of real code and stub code. I would leave it to the domain experts (C#...).
Specifically, I feel like there's significant reviewable content in:
 
// concrete implementation
public class  BasketballPlayerStats : IPlayerStatsModel
{
    // various class members with getters and setters
}
I VTC'd
 
public static IPlayerStatsManager Create(DbContext context, int sportType)
{
    if (sportType == (int)Utils.SportType.Basketball)
    {
         return (IPlayerStatsManager)Activator.CreateInstance(typeof(BasketballPlayerStatsManager));
    }
    return default(IPlayerStatsManager);
 }
 
there is
 
3:04 PM
@rolfl ouch, yes there is
 
actually...
 
In a sense, I think he's stripped out abut the right amount of crud to leave the core implementation of the persistence layer and so on... it's actually probably a well-structured review question for reviewing only one aspect of the implementation
 
I split the code block in two - only the context code seems stripped down
 
Yup.
 
0
Q: C/C++: Performance issue for reading large text file from network

Pramod KumarI am facing performance issue while reading large text file from network. Same file is read locally without any performance problem. FILE *fp = NULL fp = fopen(file_path, "r"); while(1) { if (fgets(line_read, 160 ,file) == NULL) { if(feof(file)) return linecount; else ...

 
3:11 PM
What would you do if you weren't married and someone you had never seen or heard of before wrote to you and said "will you marry me?"?
Nothing but that.
Someone from India did this to my sister, and of course she refused.
 
Sounds like she did the smart thing ;-0
There have been two interesting recent Indian weddings....
 
Yup, I saw those.
The groom who had a seizure can be lucky she didn't marry him.
 
The bride of the guy who failed the math test was smart.
 
Not to say he's not a good catch, and all, but a "will you marry me?" introduction is not exactly a good pickup line.
 
3:17 PM
reviewed
 
VTC & answer ..... huh....
;-)
 
edited & retracted
;)
 
@rolfl but... but... but what about us!?
 
that's what we have a chatroom for, right?
 
right... now, I have a cinnamon bun with lots of icing, waiting for me down stairs, with a cup of fresh coffee I need to brew.
These are important things... so, I am out of here for a bit (bite).
 
3:19 PM
byte
 
Mega-byte.
 
depends on the size of the bun
 
Maybe he'll swallow it whole.
Anyway, I'm out of here to study accounting, spring break or not.
See you.
 
later!
 
And I'm in of here to check what's happening on CR today
or what's happening with @Mat'sMug
 
3:25 PM
0
Q: Coding novice in need of help coding html email for Outlook

Novice DeveloperBackground - I got my degree in video production but am currently in a marketing position that is heavy on email development. I taught myself basic code a long, long time ago, and have recently been trying to learn more advanced coding for my job. The problem - For some reason my boss expects...

0
Q: Rename file with ffmpeg

Marcello GalvãoI have a recording process in Task Scheduler , it's a file is " called " and some parameters are added . This " file named" has some command lonhas , but the main ( responsible for naming the file is this: C:\DATACLIP\SISTEMA\script\ffmpeg\ffmpeg\ffmpeg.exe -i %url% %ffmpeg_opt% -f segment -segm...

0
Q: Quadtree implementation

YannI've implemented a quadtree in c++. Ignore any apparent similarity to the pseudocode on wikipedia, it's all in your head, I swear. How can I improve? Algorithm speed/space improvements, any extra functions that I'm likely to want etc etc as well as general practice. #ifndef _QUADTREE_H_ #define...

 
or what's happening with @CaptainObvious...
This seems to be an explanation about why some people on SO don't downvote and VTC some CR-style question:
@SimonAndréForsberg This is not just some bulk custom code for review, but rather short snippet of code that can be useful to others too. — Dalija Prasnikar 5 mins ago
 
@DalijaPrasnikar for the record, Code Review has TONS of working implementations of various coding problems in many languages, that anyone can browse and find useful, too... who said CR is only useful for the asker? — Mat's Mug 30 secs ago
3
 
couldn't help
 
@Duga good job, @Mat'sMug.
Happy birthday, @Marc-Andre!
3
 
I dare say that we may have one of the biggest bases of small and functional working pieces of code in many languages.
3
 
3:36 PM
^^
 
@Morwenn +1
 
Suggestions to improve it?
I don't like the redundancies but any solution would just make the design unnecesarily convoluted
 
Use Boost.Fusion.
 
*cppadvice = null
 
3:39 PM
:D
 
@Mat'sMug What I meant to say is that while this code would also suitable for CR (even though it has bugs), it may be more visible here than there. — Dalija Prasnikar 2 mins ago
@Mat'sMug ^^ that I can agree with
We don't have many Delphi reviewers around here
especially not advanced ones. My Delphi is nowhere near as good
 
Thanks @SimonAndréForsberg!
 
OP created an account! missing 1 upvote to unlock upvpote priv: codereview.stackexchange.com/q/84366/23788
thanks!
 
4:00 PM
0
Q: Convert IP address to its binary representation

Chris CireficeFor a recent lab at the university we had to match the longest prefix for an IP (v4) address by using a Trie data structure. The code works fine, but it takes about 2 minutes to load a 14 million-line routing table. I examined what was causing the slowness, and it was the (String) IP to (String) ...

 
monking
 
monking!
 
Man it's been too long since I've been here
4
 
Hey :)
 
@Yann couldn't live without stars any longer?
 
4:10 PM
@SimonAndréForsberg I've been pining for a good star.
2
Better say something witty
@Morwenn Thanks for the review, it's great! I really do need to learn c++ 11/14
 
@Yann welcome back!
 
@Mat'sMug :D Don't be too welcoming, I'll start piling my c++98 on you all (apparently)
 
lol that's all right! (ignores c++ tag)
2
 
From seeing your code i believe you are able to do what you have asked. By you asking this questions it seems like you have not coded this yourself because it is very simple. i will rethink the language you are coding in, if i was you i will look at this link: codereview.stackexchange.com/questions/54636/… hopefully this link helps you but please rethink your language. — user3306763 1 min ago
 
@Yann No problem. Note that I did no more than a syntactic analyzer/code modernizer. I didn't even bother to understand what the code was actually doing x)
So you will probably want somebody else to perform a semantic review :p
 
4:15 PM
Does anyone know where I can find a (easy to read) list of things that 11 and 14 can do that I should be taking advantage of?
 
@Morwenn That's fine, I'm particularly excited about the for(auto&&...)
 
Well, the auto&& part is actually tricky and I didn't bother to explain it, but the for (... : ...) part is easy to grasp and to use :)
 
The auto keyword does scare and confuse me, and my first reaction tends to be to dig through and find the actual type
But hey, gotta learn
 
So, Wikipedia has a great summary of what changed in C++11. Now, you can read it and look for more in-depth articles on the internet when some features catches your interest.
 
4:19 PM
Yeah, I'll take some time to have a read through. Is there anything that makes templates less irritating to work with?
Ah, there is. Magical
 
0
Q: Structure and practises of library code in C

pyCtrl_Most of the C code I have written have never been seen by anybody else, and I wonder if my code follows normal practises, and especially how it performs security wise. The code is for a library I have made for working with strings, and is using in other programs. The full project can be found o...

0
Q: Simple mobile-first/responsive Grid System (w/ IE8 Support)

darcherMade my first grid system supported back to IE8 if respond.js is used (or another method such as modernizr, etc.) This was made really just for use in a project I'm working on, so it's not as robust as it could be, but figured I'd share it and see what others thought of it. It's also in a gist:...

0
Q: ViewModel creator design

janhartmannI am trying to move some logic outside my controller for creating my view models for the view. I have a lot of queries to fire to make sure the complete view model is ready, so to keep my controllers thin I came up with this design - any feedback, comments or suggestions are welcome! The inte...

 
4:39 PM
looks like the doughnut ate the monkey
 
@Mat'sMug Thanks, I want doughnuts now.
 
lol
 
Right, I'm orf, but I WILL BE BACK
 
See you later :)
 
later!
 
4:43 PM
At least, I'll get to eat some fromage blanc with red berries marmelade when I get home.
 
@Yann Hastalavista, baby.
 
@JeroenVannevel A couple suggestions.
First, you have this in both your if and else block:
> show.LastUpdatedOn = DateTime.UtcNow;
Would it be possible to move it outside the block, or is it required to run the next statement?
It looks like it might be required for the next statement:
> _context.Shows.Add(show);
> _context.Entry(localShow).CurrentValues.SetValues(show);
This can be moved outside the if/else block with a ternary:
> Console.WriteLine("Inserting movie \"{0}\" with TMDb ID {1}", movie.Title, movie.TmdbId);
> Console.WriteLine("{0} movie \"{1}\" with TMDb ID {2}", localMovie == null ? "Inserting" : "Updating", movie.Title, movie.TmdbId);
Not sure if that looks good, though.
Also, would it be possible to create a base class or something for these so you would only need one method?
There is a ton of duplication in there.
(Which, of course, you already know.)
 
Yep, good remarks. I'll put the update timestamp out of the loop and the writes go in a ternary
Not sure how you would use a single method for this though
 
Neither am I, but it is asking for one.
Maybe Jon Skeet knows (just kidding).
 
Code review questions belong over at codereview.stackexchange.comBrad 51 secs ago
 
5:02 PM
@Duga return eval(t); enough said.
 
He can move var q into a tighter scope too.
 
flagged for migration
If you know how to use jsfiddle, you should also know better than to use eval.
too bad that the question belongs on CR. I need more SO rep.
 
Working on a CR answer, and have a C# question.
Would you prefer this:
public override string ToString()
{
    switch (Denominator)
    {
        case 0:
            return "Undefined";
        case 1:
            return Numerator.ToString();
    }
    return string.Format("{0}/{1}", Numerator, Denominator);
}
Or, would you put that final return under default?
It works the same either way...
Not sure if I should mention this or not.
 
I would put it under default
can't explain why, but that's what I would do
 
OK.
I'm not sure what I would do yet, but I will mention it.
Hey, @Mat'sMug beat me to it.
 
5:11 PM
the Rational question?
:)
 
Yup.
Well, you missed one thing.
 
probably, I didn't dig too deep into the code
what did I miss?
 
@Hosch250 There's always room for another answer.
 
The missing braces.
Yep, I'm writing one.
 
5:17 PM
> I'd live with the non-enum switch in the name of premature optimisation
that's what it is, right?
"switch is faster than an if"
 
Named returns should normally be limited to helping make better/clearer godoc documentation or when you need to change return values in a deferred closure. Other than that they should be avoided. — Dave C 30 secs ago
 
OK, posted.
Not as good as yours, @Mat'sMug.
Lunch is on, BBL.
 
yeah TFL here too
@Hosch250 thanks! :)
 
If this is working code that you think could be improved, it might be a better fit for codereview.stackexchange.comjonrsharpe 1 min ago
 
Oooh, I mixed up Simplify and Reduce ...will revisit this answer — Mat's Mug 6 secs ago
 
5:22 PM
As Jon said, this should be on code review, but as a general hint: You have a lot of copy - pasted code... you use the same 10 lines over and over with just a few differences. So think about taking that block of code and moving it into a function, then create a loop to run that function with the necessary inputs. — Jkdc 1 min ago
 
5:34 PM
@BЈовић: If the programmer forgets to copy/paste then there will be no unit test and nobody will know if it's missed in a code review. That's the whole point. I'm looking for a way to ensure it's not missed. — John Dibling 1 min ago
 
Time for school, see you.
 
6:00 PM
Ello @all!
 
hey @syb0rg
 
0
Q: Perform a contains-ignore-case with multiple search-tokens

u6f6oI had a look on stackoverflow etc. how to perform a contains ignore case with 2 given strings. Most answers suggested using regex for this task. Although it's a valid option, I prefer doing upper-case for both strings and apply a .contains afterwards. The solution I came up with looks like this...

 
I need a Powershell script to recursively look through a directory and count the number of lines in every file with the .vb extension...
 
Get-ChildItem -recurse -Filter *.vb | Measure-Object -Line
 
That runs on working directory?
 
6:18 PM
yes
although it doesn't seem to work entirely
 
Definitely not. There's way more than 2644 lines...
 
It considers one file as one line
 
Yeah.
 
wouldn't you need to measure after calling Get-Content?
 
This question would be better posted on Code Review. — Tom Fenech 52 secs ago
 
6:23 PM
You're right
Get-ChildItem -recurse -Filter *.vb | Get-Content | Measure-Object -Line
This seems to work fine
 
1,702,589
 
@TomFenech This question is borderline for Code Review, because asking for code to be written is off-topic there. One could argue that roll4d6() is to be reviewed, with the roll5d6() being an illustration of the direction that the author wants to go, but that would be a creative interpretation. — 200_success 55 secs ago
 
If I knew assembly, I'd write a simple game involving zombies. Then, I'd post it for review with the title "Zombies in the Assembly line."
It probably would never become a zombie with that title, though.
I'm looking through some C code.
This looks terrible:
    if (string == NULL || table == NULL || deletechars == NULL) {
        goto error_exit;
    }

    if (strlen(string) == 0 || strlen(table) == 0 || strlen(deletechars) == 0) {
        goto error_exit;
    }

    if (strlen(table) != strlen(deletechars)) {
        goto error_exit;
    }
 
6:40 PM
1,702,589 lines of VB.NET code...
 
Should those if statements be merged?
 
No.
 
I think they should be, but then, they all test different, related problems.
OK.
 
Maybe merge the last two... But if any of that is null, you don't want to run the other stuff...
 
|| early exits, I believe.
 
6:42 PM
Don't guess.
 
I know it early exits in C++/C#/Java.
 
And given that it is different in every language, as written it is more clear.
Are you looking at code in one of those languages?
 
Yes, I see.
My C++ and Java books told me so, and I've tested C# code.
I fixed a crash in one of my Java programs by adjusting the order of conditions.
Probably a dumb idea, now that I think of it.
Or, I should at least put a comment in about the problem.
 
> That "processor" is actually a.. wait... an abstract factory.. factory.
 
Yes, || short-circuits in C#.
As does &&:
> except that if x is false, y is not evaluated, because the result of the AND operation is false no matter what the value of y is. This is known as "short-circuit" evaluation.
 
6:46 PM
@Hosch250 Ew
 
If you don't want to short-circuit, use & and |
 
@Hosch250 confusing. those are bitwise operators. If you don't want short-circuit, nest your conditions.
 
According to this, C short-circuits too:
@Mat'sMug Well, && is the same except it short-circuits.
Both my C++ and Java books say so, as well as MSDN.
 
still, non-short-circuiting conditions are clearer when they are nested IMO
 
I typically only use & when I am doing a calculation at the same time.
I've used it once/twice only.
 
6:50 PM
I agree 100% with nesting if you don't want it to short-circuit
 
0
Q: Am I correctly implementing PHP/PDO and the MVC/DAO pattern?

SandeepContext: I am working on the login module of a PHP web-application and I am trying to implement this using PHP/PDO and the DAO pattern. I would like someone to review the code below and let me know whether my understanding is correct or not,i.e, am I implementing it correctly. The application w...

 
that's how nasty bugs happen and accidental babies are born
 
DI / IoC is so much easier to do right... in other people's code
 
If I posted this in a code review, I wonder what would happen:
if (a & a = false) {}
I bet CR would explode ;)
 
A unicorn would die
 
6:55 PM
NP, they are extinct anyway.
 

« first day (683 days earlier)      last day (3335 days later) »