« first day (689 days earlier)      last day (3330 days later) » 

12:00 AM
There are 1233 unanswered questions
 
12:21 AM
0
Q: Genetic algorithm in R - help in looping

Rcode_beginnerI have to implement genetic algoritm in R to optimize minimum of schaffer function. Below I describe each step and I need to create one big function and another loops for 100 iterations (and from 100 iterations choose the best solution) for schaffer function. I would be grateful for any tips, whe...

 
@CaptainObvious The <- operator ... ... what is that?
 
looks like assignment
a = b
a <- b
 
Ah, I guess it makes sense visually
two <- 1 + 1
 
I thought that there might be a different between = and <- where one was declaration and the other was definition.
 
that might actually be true
 
12:30 AM
According to R's wiki, "In R, the widely preferred assignment operator is an arrow made from two characters <-, although = can be used instead"
 
I'm voting to close this question as off-topic because it should probably be on codereview.stackexchange, since you're asking for generic advice rather than trying to solve a specific problem, — Javier 1 min ago
 
that R question looks like it's asking for help implementing new functionality. but i'm not sure
"#mutation should be counted 20 times for each column. would be grateful to advice, how I should create a loop"
 
1:40 AM
PHP behind nginx is significanly faster than behind apache..... so much so that I am confused
 
2:38 AM
 
3:18 AM
Isn't numberOfSpaces just numberOfWords - 1? that saves you from calling split(" ") twice. But this question would probably be better suited for Code Review since it contains working code that you're looking for suggestions on how to improve. But certainly read their Help Center before posting there. — Mike D. 1 min ago
 
3:29 AM
4
A: Sort a stack in ascending order

rolflGenerics Generics... you want them. In your solution, they would be relatively easy to apply too. Consider your Node class: class Node { Object data; Node next; public Node(Object item) { data = item; } public Node(Object item, Node n) { data = item; next = n; } } ...

Beautiful Answer.
 
3:46 AM
0
Q: Word counting and more with javascript

Christopher OylerSo, I'm attempting to gain admission to a coding bootcamp in SF and they charged me with a challenge and 24 hours to complete it. The challenge: Write a JavaScript counter function that takes a text argument and count the following: Number of words in the text Number of characters in the text N...

 
Thanks guys, I've posted it on Code Review, I'll delete this one in a bit. Trying your suggestions. — Christopher Oyler 24 secs ago
 
4:06 AM
0
Q: LiveDateTime Performance

Kid DiamondThe following JS object displays the time and updates whenever it changes. If a timestamp URL is provided, the object will use this as the source so that it doesn't completely have to rely on the client's unreliable date. Else, there is unfortunately no other way but to use the client's time. Th...

0
Q: Understanding responsive web design using HTML5/PHP/Bootstrap3.3.4

SandeepI am trying to understand the basics of responsive web design using bootstrap. So, Is this a good way of structuring the layout of a responsive web page or are there any other/better alternatives? Here's the Gist of the entire file(login page), just in case if you want to download and test. HT...

 
4:29 AM
Thanks a lot Google.
I don't want to be part of your social media system, I just want a simple YouTube account for submitting my assignments.
I'm going to sue you when I'm older for emotional distress, so you'd better get your act together quick or consult your lawyers, which ever you prefer.
(Just kidding, but come on, Google.)
 
4:58 AM
You should post this question in code review section. — Yogesh Suthar 19 secs ago
Go to Code Review codereview.stackexchange.com site and post the same question. :) — Yogesh Suthar 1 min ago
 
Am I the only one crossing my fingers every time I merge 30-some commits from a dev branch into the next release branch? #github
Good night CR!
 
5:25 AM
0
Q: Clear function for Stanford iOS 8 Calculator application

steveclarkI am following the Stanford iOS 8 lectures and I believe I have successfully added the "Clear" functionality to the application, but I don't know if I am doing it properly. Controller class ViewController: UIViewController . . . // Linked to the "C" button in the Storyboard @IBAction func clear...

 
6:06 AM
If you're looking for a review, please visit codereview.stackexchange.comSourav Ghosh 1 min ago
 
6:17 AM
0
Q: Reading diagram code

TanhuaI would like to ask if I have done my code right from diagram.. I have following diagram: http://i.imgur.com/w1dYwVw.png and my code: //nibbleStates #define UNPACK_WAIT_FOR_1ST_NIBBLE 0 #define UNPACK_WAIT_FOR_2ND_NIBBLE 1 #define UNPACK_WAIT_FOR_3RD_NIBBLE 2 //Global variables static int byte...

 
6:41 AM
0
Q: Update on tileMap Class

TwiggyThis is an update from An Update on my TileMap Class. It's a tileMap class for a Top-down old-school final fantasy game. User Tim gave me suggestions and I updated some of the code accordingly. Tile.java import com.stardust.rpgtest2.gfx.Assets; import java.awt.image.BufferedImage; public enum ...

 
7:22 AM
You might want to post your code over at codereview.stackexchange.comduncan 1 min ago
 
7:42 AM
0
Q: Identifying the final rule from result

user2129623I am getting dictionary with different rules result, starting from two to five. rule two has lowest priority and rule five highest. For processed_output like: {'object34': {'REND': '2', 'RULE': ''}, 'object35': {'REND': '2', 'RULE': ''}, 'object36': {'REND': '3', 'RULE': ''}, 'object37': {'REND'...

 
7:54 AM
Provide us a code that you feel is not a better way. Also note you should ask such a question on codereview.stackexchange.com. — Jenish Rabadiya 1 min ago
 
8:07 AM
0
Q: fftshift implementation for opencv

GiladI'm trying to implement fftshift from matlab for opencv can you please review the correctness of my algorithm? have I missed something? also is there a better and faster way to do it? cv::Mat ff; cv::dft(distanceF, ff, cv::DFT_COMPLEX_OUTPUT); //Make place for both the complex and the real valu...

 
1
A: Reverse words in a given String

prj001I think you can simply try this:- String str = "your input source string"; String strArray[]=str.split(" "); for(int i=strArray.length()-1;i>=0;i--) System.out.print(strArray[i]+" ");

^ Is this a code dump answer ?
 
I'm voting to close this question as off-topic because it is running code and the question should be ask at codereview.stackexchange.comJens 1 min ago
It's possible this question is more on-topic at codereview.stackexchange.com, but please check their help center first. — Duncan 1 min ago
 
8:35 AM
50 minutes since I've booted my laptop: Visual Studio is halfway done loading my solution
 
9:33 AM
0
Q: Check whether given a pair of arrays are permutation of each other?

SteephenCheck whether two given arrays are permutation of each others. Does this implementation guaranteed execution of O(n) time ? What is the additional space utilization for this implementation by excluding the original array size, does it O(1)? #include<iostream> #include<set> #include<algorithm>...

 
9:48 AM
it would be great if you can share you knowledge pointing the issue — user2129623 55 secs ago
Whoosh.
2
 
10:14 AM
@200_success part of me wants to Upvote for the smart answer. The other part of me wants to DV for it... what to do? what to do?
Man.... I need a bigger monitor. This laptop screen isn't big enough for all these windows.
 
I think your question is a bit unclear. The first question(s) are about code review and the second one is about the mismatch of the result you get. Which one are you asking? The first group may be better suited at Code Review. — kkuilla 13 secs ago
 
10:33 AM
0
Q: Suggested pattern for view controller frame setting?

puzzlI've run into the following sequence of actions many times in iOS dev, and never quite known what the suggested pattern is for implementation: 1) A view controller A creates a new view controller B 2) A sets the frame of B's view 3) B then creates its own subviews, which need to be sized relat...

The comments on this question...
 
"Can you please review the correctness" is going to most likely be off-topic on Code Review. And stating that you're not getting presumably intended results is definitely going to make it off-topic on Code Review. At Code Review, we take code that is working as intended and we make it better (cleaner/more efficient/faster)... but if your code doesn't work yet, it's not ready for a review. @kkuilla — nhgrif 21 secs ago
 
0
Q: My frist jQuery plugin: custom cursor (should not be used)

Dylan HI maded my own first jQuery plugin, it should not be used because click events are not working properly. But I like to know if this is good code: (function($) { if(!$) { throw new Error("jQuery required!"); return; } $.fn.customCursor = function(settings) { ...

0
Q: My first jquery plugin

Paolo RossiI tried to write my first jquery plugin. It's a very simple ajax files upload. You can check if it is correct what I did and where can I improve my code? Thank You HTML <input type="file" id="upload" multiple="multiple" /> PLUGIN ;(function ($, window, document, undefined) { // Function...

 
the only possible inconvenience being a code review where the reviewer doesn't like it, because "it is used neither in JDK nor in the rest of our code" — Vlasec 1 min ago
 
I just mathematically proved that my optimization to the algorithm used to add an integer to a fraction always work.
Yesterday, an INNER JOIN, today a mathematical proof. I must be in good shape :)
Monking by the way ^^
 
10:50 AM
@nhgrif Well, I said may be suited. So the better and faster question could be asked at Code Review (once it is working), not getting presumably intended here and correctness to the bin? — kkuilla 1 min ago
 
@Morwenn Very nice! That's a good day righ there.
 
@Morwenn Just reading that exhausts me and I'm only a few hours awake
 
@JeroenVannevel I only had to find how I could represent what I wanted to do mathematically, then I found a theorem that was exactly what I wanted.
And it's number theory. There are plenty of theorems to prove whatever you want.
 
Mmhmm yeah. All of that sounds reasonable, it's just the mathematical part that puts me off
 
Actually, I only had to state that a fraction x / y is normalized if and only if gcd(x, y) = 1.
And what I want to prove is that x/y + n is normalized.
In other words, that gcd(x+n*y, y) = 1.
And there's a theorem that proves that gcd(x+n*y, y) = gcd(x, y).
All done.
 
11:20 AM
But it's just a theorem...
 
11:32 AM
Hey! Consider moving the code to codereview.stackexchange.com, where people may help you refactoring it! — PaweÅ‚ Dawczak 35 secs ago
 
Greetings, Programs.
 
Greetings User.
 
11:48 AM
0
Q: How can I DRY this spec?

Marcin DoliwaI'm just starting with rails and testing, and not sure what's good way to dry code like this. require 'rails_helper' describe EventsController, type: :controller do let(:admin) { create(:user_admin) } let(:mod) { create(:user_moderator) } let(:user) { create(:user) } let(:link) { creat...

 
12:02 PM
0
Q: Multitenant Cassandra Query in Clojure

egerhardThe following code handles querying for user data in a multitenant Cassandra database. Each tenant has their own keyspace and within that keyspace data about each tenants users is stored. This code will run as part of a webservice. I'm looking on comments for how I handled managing the session...

 
@CaptainObvious A good towel is probably best.
2
 
12:19 PM
We got a good looking resume yesterday afternoon.
3
 
@nhgrif Nice! hope it works out.
 
Spellchecker v1 could use some improvement
> Input : at the hme locations there were traces of water
Answer: nat they hmo locutions tere where traces af mater
 
Afternoon all :)
 
@nhgrif Yep. But the fact that it's not my theorem means that I can blame somebody else if it does not work :)
 
0
Q: What is the best way to share NHibernate session between UnitOfWork and Repository?

CoffkaCurrently I do this: public UnitOfWork(ISessionFactory sessionFactory, ILifetimeScope rootScope) { _sessionFactory = sessionFactory; _session = _sessionFactory.OpenSession(); _scope = rootScope.BeginLifetimeScope(b => b.RegisterInstance(Session).As<ISession>().Si...

 
12:28 PM
Amazingly lists .net and objective-c
Not VB but that should be okay.
And we aren't looking for someone that knows ObjC but that's a nice bonus.
I mean, if you list C#.NET, ASP.NET, JavaScript, Sql, and Objective-C and can't figured out VB.NET, I'd be impressed.
 
Monking all
 
Does someone know what algorithm is used by SE to suggest similar questions while creating a new question, I couldn't find anything on the subject. Lucene would be too easy I guess.
 
ElasticSearch (Lucene) is the seartch engine used.
I am not sure how they correlate the ask-a-question related lookups so well, but, often, searching for stuff in there is better than searching in search (which is also elastic search).
 
12:54 PM
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.comAnton Savin 1 min ago
 
ty @rolfl it seems they only base it on the title though
morning btw ;)
 
It does most definitely not belong there @AntonSavin. Code Review is for the review of working code. — Bart 8 secs ago
 
0
Q: check given points inside cuboid or not

Pramod KumarI have a list of large points define w.r.t given system and would like to get all points that are inside cuboid (cuboid can be defined in other system/skew). I have already translated all 8 points of cuboid to current system. I need some generic function like int check_point_inside_cuboid( dou...

 
@AntonSavin this question does not belong on Code Review. If the code is provided, then it may belong there. Either way, being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — Simon André Forsberg 47 secs ago
 
1:34 PM
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.comjuharr 26 secs ago
@juharr This seems to be example code which is off-topic on Code Review. Being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — Simon André Forsberg 43 secs ago
 
Is it not a programming question? Seems completely on-topic to me. The division of these questions to other stack exchange sites just makes it harder for programmers to find answers - the original intent of the site. — BlueRebel 16 secs ago
^^ Amen
 
1:59 PM
This is code review - your question is explicitly focusing on a design review and dismissing the code aspect. That's why your post is still deemed off-topic. Please see our help center for all the details, or feel free to ask on meta, or bring it up in Code Review Chat (the 2nd monitor). — Mat's Mug 10 mins ago
 
I see your point and retract my argument. — roryap 4 mins ago
 
2:14 PM
Maybe codereview.stackexchange.com is a better place for this kind of questions. — MystyxMac 1 min ago
@MystyxMac Subjective questions aren't really welcomed anywhere on the SE network. I don't think Code Review would accept this question. — Duncan 33 secs ago
 
^^ borderline for CR?
 
I think it's bad for cr.
 
ditto ^^^
 
"We did X to make our code more readable and we don't care what you think because it works for our small team, so what do you think?"
It explicitly fails the "any and all aspects" test, I think.
Even if it were on topic, it's be a very weak question since it is so narrow in scope.
 
It's definitely bad for CR, and I won't suggest them to post it here. But what if the question would have been posted here in the first place?
I don't think it is off-topic per-se. If it would have been asked here, I think the best action would have been to answer and say "Don't do this".
 
2:29 PM
I think it is. It's a naming question, not a Code Review.
OT, opinionated.
 
404, deleted
monking!
 
monking!
 
I'm going to have some serious code to put up for review soon :)
 
Just so long as you don't have code to put up for serious review, that's fine.
 
haha
2
 
2:32 PM
Huh
storing 55,000 sentences of 10 words max takes 4GB?
I'm having my doubts on that
 
10-words, 50-characters?, 2 byte sper char, is 100 bytes.
then, you have 32-byte overhead, call it about 128 bytes per sentence.
 
that doesn't add up to 4GB
 
55K of those is ..... 7 megabytes.
1 min ago, by skiwi
I'm having my doubts on that
^^^ me too
-1
Q: Linked List of a Linked List

codewarmerI need to make an adjacency list data structure - a linked list of a linked list in java. Can anyone please help me with how to proceed?

Asked, downvoted, closed, flag processed, all in 30 seconds ..... ;-)
 
Hey, why did I get a downvote ? — JaDogg Mar 18 at 14:49
 
posted on March 24, 2015 by codewarmer

I need to make an adjacency list data structure - a linked list of a linked list in java. Can anyone please help me with how to proceed?

 
2:38 PM
And... deleted.
 
@rolfl It's still using 4GB though, so the problem must be somewhere else
 
boom
 
hey @JaDogg
you got 2 actually ;)
 
@skiwi which is a logical conclusion to draw, or, you are not storing the data the way you think you are.... or, you are using Java7 and an interesting String source.....
 
Andrius, it is not irrelevant. Per the question guidelines for this site, your post is not appropriate here. We're looking for specific programming problems here, not theory discussions or opinion polls. If you have a specific problem with your code, you can isolate the problem and ask here. If you want someone to look at your existing, working code and tell you where you went wrong, use Code Review. If you want to learn best practices or compare and contrast programming patterns, take a class or use Amazon to pick up a book. — Chris Baker 35 secs ago
 
2:40 PM
What, no link to Programmers? ^^^
 
@rolfl Not using anything too fancy here
 
You know about the String memory issue, right?
 
I do see that the OOME happens on String.join rather than Map.put
@rolfl I do know something about it, though I forgot most of it aswell
 
things like String.substring, split, etc. on older Java versions would reuse the underlying char[] array.
 
Ah yes, the substring, I remember now
Running on Java 8 though
 
2:42 PM
as a result, doing things like: String name = String.valueOf(Files.readAllBytes(...)).substring(1, 10)....
 
Running your code gives many warnings, mostly number of items to replace is not a multiple of replacement length. You should fix these first. Also your question may be better suited for CodeReviewshadow 31 secs ago
 
@rolfl Interesting, calling String.join(" ", list) seems to be very troublesome
When using a StringBuilder if you exceed capacity, it will copy it to a new array
I still find it hard to believe that it would use 4GB though
phraseStrengths.put(String.join(" ", currentSentence), currentStrength);
^^ Manages to pull off 4GB after 55,000 times
 
what is currentStrength....
Just because the join fails, does not mean it is the thing with the memory problem..
 
@rolfl Just a double
StringBuilder sb = new StringBuilder();
currentSentence.forEach(sb::append);
phraseStrengths.put(sb.toString(), currentStrength);
^^ Gives same issue
If I do a simple + in a for-loop, it doesn't cause issues though
 
0
Q: Beginner text editor

m.cekieraI wrote a simple text editor and I would like to get some critical comments. Below I present only a main part of code. I removed icons, irrelevant functions, etc. I am aware,that JTextArea is not best choice for text editor, however I purposely didn't choose JTextPane because at my level it seems...

 
3:00 PM
Code Review only reviews working code. If, and only if the code works as intended (which doesn't sound like it based on the warnings) it may be on-topic for CR. — Phrancis 59 secs ago
 
> Body is limited to 30000 characters; you entered 34732.
#dammit
 
Haha, I got that one too once :)
 
@Mat'sMug you trying to beat my record!?
 
@Phrancis code with warnings works as intended all the time.
 
but... it's only 4 little classes!
2
:(
fine, fine... edits
 
3:02 PM
4 classes is a lot to review...
 
@nhgrif Ah, think I should edit that out of the comment?
 
mostly context code though...
I'll just link to github instead
 
@Mat'sMug 4 little classes.... 34k+ LoC.. might want to think about that in and of itself.
 
ANTLR listener implementations...
 
By the way, I started a bounty on Stack Overflow last night. stackoverflow.com/questions/23058657/…
 
3:03 PM
Oh... nevermind.
 
2
Q: sandbox custom qlgenerator (Quick look) plugin

Lakshmi SHow to sandbox quick look plugin on mavericks? Currently obtaining following error message: 2014-04-14 16:26:50.507 qlmanage[5601:303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x8b13, name = 'com.apple.tsm.portname' See /usr/include/servers/bootst...

Feel free to burn an SO upvote on the question.
 
@skiwi What is currentSentence? How big is it? What does it contain?
 
@SimonAndréForsberg The problem may be that it's bigger than expected
 
actually, it's Rubberduck.Parsing.Symbols.DeclarationType enum, Rubberduck.Parsing.Symbols.Declaration class, Rubberduck.Parsing.Symbols.IdentifierUsage struct, and Rubberduck.Parsing.Symbols.IdentifierReferenceListener implementation - and I removed the Rubberduck.Parsing.Symbols.DeclarationSymbolsListener implementation
 
Oops!
A missing return statement matters
2
> Input : at the hme locations
Answer: bat the hme te hme thf hme th hme tho hme ths hme thu hme thy hme thx hme tie hme tae hme che hme she hme he fat tue hme tee hme they hme thee hme them hme then hme toe hme the hme te hme thf hme th hme tho hme ths hme thu hme thy hme thx hme tie hme tae hme che hme she hme he nat tue hme tee hme they hme thee hme them hme then hme toe hme the hme te hme thf hme th hme tho hme ths hme thu hme thy hme thx hme tie hme tae hme che hme she hme he aa tue hme tee hme they hme thee hme them hme then hme toe hme the hme te hme thf hme th hme tho hme ths hme th
^^ If my spell checker now would start to make sense, that would be great
 
3:08 PM
lol
 
The goal was to correct the sentence, not to mess it up even more
 
0
Q: Beginners' All-purpose Symbolic Instruction Code - Turning VBA code into symbols

Mat's MugThe Rubberduck project is coming along pretty nicely, and for the next version the parsing strategy is getting yet another revision, and this time around it really feels like it's done right. Or is it? The idea is to walk the parse tree once to locate every single declaration. Here are the typ...

 
Someone is strangling your spellchecker
 
> I like this API now, ...but am I going to curse at it in 3 months?
Well, given the project's history..... lol
 
IKR :)
 
3:15 PM
0
Q: Java Assignment

user68831Write a program that reads ten integers from the keyboard, stores them in an array, and displays them in the reverse of the order in which they were entered. The minimum and maximum values that were entered should also be displayed.

 
@CaptainObvious oh-the-title
 
WTF
> Input : at the hme locations
Answer: bat fat nat aa ab ad rat ae apt af ag ah vat ai ak it al am an ao ap ar as at au rt tue tee they thee them then toe the hme locations
 
This is SO, not Code Review ;) — Martin 1 min ago
 
My review of this assignment is that it ia a pretty good assignment and should be easily completed by an novice Java programmer. — nhgrif 13 secs ago
 
OMG where in "Code Review" does it say "gimmeh teh codez"?
@CaptainObvious kill kill kill kill
 
3:25 PM
2 more to close
 
this might be a better title:
1
Q: Where's what used where - turning code into symbols

Mat's MugThe Rubberduck project is coming along pretty nicely, and for the next version the parsing strategy is getting yet another revision, and this time around it really feels like it's done right. Or is it? The idea is to walk the parse tree once to locate every single declaration. Here are the typ...

seems the mere mention of "VBA" scares C# viewers away...
 
Confirm or debunk my suspicions: if an object has a field that serves as unique ID, is it appropriate to over GetHashCode() by simply returning the hashcode of that field?
Won't that just create N buckets? Or are buckets grouped by range?
 
@JeroenVannevel is that a question about my code?
 
Initially it was but halfway through my sentence I realized it doesn't apply in your case
 
I'm lost
 
3:29 PM
But I still want to know
 
Looking lots better:
> Input : at the hme locations there were traces of water
Answer: et the home locations there were traces of water
When the probability of error will be taken into account, then it should be lots better as well
It's more likely that "at" is spelled correctly, than that "e" is typed instead of "a"
 
@JeroenVannevel can you rephrase that in English? ;)
 
If you have a class Author with a field Id and Name and want to override GetHashCode(), can you simply return Id.GetHashCode()?
The ID is unique which means every GetHashCode() will be unique
If you put that in a hashtable, it means there will be N different hashcodes (not a single collision)
 
if Id is unique, I'd deem it an ok implementation, no?
 
This means a lookup would still take O(n)
But hashtables are O(1)
So does this mean the buckets are grouped on some criterium?
 
3:33 PM
buckets?
 
Code Review is where this question belongs. — Arun A.S 28 secs ago
 
In computing, a hash table (hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found. Ideally, the hash function will assign each key to a unique bucket, but this situation is rarely achievable in practice (usually some keys will hash to the same bucket). Instead, most hash table designs assume that hash collisions—different keys that are assigned by the hash function to the same bucket—will occur and must be...
oh
I should've read wiki
2
 
me too! lol
 
> Ideally, the hash function will assign each key to a unique bucket, but this situation is rarely achievable in practice (usually some keys will hash to the same bucket). Instead, most hash table designs assume that hash collisions—different keys that are assigned by the hash function to the same bucket—will occur and must be accommodated in some way.
> In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table.
Now they just need to say why this is..
 
What are you confused about?
Trust me, I know what I'm doing!
 
3:36 PM
If a hashtable has N keys, how does it have an O(1) lookup time?
 
funny you mention hashtables an O(1) lookups.. .that's what I initially intended to do with my thingy there (hence the GetHashCode override)... turns out I end up iterating them anyway, so I gave up and used a ConcurrentBag instead
 
I always thought it grouped keys by range so it could immediately disregard the majority of entries and only had to look in a single bucket
 
@JeroenVannevel Under the assumption that you have a good hashcode, then every bucket will contain a constant amount of items, hence O(1)
 
@skiwi yeah, but you still have to get to the bucket. How do you get to the bucket?!?!
 
0
Q: Refactoring a nested unless statement in Ruby

user2770919For a board game I'm writing, I created a method that requires a bunch of nested unless statements. It looks really ugly, and I was wondering if it could be refactored. def loss_checker new_board = Marshal.load(Marshal.dump(@board)) option = move_right unless option option = mo...

 
3:37 PM
@JeroenVannevel Magic?
Consider a hashtable capable of storing 1000 elements, if you create an array with 1000 elements then you could potentially store them there, if you happen to need to insert another element in the same bucket, then you need some kind of linked list node that points to the initial element of the bucket
The basic implementation is essentially an array containing linked lists (sort of)
Now, using an array would be stupid, so then they came up with lots of smart ideas
 
> I tried the following, but it broke my code
^^ SO's what-have-you-tried syndrome
 
@skiwi Combined with Given a key, the algorithm computes an index that suggests where the entry can be found I assume they just sort of guess where the data can be found and look in that area
My curiosity is satisfied for now. I'll look into this again in a few months
 
@JeroenVannevel I believe it's also amortized O(1) lookup time, so you can do a few instructions when looking u a certain element, as long as it doesn't turn into a complexity related to n
 
that would make sense
Well, all you really need to do is map each key-value to an integer between 0 and amountOfKeys after all
So once you have that function, you're done
Each key can be resolved to a bucket in O(1) since arrays are O(1)
 
The problem with a traditional array approach is that it creates huge gaps if the data is sparse though
 
3:44 PM
Seems you have spent some time on CodeReview, haven't you? :P — kocko 1 min ago
 
Using the three-step-rule you can easily get a number between 0 and amountOfKeys and susequently calculate it with the exact value
All you have to do is amount for some rounding errors to make sure you start at the right index
so a few buckets at the most
if it's uniformally distributed, it will be 0(1) for each bucket
magic resolved!
 
I keep meaning to check out that site :-) — Duncan 4 mins ago
 
@Mat'sMug Just read your latest Q.
Seems like you have an awful lot of methods doing the same thing.
Is there any possible way you could merge them?
 
Are you getting any console errors? What output if any are you getting? "Would you have done anything else differently" doesn't really fit with stackoverflow as it's too opinionated. Code review type stuff fits a bit better at programmers stackexchange. — scrappedcola 29 secs ago
 
^^^ so many wrong things there ^^^ , but the programmers folk will nail them down, I am sure.
 
3:56 PM
Wow, @Duga
 
@Hosch250 possibly... that's why it's up on CR ;)
 
@scrappedcola Code Review stuff usually fits better at Code Review - I suggest you take a look at the CR Help Center (hint: code that doesn't work as expected is explicitly off-topic)... and Programmers' Help Center, too. — Mat's Mug 1 min ago
 
That question belongs on SO...
Not programmers or CR.
 
What kind of bar doesn't put a name outside
 
that's why I'm pointing commenter to help centers...
 
4:00 PM
The Foo bar?
2
@Mat'sMug Would it be possible to just create one function for entering and one for exiting?
Seeing as they are override methods, I'm not sure.
 
the base class is ANTLR-generated code
there's a virtual method for every grammar rule
I only override the ones I'm interested in
 
I know that they can be merged somehow, but I'm not sure how.
 
but the two listeners (only one is listed) share a fair amount of code, I was tempted to make a base class for them
 
I don't know the project good enough.
I'll mull over this for a while, and maybe post an answer, but I've really got to do some school now.
 
3
Q: f# hashtag on Twitter is not valid

BrunoMy question was tweeted with the automatic Code Review Twitter account. The tweet in question is using #f#, which isn't valid. It should use #fsharp, like #csharp in this tweet.

 
4:06 PM
Chameleon questions... Blech...
its part mine and part yours here what i did let url = NSURL(string:testAd.getImgPath()) var err: NSError? let imageData = NSData(contentsOfURL:url!, options:.DataReadingMappedIfSafe, error:&err) let imageE = UIImage(data:imageData!) ***where imageE is inserted into a button background — Tom 2 mins ago
Switch it to be exactly like mine or post a new question. — nhgrif 1 min ago
 
The mug has a bug.
4
 
what? where?
 
NO SPOILERS
Imma let you steam for a bit more
 
...
but... but.... code inspections work! ...
 
I can only assume your unit-tests are inadequate
because this is typical unit-test material
 
4:10 PM
I wish I could write unit tests for the parser... but mocking up the VBE object model is ....daunting.
so parser-related stuff is all integration-tested.
 
another bug, same kind
I hope I'm not wrong, otherwise I look silly
 
lol
5
dammit
@JeroenVannevel if you have a way of twisting this code around so it can be unit tested.. I beg you, be my guest!
2
 
mm they're private methods which makes it pretty hard. However recently I saw a very interesting approach on testing private methods, which might be useful
 
then maybe I should extract an interface there?
 
Eh.... the private methods isn't really the challenge. Mocking the damned dependencies is. I tried a few weeks ago. Ended up writing about 50 LoC just for the Mocks.
 
4:19 PM
Mocking is a problem an sich
@Mat'sMug Not really since the code is still in the implementation. It's not about injecting
But with a PrivateObject you should be able to access those methods just fine
then it's just a matter of creating your own Declaration object to input, but I don't know what options you have to do that since I don't know ANTLR
 
Is there a code-coverage tool for C#?
 
dotCover
 
JetBrains has one ^^
 
That's a decent way to audit tests of private code.
If all your tests use all the code and get all the right results ......
 
Rubberduck test coverage being definitely sub-par, is an understatement...
 
4:26 PM
string.Format(Name, issue.IdentifierName) What does this do?
Does Name hold a formatted string?
as in a {0} value?
 
yup
but not always
IKR
 
mmhmm
^ Judgemental mouth sound
 
Name is part of the IInspection interface
 
I'd be afraid to run a coverage tool on RD. I'd spend the next month doing nothing but writing tests.
 
> Test coverage: 0.001%
2
 
4:28 PM
Make it public, it motivates: hunterhacker.github.io/jdom/jdom2/coverage
org.jdom2 -> 99%
 
@JeroenVannevel the bug is in GetHashCode? Awesome, I'll just remove these overrides! (I don't think I need them)
 
No, that's just me complaining
 
I have adopted TDD with new code, just to make sure they get written, but a lot of the code base is lacking for sure.
 
It's in your boolean logic
 
Selection is definitely immutable
EnterSubStmt is a generated method...
 
4:38 PM
Thanks - good suggestion on moving this to Code Review. — Steve Midgley 1 min ago
 
@JeroenVannevel fair enough.. but then how do I test that a global-scope array a(1 To 10) isn't "hiding" a module-scope procedure a(foo As Integer)?
nice answer BTW
very
 
@Mat'sMug I don't know what that means. Keep in mind that my knowledge of VB is restricted to Dim blaat As Integer
 
How about a ButtonFactory with a single public static JButton createButton(Color color, String text) method. In that method, configure the button and return it. Then your main class can just do JButton button1 = ButtonFactory.createButton(Color.red, "Add");. Also, codereview.stackexchange site is probably a better place for these sorts of questions: it's a bit too open-ended for stackoverflow. — Mr Spoon 18 secs ago
 
lol right.. one of the challenges I'm going to be facing, is proper scoping (GetClosestScope addresses that) - I want to implement a refactor/rename functionality ;) ..so I need to make sure when I pick up a(10) = 42 somewhere, that a is referring to the function a the assignment is in, not to the global-scope array a declared in another module
 
Hmm what is on cr the common practice is if the solution you used is a merge/boiling of all provided answers?
 
4:46 PM
@Mat'sMug Write a tool in C# that can clean up and refactor C# code, ???, profit!
 
I already have ReSharper for that!
 
@Mat'sMug Doesn't Antlr provide a unique ID for each syntax element or something like that? That would've been nice
 
if so, I haven't figured it out yet - but I'm holding on to the Context anyway, so I have a unique reference for everything anyway
 
Can you work with just fully-qualified names?
That should make the distinction between all elements
 
if I can mock up a VBProject's hashcode, yes
(shouldn't be too hard)
oh wait, no
 
4:48 PM
Reinforcement learning in Artificial Intelligence is awesome
 
QualifiedModuleName has/needs a reference to the VBComponent it's for
 
@skiwi Aka: beat the cat until it does its tricks
 
All that robot knows is that it can move some actuators and that moving forward (measured by a sensor that checks if the wheel is turning forward) is good behavior
 
0
Q: Casting a float into an int lacks precision

BrewalI have this simple code : demo $float = (float)('33.30'*100); var_dump($float); $int = (int)$float; var_dump($int); And I get this result : float(3330) int(3329) I have done this ugly fix, but I would like to know if there won't be side effects, and I would really appreciate if someon...

 
@paul23 Upvote all useful answers, and accept the one you found the most useful. It's also possible, but certainly not very common, to post your revised code as a community wiki self-answer (make sure you don't accept your own, if you do that - that would be considered rude)
 
4:59 PM
@paul23 that's quite common. when all answers are useful, I usually accept the most detailed one
 

« first day (689 days earlier)      last day (3330 days later) »