« first day (640 days earlier)      last day (1840 days later) » 

4:01 PM
Unless I just prefix all the files with a number~
 
0
Q: XML document parser with XPath

AntonHere is my simple implementation on XML parser for XML which I recive from server response. Also I've tried to use XmlPathDocument but falied to get child elements for node in XmlPathIterator. Thanks a lot for any advices for code improvement! public OutboxResponse CheckSendResponseForOutbox...

 
4:24 PM
0
Q: Correctly coding an OOP object - php

Pieter GoosenI have a couple of functions in Wordpress that I'm rewriting to OOP. All these functions are interlinked in some way and also reuse code from other functions. This is an example of the first class I'm trying. I'm very new to OOP, but I have learned about separation of concern, so basically each ...

 
Monking!
 
!Monking!
 
Morning.
 
Morning.
Expect a +5 about UTC midnight.
 
So...thinking I won't ever get when recursion would be useful. Seems like I'm forcing it just trying and I should just go back to avoiding it altogether.
 
4:37 PM
Backtracking.
Or look-ahead.
But yeah, you don't use it too often.
 
@Legato simplest use of recursion: recursive calculations
also DFS can be easily implemented recursively
 
I understand the concept, but it seems so far every case I think "oh it'd be useful here!" the non-recursive version is simply superior and in the few cases that that's not the case it's a marginal improvement still outweighed by the clarity of the iterative form.
DFS?
 
Depth First Search
 
There are times you should go recursive.
 
there are also times where you can't go iterative
 
4:41 PM
Write an N-Queens solver - you can't really go iterative.
 
well most backtracking things and often also pathfinding algorithms are implemented recursive
 
Exactly.
 
mostly because that saves you from maintaining the current path and dead ends in memory
 
I should write a recursive Fibonacci calculator quick after I get some school done.
 
Guess it's something that'll be more intuitive later on. I appreciate the input guys.
 
4:43 PM
the problem with that is how many stackframes you have
 
The main problem with recursion is that it usually overflows the stack when there is a problem.
 
and that minimal changes often can have unintended consequences down the stack
recursion is really hard
 
How do you feel about 1 liners? such as if (4 > n) { n = x; }
 
shoot it
 
I do oneliners when there is only one statement.
A lot of people here don't.
 
4:45 PM
oneliners are IMO close to obfuscation
what are you losing by having two more lines in your code?
shorter code often isn't more readable
 
You have a longer method.
Sometimes it overflows the screen.
 
I usually try to keep my methods to a maximum of 25 lines
including head and closing brace that is
 
But anything that does that should probably be split up.
I do too, and that is partly why a certain section of code is bugging me.
 
I'm voting to close this question as off-topic because it is asking for codereview. codereview.stackexchange.comFelix Kling 1 min ago
 
I'd rather go with what's considered 'best practice' or more readable. I thought there's no harm in it but @rolfl called my repeated use "disheartening." Didn't think it was that big a deal.
 
4:47 PM
I was already told to not do it the way I prefer and to do it this way.
 
@Legato well you were told before
it's not the use itself that's disheartening, but your continuous use after being told not to...
 
Ugh, why are you showing hidden characters?
I expect you'll have dots instead of spaces next.
 
because the formatting preferences of the guy I work with on that project
and because my formatter sometimes borks
which makes evil diffs
 
IntelliJ automatically collapses oneliner-code
 
@Legato That would actually look better as a ternary IMO.
 
4:49 PM
whole classes completely replaced without a single non-whitespace character edited...
@RubberDuck there is no second assignment...
 
But generally, ifs should be a min of two lines (with braces)
@Vogel612 Ahh you're right.
But ultimately @Legato consistency is King.
 
@RubberDuck What vogel said, but it's just meant to illustrate my using them if what's within the block is 1 statement/around that short. I'm definitely consistent about it, as you can see from rolfl's complaint, haha.
2
I'm going to avoid it though, I didn't really see the harm before but if it's approaching obfuscation I'd rather be consistent with the standard.
 
meh, that's mostly personal preference..
in general I'd prefer to have each instruction on a separate line
sometimes I don't do that for fluid API's or Streams, but I think it's a good thing
 
Do you split your for loops up?
 
?? split up?
 
4:55 PM
I thought it was simply personal preference too, but these reviews have been so helpful, don't really want to undermine the advice they contain. @Hosch250 who's that directed to?
 
for
(int i = 0;
i < 5;
i++)
It's for @Vogel612
 
eeek no
 
Approved. This is Code Review material. — Simon André Forsberg 59 secs ago
 
a for loop head is a single instruction for me
and I seldomly work with arrays so I often have enhanced for-loops
 
I see.
 
4:58 PM
That'd be so weird, have you ever seen that anywhere?
 
No.
Never.
I should ask about it on Programmers (would it be on topic?)
 
I doubt it.
 
Depends on your motivation for asking. I doubt it.
 
4 mins ago, by Vogel612
and I seldomly work with arrays so I often have enhanced for-loops
Enhanced for works on arrays too.
 
@Vogel612 I don't see why say eek...
 
5:03 PM
Horror.
 
@rolfl true, but I often have to use the index somewhere outside when I get arrays and then I can't use an enhanced for-loop :(
@Legato no... Disgust.
 
You sure you don't mean both? Disgusting and Horrific seem fairly fitting.
 
What if your loop statements are more complex?
A for loop is the only place we accept multiple statement per line mostly...
 
@Legato Horrific != Horrifying
@nhgrif then I prefer to get the complication to somewhere else...
 
Sometimes that's not always good.
 
5:08 PM
terminology is sometimes important....
a for loop is asingle statement with multiple clauses.
The initializer, the terminator, and the progressor.
 
@Vogel612 horrid, horrifying, horrible, horrific, all semantics really.
 
no...
 
Agree to disagree; save chat from the horrendous horrors that otherwise would follow.
3
 
Fun! Fun! Fun!
 
5:15 PM
How do you manage that many notifications?
 
Monking!
I am a bot, it is easy!
 
Hardly.
Oh, from all the times we ping @Duga?
You just ignore them?
 
exactly :)
 
you should see the mod and employee notification bars...
all the flags in one big red bubble.
 
0
Q: Best way to std::vector::push_back(new Object)?

Cole LawrenceIs this the best way to construct a vector of 2D points for return? std::vector<Point2D> results; results.reserve(max_results); ... Point2D* point = new Point2D(x, y); results.push_back(*point); delete point; It might be that I could do this without constructor. class Point2D { public: ...

 
5:43 PM
I think you've forgotten to post your code, regardless, if you already have working code and just want to get others to review it and give their opinion/how they'd do it, you'd probably be better off on codereview.stackexchange.comMLeFevre 24 secs ago
 
^^ true that.
 
1
Q: Wrapping WinAPI FindNextVolume as std iterator

Felix DombekThis is my first attempt at creating an STL-style iterator. Is this code ok? std::set<std::wstring> getVolumeNames() { class FindVolumeWrapper : public std::iterator<std::input_iterator_tag, std::wstring> { WCHAR m_curVolName[MAX_PATH]; HANDLE m_hFindVol; ...

 
If/When posting on Code Review, please include the code in the question itself - otherwwise it will be closed. — Simon André Forsberg 1 min ago
 
You've earned the "Good Question" badge (Question score of 25 or more) for "You are being watched! - Comments of Interest".
2
 
I took my first one two days ago (UTC time) on LOLCODE.
 
6:04 PM
0
Q: Refactoring the following methods to make it easier to read

methuselahWould it be possible to refactor the following methods? If so - how would I go about best doing it? public void PlotListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (PlotListView.SelectedItems.Count == 0) return; var selectedItem = (PlotCompone...

0
Q: Need help drying up some RAILS code

NiceZebraI feel like I've been writing some really ugly code in my app ihsb_goals = @patient_goals.where(service_code: 'ihsb') ihsb_goals.each {|g| Goal.decrypt g} personal_care_goals = @patient_goals.where(service_code: 'personal_care') personal_care_goals.each {|g| Goal.decrypt g} respit_goals = @pat...

 
@CaptainObvious Need help titling some RAILS question
 
0
Q: Approximately putting integers into buckets such that the sum of bucket differences is minimized

coderoddeI have the need for load balancing in my MSD-radix sort routine and doing it optimally is not an option. So I tried to play with two simple routines for putting integers into a prespecified amount of buckets such that the sums of buckets are "close" to each other. My main question is: Can you su...

 
Hello
 
Hello
 
@MannyMeng Hey there :)
 
6:15 PM
Hello
 
@Phrancis That was just supposed to be "Hello"
 
Trying a "Train" again?
 
Nah we don't need to make a train every time!
 
@SimonAndréForsberg Grats! Awesome quote btw. It sucked me right in.
 
That's what I thought
 
6:17 PM
@RubberDuck awesome TV-series btw ;)
 
@Duga What's it from?
 
Howdie :)
 
Hello.
 
@RubberDuck if you click the time link it takes you to the question/comment
looks like a SO question
 
6:19 PM
Asking for a refactor.
 
It is.
 
@DanLyons LOL. That was meant for @SimonAndréForsberg. Duga must have posted as I was replying...
 
Is a refactor a Code Review?
 
This would be a good fit for Code Review, indeed - I would recommend to add a bit more context to explain what the code is doing! — Phrancis 1 min ago
 
Yep
 
6:19 PM
yeah, for me it was the comment immediately before yours
 
What's the best thing to do for these, other than optionally adding a comment? Recently I have flagged for mod attention informing it would be better fit on CR, is this the correct method?
 
Hey, what do you guys think of adding a feed for newest questions on SO with the refactoring tag?
 
refactoring is the process where one tries to improve the internal structure, without altering the external behavior. Asking feedback on how to improve your internal code seems pretty suitable for CR imo.
 
Worthwhile? Yes? No? Shut up duck?
 
@RubberDuck Try Meta maybe?
 
6:22 PM
@Phrancis Maybe...
 
it would be even cooler if SO automatically redirected the question to CR when it has a refactoring tag :)
 
@DanLyons No automation in this case could quickly turn to hell
 
^^ Ditto
 
If people can tag a Java question with php or another language I would not trusted them to know when to tag refactoring and be on-topic for CR for an automatic migration
 
Please explain what the Pushy game is. Code reviews are done in the Code Review Stack ExchangeGilbert Le Blanc 1 min ago
 
6:25 PM
Hello @Zerotime
 
posted on February 03, 2015 by Veritas

I have an event manager that is implemented as a table of std::unique_ptr<CallbackWrapperBase> objects. Callables subscribe for specific events using the template <type EventType> void subscribe(std::function<void(const EventType&)>); templated functions. What I want to do is make the functions return handles so that I can unsubscribe cal

 
Please note that if you post a question on Code Review, it must have the code embedded (rather than paste bin) and it must function as intended. — RubberDuck 23 secs ago
This code appears not to work as intended, and would therefore be off-topic for Code Review. — Phrancis 56 secs ago
 
@SimonAndréForsberg @Duga post comments on newer first order ?
 
@RubberDuck It is from the TV Series "Person of Interest". Me, Monkey and Mr. Scala are fans of the show.
 
@SimonAndréForsberg Thanks. I'll check it out.. Sounds interesting.
 
6:29 PM
@Marc-Andre hmm... apparently yes, never thought of that. Good catch.
 
Interesting Characters.
As my family would call them.
 
"I think it looks hack-ish and I was wondering if there is any pattern/idiom in order to properly deal with this issue." That doesn't look like a question that's really appropriate for SO. You might better try asking on SE CodeReview. — πάντα ῥεῖ 1 min ago
 
@RubberDuck I am not sure about adding that feed, in a way it feels like we have gotten more on our hands already. It is an interesting idea though and could be worth testing, but perhaps not start it in the 2nd monitor. I have a feeling that many SO "refactoring" questions are about hypothetical code.
 
I should write an answer here telling him to use braces around his loop statement:
97
Q: Calculating entropy of a string

Jeff AtwoodWe're calculating entropy of a string a few places in Stack Overflow as a signifier of low quality. I whipped up this simple method which counts unique characters in a string, but it is quite literally the first thing that popped into my head. It's the "dumbest thing that works". /// <summary> ...

 
That's really cool @DanLyons thank you.
@SimonAndréForsberg That's why I asked. I haven't looked at the questions yet.
@DanLyons if you don't mind me asking, just what is the difference between a "get-only" auto-property and a get; private set;. As cool as that is, I'm not sure I understand the subtlety here.
 
6:37 PM
the get-only auto property behaves the same as a read-only field
you can only set it in the constructor or in-line
 
I wonder how long it takes before Stack Overflow users realize that they're being watched...
 
I was wondering that too @Simon. It's a big site. They may never.
 
@rolfl The SO moderators knows about @Duga's recent assignment, right? Any words from them?
 
Mods might catch on though.
 
Hmm, right... perhaps the mods don't know about it yet.
 
6:39 PM
You may consider codereview.stackexchange.com if you are looking for a review of given code. — Stephen Reindl 1 min ago
 
-9
Q: Feature Request: Starring system that isnt easily abused

VirusboyThe whole point of starring in chat was to mark either statements you liked or something good or amusing that also held a significant importance. Lately I have noticed that multiple users, currently unknown, star either statements that have no need to be starred, or blocks of statements. Exampl...

 
Could the mods do anything about it really?
Other than request we stop?
Also, wouldn't they like the help?
 
I don't really expect them to request us to stop. I hope that they appreciate what wwe are doing
 
nope you made it as short as humanly possible... maybe the nice folks over at codereview.stackexchange.com can provide further assistance — Joran Beasley 8 secs ago
@StephenReindl This is about "translating" the current code from 2.0 to 1.0 which does not belong on Code Review — Simon André Forsberg 1 min ago
 
Isn't it called "porting"?
Or is that something else?
 
6:47 PM
Thanks. I've nominated for re-opening. — RubberDuck 2 mins ago
 
@SimonAndréForsberg If someone would save me the trouble of dealing with question.. I would appreciate it. SO mods have a ton of work to do, if user step in and help, I'm sure they will be happy
 
@Marc-Andre Except for the part where maybe more questions end up getting flagged for migration in the long run.
 
It would be beneficial to explain in more detail what the purpose of the code is (whether it stays here or comes to Code Review). — RubberDuck 46 secs ago
 
@RubberDuck Good point. But at least those flags will be good flags since they are issued by user of the target site
 
Very true. Very true.
 
6:51 PM
Just as a side code review, there is no need for == true. Just do if(isValidRank(Rank))Ascalonian 1 min ago
 
Defending the stars:
0
A: Feature Request: Starring system that isnt easily abused

Simon André Forsberg A mechanic to chat ban for starring things so often. Use too many in a day, get banned for additional day. There is already a limit for starring things. You can use up to 20 stars per day, per room. The discussion about stars came up recently during Winterbash when there was a hat for starr...

 
Should I flag the question as offensive?
JK.
But really...
 
but to most of us it removes the point of having it in the first place I don't like when people include a majority without the majority knowing it.
 
I'd downvote that question, but I don't have 125 rep on meta.
 
I downvoted.
 
7:01 PM
I'm not sure what your question is. Your code is quite odd; this looks like it was better asked at Code Review. — Bergi just now
 
@Donald.McLean then answer it and get 125 rep on meta :)
 
@SimonAndréForsberg Could I flag it as "primarily opinion based?
 
@Hosch250 that's what meta is for, is it not?
 
Then why is there a flag reason for that?
 
I'm voting to close this question as off-topic because it is more on-topic at Code Review Stack Exchange, with some more detail added to help. — Andrew Barber ♦ 53 secs ago
 
7:09 PM
@Hosch250 good question
 
7:20 PM
0
Q: Greatest Common Divisor

Vinayak AgarwalWith reference to thishttp://www.spoj.com/problems/GAMES/, I made a program: #include<iostream> using namespace std; long gcd(long p,long q){ return p == 0 ? q : gcd(q%p , p); } int main(){ double a; int t,b=10000; cin>>t; while(t--){ cin>>a; //cout<<gcd(b,(long)(a*b))<<'\n';//To ...

 
@SimonAndréForsberg There - my first answer on meta.
 
> Let's focus on issues that really matter.
4
All hail The User.
2
 
@Donald.McLean You can now downvote.
2
 
@SimonAndréForsberg I was indirectly mentioned on a popular Meta Answer!!!!
 
Nice, @Donald.McLean!
 
7:35 PM
@Duga was this automatic?
 
Yup.
 
wow I haven't been mute slapped for my use of stars yet....lol
2
 
You have 20 stars per day. According to economics, you should spend all 20 stars so you get the most value possible per day. I don't spend all 20 stars each day, bu I have no problem with someone who does. — Hosch250 18 mins ago
2
 
26
Q: You are being watched! - Comments of Interest

Simon André Forsberg You are being watched Code Review has an open system A machine that spies on you on every hour of every day I know because I built it. I designed the machine to detect suggestions to post on Code Review but it sees everything Horrible comments involving ordinary users Users like yo...

 
@Hosch250 That makes me happy, because.... well... I run out of stars on the regular.
 
7:40 PM
I should write an answer stating "Freedom of Speech"
 
s/Speech/Stars/
 
@SimonAndréForsberg nice
 
0
A: Feature Request: Starring system that isnt easily abused

Hosch250Three words: "Freedom of Expression."

 
0
Q: Truncate 160-bit output from SHA-1 to 64-bit uint64_t

DruxI'd like to truncate 160-bit output from SHA-1 to receive a (weaker) 64-bit digest. It has been a while since I did the type of low-level C pointer arithmetic in the but-last line. Could you please double-check it for me. It should return the last 64 bits of the the byte array in a uint64_t. (I...

 
To show there is a point of over doing it. And to by example not get stupid with it. — Virusboy 47 mins ago
@Virusboy that doesn't even make sense. — Malachi 27 secs ago
in Mos Eisley, 24 secs ago, by Richard
If there's anyone lurking that hasn't voted yet, you've got 15 minutes remaining
 
7:44 PM
Well, obviously someone else didn't like my answer - I got two downvotes, not just one.
 
@Donald.McLean is running for President Moderator on SciFi!
vote for Don and Dick Richard
 
I don't have an account to vote.
 
@SimonAndréForsberg Yes, they do.
 
you have to have 150 rep I think as well...
 
There are basically only two sites where I'm active enough to feel I could legitimately run for mod - here and SF.
 
7:46 PM
@rolfl good good
@Donald.McLean What about Astronomy where you are already a mod?
 
@Donald.McLean What about astronomy?
 
oh wait, beta site.
 
that.
 
Well, in seven or eight years, when Astronomy graduates, I'll give it some serious consideration.
5
 
Any of them could make a good mod except for scifi.stackexchange.com/users/10746/arvin-g-borkar
 
7:55 PM
@Donald.McLean that's when I wish light years were a measure of time ;)
 
Who won?
 
I'm a loser.
 
I can't see.
It just has the raw data and a link to download malware something.
 
> Richard and Thaddeus
 
OK.
 
8:06 PM
(the election voting results are available here: scifi.stackexchange.com/election/download-result/3) and I ran them through the engine.
Note that the results are unofficial, etc.
I get the following:
Counting votes for Science Fiction & Fantasy Stack Exchange Moderator Election 2015 using Meek STV.
8 candidates running for 2 seats.

 R|Richard        |Thaddeus       |phantom42      |alexwlchan     |Donald.McLean  |SSumner
  |---------------+---------------+---------------+---------------+---------------+---------------
  |Jack B Nimble  |Arvin G Borkar |Exhausted      |Surplus        |Threshold
==================================================================================================
 
OK.
Apparently Sci-Fi has a version of JD.
The name is Rondo, and they are obsessed with time-traveling robots.
 
Marvin.
 
Only, they are usually off-topic.
 
in Duga's Playground, 5 mins ago, by Duga
2015-02-03T20:08:01.235Z Quota has been reset. Was 9274 is now 9999
 
BBL.
 
8:13 PM
seems like for @Duga, the quota is reset shortly after 20:05 UTC
I still have 9000 API requests available per day that I am not using though
 
@SimonAndréForsberg You should never clear @Duga's inbox and see when the number overflows to 0.
 
@Hosch250 I think it wwill overflow to -2147483648 first
 
Feature request: have @Duga post the number of inbox notifications in its account at reload! :)
...or not
 
LOL.
Or not.
I never thought about this before, but it makes sense.
7
Q: some bounty reason options make no sense when starting a bounty on a question with no answers

berry120It strikes me that the most popular reason for starting a bounty on a question is because the question hasn't received any answers thus far. However, when starting a bounty, whether there are any answers or not, it still presents you with the full array of reasons for starting the bounty. Three ...

 
8:31 PM
@Mat'sMug would have to retrieve them first, no idea how I do that :)
 
-1
Q: What is a more descriptive word for Create and Send in method/function name?

javaPlease42I need a more descriptive word to improve readability which tells the reader that this method/function creates and sends the message. Right now I am just saying sendMessage. Is there anything better that other coders would know that this method/function not only sends but also creates the message...

 
Thanks Joran for suggesting codereview hope in future I will discuss there. Now the suggestions are really helped me to make the code very short. Thanks to all especially Garrett, I was planning to create separate file each category of result, because I have to append results running the code multiple time. But now I think this can be made in single file with proper documentation. Thanks for the suggestion of 'with' and new line. — user46242 1 min ago
 
@Donald.McLean In astronomical terms, seven or eight years is nothing.
 
8:58 PM
@SimonAndréForsberg the 'hot network questions' widget on my phone is showing your comments of interest post :)
 
@Mat'sMug that explains the 1055 views and 28 upvotes :)
I checked this morning and then it was on page 2 on stackexchange.com
I wwwwonder how many of the viewers are POI fans :)
3
4 w's? really?
 
9:11 PM
@200_success Only if you're an astronomical body. For better or worse, I'm just a human. A weird human, but human none-the-less.
 
greetings, humans, even if weird
4
 
Tip: when replying to commenters on SO, refer to Code Review as "CR" - Duga won't post your reply here :)
 
Are you having any problems with the code, or do you just want it reviewed? There is a Code Review Stack Exchange if you aren't asking about a specific problem. — yellowantphil 35 secs ago
 
9:29 PM
1
Q: pros and cons of static vs inherited method for small framework

Jose MartinezWe are working on an application that executes requests for Amazon SWF Workflow's. Workflow is an annotation and you construct your own MyWorkflow interface (that is annotated with Workflow), and then a MyWorkflowImpl that implements the workflow code. In SWF the WorkflowImpl is executed on som...

 
Looks like this question is better placed at SE CodeReviewπάντα ῥεῖ 1 min ago
@πάνταῥεῖ No. CodeReview deals only with the working code. Hypothetical and stub code is explicitly against the chapter. — user58697 30 secs ago
2
If you are quite confident that your code works, this sounds like it can be posted on Code Review — Simon André Forsberg 54 secs ago
 
@Duga THERE IS HOPE!!
2
Greetings, @janos
 
hey @Simon
 
0
Q: Removing via a break statement and a for loop or a while and a flag?

committedandroiderI am implementing an set, using an array as the backend. Here is how i declared it public class Set { private int[] elementData; private int size; .... public void remove(int value){ .. } } I have a question about co...

 
@CaptainObvious This question doesn't feel right, but I can't quite put my finger on why I feel that way...
 
9:44 PM
0
Q: How to execute the url from shell script and verify the conditions on the data?

davidI am working on a project in which I need to make a url call to one of my server from the bash shell script.. http://hostname.domain.com:8080/beat After hitting the above url, I will be getting the below response which I need to parse it and extract value of state from it num_retries_allowed...

0
Q: Multiply using statements in method, is it correct?

Thomas MullerI'm learning WebAPI framework from ASP.NET family and also C#. I wonder, is the next way of handling incoming data correct? [HttpPost] [ExpiredCookieCheck] public IHttpActionResult Auth([FromBody]AuthenticationData authenticationData) { try { if (authe...

 
I bet this confused Robert a bit:
in The Whiteboard, 2 mins ago, by Duga
@RobertHarvey Thank you, you are awesome too!
 
meh....
 
@rolfl posted in wwrong room?
 
shhhhh
 
in The Whiteboard, 46 mins ago, by Robert Harvey
So wait, teh Duga finds comments that mention Programmers, and posts them here automatically? Genius.
 
9:51 PM
0
Q: Is there some way of taking advantage of code reuse in this example?

committedandroiderI am implementing an set, using an array as the backend. Here is how i declared it(and some method implementations) public class Set { private int[] elementData; private int size; .... public void remove(int value) { for(int count = ...

 
in The Whiteboard, 57 mins ago, by Jimmy Hoffa
This doodad is great.
I found Jimmy Hoffa!
He's hiding in The Whiteboard!
 
Call the FBI.
2
 
Shit, my mailbox just exploded.
Luckily it's the virtual one, and not the real one.
 
Speaking of calling the FBI....
 
No need to call the NSA, they're listening anyway?
2
 
10:01 PM
2
Q: Truncate 160-bit output from SHA-1 to 64-bit uint64_t

DruxI'd like to truncate 160-bit output from SHA-1 to receive a (weaker) 64-bit digest. It has been a while since I did the type of low-level C pointer arithmetic in the but-last line. Could you please review it for me? It should return the last 64 bits of the the byte array in a uint64_t. (I guess...

 
Funny story, I have a process called CIA.
2
 
Does that question need both code snippets...?
 
Yes, it's because I like acronyms and bad puns.
@nhgrif IDK, but I find it confusing and worth a DV.
You hate , I hate ..... =;)-
 
hey @nhgrif! regarding the NSDictionary implementation of my code, the problem boiled down to this. It was easy to make the DMMatch a key for the dictionary by adding the <NSCopying> delegate, but the problem came about when I wanted to retrieve the key when I had the value. There is [dictionary allKeysForObject], but apparently that calls isEqual on every object in the dictionary. This was somewhat tolerable, but the isEqual checks were sometimes failing when they should be passing.
 
@rolfl You are being watched!
 
10:04 PM
CoreCLR is now open source, being ported to linux/os x! blogs.msdn.com/b/dotnet/archive/2015/02/03/…
 
@bazola should it be a 1-to-1 mapping of keys and values?
 
overriding isEqual on the class that was the value in the dictionary worked as a temporary workaround, but I needed some inefficient code in that isEqual to force it to work
it is 1:1 yeah
 
Then you need a bidirectional dictionary
 
@nhgrif not something in the apple libraries I'm guessing?
 
I should be out of stars here soon if not already...lol
 
10:05 PM
No.
 
> coreclr repo has ~ 2.6M lines of code.
 
I've implemented one in Swift though.
Perhaps I'll write an Objective-C version and post it for review.
 
it seems to me way more efficient to just use an essentially plain old data object, partly because I can use a property on that object to sort the resulting array however I need
 
I haven't fully wrapped my head around all of what you're trying to do, but a good bidirectional dictionary is quite efficient.
 
briefly I did use two mutable arrays to fake the same effect, but that was a bit ugly
i would be interested to see your take in objective-c if you get around to implementing it and posting it
what I'm trying to do is pretty simple. Look at all possible combinations of two tiles on the bejeweled board, create the board for each combination, score it, and choose the best one
 
10:09 PM
In the simplest possible terms: you're trying to find the hint move?
 
it could be used for that, but instead it is being used to choose the best move for the AI player
 
Oh.
AI always plays best move?
 
its the same thing though really, it could also be used to shuffle the board if no matches were possible
there are different AI levels, so one of them simply chooses the first move that results in a match, and then the main one chooses the best move
 
@RubberDuck So you are the person running the nation?
 
this sounds like something a bunch of you here can answer ▼▼▼▼
8
Q: How do I encourage a new user to participate in the site while critiquing their first few posts?

DomI have seen this scenario play out a few times where a new user kind of understand the idea and wants to participate, but doesn't understand/hasn't read the rules of the site yet. Because of this and their desire to participate they post a lot in a short period. While some of their posts are fi...

 
10:15 PM
@nhgrif anyway, I ran instruments as you suggested, and the greediest method in my code is the one that I posted about here (matchesForOrbs:)
4
Q: Unit Testing Bejeweled Wilds

bazolaI created a pretty complex algorithm for calculating matches on a Bejeweled board that kept track of matches involving wilds. After doing some in-game testing, I found quite a few bugs that needed to be eliminated. In order to deal with this problem, I first created an undo system for the gam...

 
Is it taking a lot of time per run, or is it also because it's called tons of times?
Could you potentially solve the problem with multithreading?
 
well, its taking about 3% of the execution time, but I'm pretty sure it is being called a lot
that method is not actually the real problem though. The problem is that the bestMatch method in my latest question takes about a second to execute once called. I am already placing it on another thread, and that's fine as far as not blocking the AI, but it definitely means that I can't improve the AI any further as the player already has to wait a second for the move to compute
 
wow, +180 today... I wonder if @Santa is around...
 
I'm writing a bididict write now.
 
I'm almost out.
I think I'll save it for about an hour, but I'll remember if I have some later.
 
10:29 PM
@Hosch250 no. Just the "Cycle Item Activity" =;)-
 
IC
 
(wrong room)
 
Still funny.
 
Thanks @Santa!
 
Now no more voting on @Mat'sMug today.
 
10:38 PM
Morning Santa
 
Morning.
 
I repcapped today without even trying
5
 
I had to ask for 25 yesterday.
Modem going down in a sec.
BBL.
 
Huh, got logged out.
 
Oh great, now @Duga will get pinged from The Whiteboard as well!
perhaps I will manage to get an overflow after all
 
10:52 PM
Oh, @SimonAndréForsberg, it depends on whether SE uses a signed int (or long) or not.
On whether you get a negative overflow, that is.
Rumor has it that Jon Skeet has overflowed three times!
 

« first day (640 days earlier)      last day (1840 days later) »