« first day (865 days earlier)      last day (3158 days later) » 

3:00 PM
possible answer invalidation by Orace on question by Orace: codereview.stackexchange.com/posts/104811/revisions
 
@Duga thats ok
 
the question is closed though
 
@Caridorc OP edited their actual code into the question. how do you want to handle this?
 
0
Q: Clean regex matches with named matches

Heru-LuinI have a regex pattern that will match some elements from a string and give them a particular name. For example #^(?<foo>.*)^# will match the whole string and name it foo. My problem is that the matches also contain the "classic", numbered matches. For example : $pattern = '#^(?<foo>.*)^#...

 
IMO your answer should have been a comment from the start
...
so.. I converted it to a comment, ...that's now obsolete, so I removed it.
and now we have a clean, on-topic question
 
3:12 PM
If you have working code and just want it reviewed then Code Review might be a better site to post on. — juharr 16 secs ago
I'd recommend posting the entire method if you're interested in a peer review. One-liners aren't the greatest questions on Code Review. — Mat's Mug 30 secs ago
 
0
Q: Hashing passwords in php

Sam SwiftWhen hashing a password, I understand it is best not to use functions such as sha1 or md5, this is why I came up with this: class safePassword { public static function makeSafe($password) { $salt = "mySalt"; $hash = hash("sha256", $salt.".".$password); return $has...

0
Q: binary number printing series

user84639want to print 1 2 3 4 5 as a binary number class binary { public static void main(String args[]) { for(int i=1;i<=5;i++) { int k; for(int j=i;j>0;j--) { k=j%2; System.out....

 
Thanks, @Quill - Guess I will throw away my salty answer.
 
Feel free to post, It was a short answer
I'm sure some handdrawn circles and funny puns could get the accept pretty easily
 
Not much value-add... huh?
 
meh, it was a short question
salt the salt, if you're feeling salty
 
3:25 PM
And I am surprised your answer still only has my +1
1
A: Hashing passwords in php

QuillThere's two sides to this review: Security & Style. Style: Directly return $hash instead of assigning it. The string concatenation can be improved into: public static function makeSafe($password) { $salt = "mySalt"; return hash("sha256", "{$salt}.{$password}"); } Security: W...

 
I just posted it
 
> If this is the kind of answer you're looking for, you need to try Code Review.
 
Thanks for pimping it though
 
@rolfl @Quill +1
 
yw
 
3:29 PM
Thank you. i have posted my code in code review. — Mukil Deepthi just now
 
ah, beautiful!
 
MathJax just destroys chat sometimes ^^
 
I love editing MathJax into questions
 
Me too
It makes everything look so pretty and shiny and cool
 
until you view it on mobile
but yeah
 
3:34 PM
Mobile... is... meh.
Just shove mobile into a corner and forget about it.
 
Zak
Mobile is just a pain to develop for.
 
I write all my calculus assignments on stackedit.io mainly because of MathJax, but also for Markdown
 
Nice
I love StackEdit.
 
@rolfl how.... how can you see that without mod glasses on?!
 
3:36 PM
@Mat'sMug Sequential userid's
 
oh wow
 
(experience too)
 
@Mat'sMug magic
 
ouch @Jamal edit rolledback on the PHP hashing q
 
We should keep an eye on that.
Just so we don't get an edit war.
 
3:39 PM
Roslyn is just - wow.
I can find everything - except what I'm looking for, which lives in a generated file.
 
@Hosch250 still getting VS hanging often?
 
@Quill Not so much, now that the caches are built.
I found the xml file that generates the generated file, but the buggy part appears to be generated from thin air.
 
@Quill And he rolled back his other question.
 
Can a mod please edit my message here? The lack of a question mark is really bothering me.
 
3:42 PM
hehehe .... mods rewrite history ....
3
 
Thanks
 
6
Q: Parsing pipe delimited lines

Mukil DeepthiI am parsing the following line of code via a specific format. Line is: S|111111|87654321|Bar UK|BCreace UK|GBP|24/08/2010| The Format is: Index Field Length S0 - 1 S1 - 6 S2 - 34 .... ... S6 - 10 I am validating using many if statements. Could anyo...

0
Q: Different data sources for UnitOfWork and Repository patterns + refactoring and suggestions

Jevgenij NekrasovI was involved in some code-review discussions about UnitOfWork and Repository pattern implementation with EF, which put me in some sort of confusion. Yes, I know that EF already implements UnitOfWork and Repository pattern, but the question is not about that. I am just asking for your opinion r...

 
What...
Why is @Mat'sMug's profile picture all faded?
 
he made an edit, but hasn't posted, probably
 
that ^^^
 
3:43 PM
magic is complex
 
a loophole in time and space
2
 
probably a bug in the chat system... but low priority
 
@CaptainObvious all yours. I'm not touching that one with a stick!
dynamic Repository<TEntityType>() where TEntityType : BaseEntity;
 
When on Earth do you need destructors in C#?
 
when you destroy objects
 
3:46 PM
@EthanBierlein when you don't know what you're doing.
 
Go figure
 
@EthanBierlein If you encapsulate a non-managed object, stuff like that I guess
 
^^
 
Destructors are defaulted in the Object class, unless you need to do something when the object is destroyed you don't need to mess with overriding it
 
@EthanBierlein when for some reason you can't release a resource using the dispose pattern that we've come to know and love
 
3:46 PM
You shouldn't really be using non-managed objects in C# anyways, I presume.
 
    ~object()
    {
        //byebye
    }
 
defaulted is not the right word
 
the biggest problem with destructors in c# is they aren't deterministic so you can't really rely on them
 
@EthanBierlein that REALLY depends on what you're doing. If you're writing a COM add-in for the VBE for example...
 
@EthanBierlein It depends, sometimes you don't have the choice
 
3:48 PM
106
A: When should I create a destructor?

Eric Lippert When should I manually create a destructor? Almost never. Typically one only creates a destructor when your class is holding on to some expensive unmanaged resource that must be cleaned up when the object goes away. It is better to use the disposable pattern to ensure that the resource is...

TLDR
> A destructor is then essentially an assurance that if the consumer of your object forgets to dispose it, the resource still gets cleaned up eventually. (Maybe.)
 
@ARedHerring dang, you beat me to it!
81
Q: When should I create a destructor?

deleteFor example: public class Person { public Person() { } ~Person() { } } When should I manually create a destructor? When have you needed to create a destructor?

 
mr lippert strikes again
2
 
The tldr tldr is "If you have to ask the question, don't"
It's like asking "how do I make an MMO"
 
3:50 PM
Because if you ever ask that question, you shouldn't be making an MMO.
 
@Mat'sMug this is an exception because it uses, well, as you said, non-managed resources (ie IntPtr)
 
@Quill He probably wrote it
 
I wanted to show an example where a destructor is actually warranted ;-)
 
"Based on a content scan of this URL, it is suspected this site may contain offensive material."
:24121544
 
3:51 PM
@Mat'sMug rename it to rubbercop? :)
 
(and for the record, I didn't write that code)
 
this firewall really takes the piss
 
@Malachi write the compiler, write the related SO post. best of both worlds
 
@JohanLarsson crap, now what to do with these 500 t-shirts and mugs...
(joke)
 
@Mat'sMug I guess you could call it... a rubber cop out
 
3:52 PM
 
alright. Markdown isn't working for me today. or I'm doing it wrong. i quit.
 
@EBrown what do you mean, you can't?
 
missing one space after ---
 
@ARedHerring its the cop part of the message, also, chatroom markdown is a tad different
 
@Mat'sMug Converters are strongly typed.
 
3:53 PM
@Mat'sMug idiomatic and xaml. pick one
 
The only way to use the same converter on multiple objects, is to write it such that it uses an interface instead of a class.
But, you have to make sure all classes you wish to convert inherit (and obviously implement) that interface.
 
so this part is correct?
DataType="{x:Type CollectionViewGroup}"
 
Mat'sMug I saw your SO question, it was so huge, I closed the tab.
 
:(
 
@Mat'sMug I can't see anything wrong with it.
 
3:55 PM
did you at least hit the upvote?
 
You're only real solution here is to use a common interface for all of them.
 
I tend to glance the scrollbar when browsing, if it signals hugeness it triggers flight
 
I would implement a generic interface.
And then on that interface use T to represent the type of name.
Of course, this leaves issues of how to use that interface to for type converting, because the type converting method would need to know what T is.
 
Thanks! I'll leave it up to the community to decide :-) — Mat's Mug ♦ 6 secs ago
 
Zak
3:58 PM
'nite everyone
see you tomorrow
 
bye
 
"night"? it's 5pm @Zak! cya tomorrow
 
@JohanLarsson the CR version will include moar XAML, and the ViewModel, and the converters, too...
'night @Zak!
 
@Mat'sMug (I'll not bother posting it as an answer.)
 
@Mat'sMug he didn't seem to actually add the missing exception handling (unless he, of course, doesn't have any); he just removed the arabic comment
 
3:59 PM
@Mat'sMug I read some CR today, first time reading CR really, many questions are like that. shrug
 
see youg uys when i get home
AFK
 
Actually, I'll bother posting it as an answer.
(Need the rep.)
 
@EBrown so, that treeview is as idiomatic as it gets then?
 
@Mat'sMug Yeah.
 
as in, that's how it's done
 
4:01 PM
Got into a small ~fight~ in comments which was good, learned a thing.
 
@Mat'sMug Yep. TreeView is a pita.
 
well, I don't even want to think of how I'd have implemented that one in
 
I once wrote a classic style for treeview, got pretty big
with + buttons and lines
prolly did it in a dumb way
 
@Mat'sMug What does one of the Converter implementations look like?
 
@EBrown could have been written by a 8-year-old
 
4:04 PM
@Mat'sMug Still need to see what it looks like.
 
There's a reason you have the value as an object.
@Mat'sMug O.o
The only way to improve that, is to write one converter and, based on type, get the value you need.
 
next thing I'm implementing for it: stackoverflow.com/q/5047576/1188513
 
Or, like I said, make a common interface.
(Which is what I would do because XAML is a b.)
 
feels like I'm a little bit monopolizing The 2nd Monitor
 
4:08 PM
            s.Draw(Texture,
                new Microsoft.Xna.Framework.Rectangle((int)Position.X,
                    (int)Position.Y,
                    Size.Width,
                    Size.Height),
                new Microsoft.Xna.Framework.Rectangle((xSource * Size.Width),
                    0,
                    Size.Width,
                    Size.Height),
                Microsoft.Xna.Framework.Color.White,
                0,
                new Microsoft.Xna.Framework.Vector2(0, 0),
So much horribleness.
 
too much cramming-into-single-instruction
 
@Mat'sMug How much rent do I have to pay for landing on your Mayfair property, kind sir?
 
Free Parking
 
That game really does ruin friendships
 
Is there enough free parking to land my Antonov An-225?
Or is it just gonna destroy everything?
 
4:12 PM
You'll just go straight to jail for doing that :P
 
if the tip touches GoTo Jail, ...
 
Well, I guess I'm gonna have to pull up now.
 
0
Q: Replacement string Base64 (and a Base32) conversion

EBrownSo, pretty self explanatory. This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ToBase32String (since .NET hasn't one). /// <summary> /// Provides extensions to convert certain objects to certain other objects. /// </summary>...

 
1
Q: Turning a 2D array into a tree

NitI have the following data structure that's obtained from a third party: var data = [ ["Parent1", "Parent1.1", "Parent1.1.1"], ["Parent2", "Parent2.1", "Parent2.1.1"], ["Parent3", "Parent3.1", "Parent3.1.1"], ["Parent1", "Parent1.2", "Parent1.2.1"], ["Parent1", "Parent1.2", "P...

1
Q: Android Network Job Queue

Thomas NairnI've just finished working on a multi-threaded network queue and was wondering where I could improve, I'm a little rusty when it comes to waits and such. The idea is to queue up network actions whilst waiting for a form of network internet connectivity. I also added the ability to prioritize whi...

0
Q: Replacement string Base64 (and a Base32) conversion

EBrownSo, pretty self explanatory. This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ToBase32String (since .NET hasn't one). /// <summary> /// Provides extensions to convert certain objects to certain other objects. /// </summary>...

 
Good lord
Slow down
 
4:15 PM
@CaptainObvious LOL Thanks.
 
^^
 
@Mat'sMug line 24, looks like it should be a static field.
 
@JohanLarsson damn, you're right!
 
Also templateselector is probably cleaner
 
never used that
 
4:16 PM
I'll write a small sample for you, hold on
why did you need groupings for the tree?
 
I love standards.
 
I never had that need.
 
because the source is just an ObservableCollection<ICodeInspectionResult> - I don't have a hierarchical data source, I'm making it ;-)
 
OH FFS ANOTHER MUTABLE STRUCT
2
 
those d**n mutable structs
 
4:21 PM
@EthanBierlein You're d**n right!
> Get these mutable structs out of here.
2
Commit message.
 
TBH, I don't really understand the difference between structs or classes.
 
@EthanBierlein O.o
 
At least in a language like C#
Is there a difference?
 
Structs are value types, allocated on the stack. Classes are reference types, allocated on the heap.
Structs (usually) perform better for smaller objects.
 
Is that the only difference?
 
4:25 PM
And cannot be nullable.
 
79
A: What is the difference between a reference type and value type in c#?

Jon SkeetYour examples are a little odd because while int, bool and float are specific types, interfaces and delegates are kinds of type - just like struct and enum are kinds of value types. I've written an explanation of reference types and value types in this article. I'd be happy to expand on any bits...

Skeet has an answer for that
 
Thanks Santa!
I like how all my enum values get longer the further down the list you get.
(At least in the RFC implementations.)
 
@EBrown It's not black and white like that
it also depends on whether they're inside a method and stuff
 
@JeroenVannevel No, I suppose it's not. I suppose if you want to be pedantic it depends.
In fact, if you want to actually note the differences, you would have several paragraphs on how that is not a black/white statement.
 
It's settled then: Jeroen is right
 
4:30 PM
@JeroenVannevel No, Jeroen is being a pedantic arse.
 
Smells like being right to me
 
:-D
 
0
Q: Memoized implementation of change-making algorithm

rookieRecently, I wrote a simple program to solve the change-making problem. Rather than the tabular dynamic programming solution (described in the link), I tried to write a solution that uses memoization. usd = [25, 10, 5, 1] def make_change(W, denoms=usd): """ Solves the change-making prob...

 
@JeroenVannevel VSDiagnostics should detect strings being appended to.
 
4:34 PM
Ah. Nevermind then.
 
Once StackMailer is done I'll get back to VSDiagnostics.
 
Anyway, bosses birthday lunchtime.
 
Patience. Only 5 more months until the next VSDiagnostics release
3
 
@EBrown cake
@JeroenVannevel 5 < 6~8, that's good
 
@JeroenVannevel how many downloads so far?
 
4:39 PM
@Mat here is a small sample using DataTemplateSelector.
 
@Mat'sMug Latest version? 26 for VSDiagnostics. Surprisingly, RoslynTester's latest has 253.
I guess utility packages are my speciality
 
Having properties for the templates lets you set things from xaml and avoid some string ugliness.
 
> Rubberduck.Setup.1.4.3.0.exe(4.32MB) - Downloaded 660 times.
Last updated on 2015-07-08
marketing dude, marketing ;-)
 
twitter and answers on SO help with that
 
uh-huh
 
4:42 PM
@Mat'sMug you can possibly save some pain doing that in the viewmodel
 
lol, this is the marketing I gave when someone asked me about it on reddit:
 
@Mat'sMug 6 more!
 
> No problem, I'm glad you're interested. It's still very much under active development and the next release should bring quite a few new things. Right now, however, it is rather unstable and I would advise against using it. We've seen it crash internally when applying it to a large codebase (but isolated code snippets work perfectly).
Until we figure out what causes the crashes exactly, it's not a useful product.
 
@JohanLarsson hmm interesting
@skiwi nah, 340 more ;-) ...which will probably be hit by the time 2.0 is ready to release
@JeroenVannevel release too early, apologize often
 
euhm, it's an alpha release
the users are my QA department
6
 
4:48 PM
there is a meme for that but you have already seen it
 
@JeroenVannevel crazy the things users do that you didn't even realize were possible huh?
 
@JeroenVannevel Sounds a lot like Ubisoft
 
In Mother Russia you don't test software. Software tests you.
6
 
that is a star imo
 
This is my type of construction work...
Moved beam by an angle of 10 degrees :D
 
4:57 PM
Yup. And I found a bug in Roslyn by working on VSDiagnostics.
We all test each other.
@Mat'sMug Where are all these Mother Russia posts stemming from?
 
@Mat'sMug Honestly we're working with offshore Russia devs at the moment and if this is the case it would really explain a lot
 
@Hosch250 I don't know
 
@Mat'sMug In Mother Russia, you don't use joke. Joke use you.
 
In Mother Russia, you don't review code. Code review you.
Also, when dealing with Jon Skeet's code. ^
 
Sounds like it originated here: knowyourmeme.com/memes/in-soviet-russia
 
5:06 PM
0
Q: Increase Graph Edge Weights

Temp IdGiven a directed acyclic graph with N nodes and M edges having positive weights, increase the edge weights of some edges such that the total weight (sum of edge weights on the route) of any route from 1 node to N node is same and minimum. Following are the constraints: The total weight of all t...

 
@CaptainObvious burn burn burn burn destroy
 
5:21 PM
Oh, um, I'm currently heading to the airport to get on a flight to go to Japan, so I may not be on very much in the next two weeks.
 
Have fun in Japan!
Maybe post some pictures, while your'e there?
 
Most certainly :-)
 
sayonara
 
this question can use an answer that addresses the actual validation logic :)
 
Worst work day ever. I messed up my SVN repo, had to re-download the 19Gb (NINETEEN!!!))) repo, now rebooted my comp because everything was weird, VS lost all its user settings, need to reinstall
Seems like someone doesn't want me to work today
 
5:34 PM
isn't this exactly why people git instead of svn? ;-)
 
@Mat'sMug get out of here with your logic!
:p
 
runs
 
you know macbooks or whatever they are? they have the ability to plug extra monitors in through hdmi slots.. right?
I have two monitors, want a mac, dont really want an iMac. dont want to code on a small screen all the time when im home though
 
@Mat'sMug My job is to choose code, not to read change mentalities
oh snap :(
Can anyone fix this mess, idk how.. lol
 
@TopinFrassi triple dash on each side of the word
 
5:36 PM
---strike---
 
(It was supposed to be a simpsons pun)
 
s/<strike>/---/ that ^^^
 
it's getting worst.. lol
 
Funny, my job is to code choose, not to change read mentalities.
I come to CR to get my code-itch scratched
sad but true
 
this reminds me of yesterday... we had to add password reset into our application
our technical lead suggested just emailing the user their password because passwords are encrypted
and said there are "many valid reasons as to why our passwords are encrypted"
...like.... what reasons, exactly?
 
5:40 PM
> emailing the user their password
== no password
 
That happens for many things, and in a properly configured system, is OK.
 
@Mat'sMug justification was "if we didn't email them their password, they would be resetting their password all day"
 
it's encrypted, except when sent over a plain text protocol
 
(not greeat, but OK).
 
@DanLyons and SMTP sends what exactly?
 
5:42 PM
@Mat'sMug that's what I was referring to :)
 
there's absolutely zero interprocess encryption
and the passwords have access to customer's sensitive details, depending on which password
 
@Hosch250 someone mentioned earlier I should go into managing for the higher pay. This is the exact reason I said I wouldnt do it
 
Interesting.
 
sucks that there is a glass ceiling but the moment I become a manager is the moment I stop enjoying my job in the slightest
 
5:44 PM
@Hosch250 Yeah, I resemble that.
My particular situation is that someone has to build the system I want to play with, and, since I want it built right, I can't think of anyone else I would want to do the building part.
If I do the crap admin work for a few more months, perhaps I will have a toy I can play with ;-)
 
@ARedHerring not every place does that - some have tracks for people to continue developing
 
@DanLyons I would hope so
but it doesn't sit well for me to be bossing people around or managing projects. :)
 
Dream title: "senior software evangelist"
Translation: tinker around and tell people about the awesome stuff you made
4
 
@JeroenVannevel But then you wouldn't be building awesome stuff anymore.
 
5:59 PM
@JeroenVannevel I don't use it, but I thought I'd try giving you some ideas anyway.
 
@EBrown That's okay, I appreciate it.
 

« first day (865 days earlier)      last day (3158 days later) »