« first day (579 days earlier)      last day (3455 days later) » 
00:00 - 20:0020:00 - 00:00

12:08 AM
0
Q: Code Improvements?

Tyler WeaverIn this program I was required to calculate the Harmonic Average using an assembly program with a C driver. Harmonic mean is define as: \$ \frac{n}{(1/x_1) + (1/x_2) + ... + (1/x_n)} \$ where \$n = \$ number of inputs and \$x_i = \$ a real number. I would like to know if My code follows com...

 
12:22 AM
@CaptainObvious This is a code review??
 
12:33 AM
@SimonAndréForsberg I have not used those features enough to have run in to them as problems...
but, it sounds like it's a pain.
 
0
Q: Need to refresh Parsed cycling Rss feed every 5 mins

MrScott101I am working on a monitor signage display and have a welcome to rss feed with just title and desc. I have code from feedEk that's been tweeked a bit to parse the feed and cycle it so I only have one title and desc showing at a time. This feed could be added to or deleted info at any time so I nee...

 
@rolfl Quick question (hopefully). You used the word "getter" but the concept seems a little... vague to me. Is it just some object that gets something from some other object? Is there a more precise way to define it?
 
'getter' is a term that appeard about 10 years ago, or so, in Java, especially with the concept of a Java 'bean'. It's a combination of two terms: "getters" and "setters".
 
The bottom line is that, proprties can be retrieved with 'get' methods, and assiged with set methods.
 
12:41 AM
That much, makes sense
 
The get and set methods are supposed to be symmetrical. A method void setValue(String value) would have a symmetrical method String getValue()
The naming convention plays a part. The get and set pair have the same 'suffix'.
read-only properties only have a get method, and not a set method.
boolean properties use the prefix 'is' instead of 'get'.
so, public void setEnabled(boolean state) has the 'getter' with the signature public boolean isEnabled().
 
Is a constructor a sort of 'set' method? I'm probably thinking about it wrong...
 
No, not really.
 
OK
 
a constructor does not fall in to the same part of the object lifecycle as the getter/setters.
You will find that your brain will quickly become 'tuned' to the consistency of the get/set/is methods on objects.
it is common, though not pervasive, that when you have a class with a prerty, like a 'Name', that you have a field called 'name', and a getter called getName()
If the name is mutable (can be changed), then there will be a setName(String name) as well.
 
12:48 AM
OK. I did not get a chance to read what you and Jeroen posted about the various answers yet, we suddenly got busy at work before I clocked out.
 
When C# came along, it borrowed the get/set concept, and formalized it as part of the language.
So, in C#, you can declare a get-set method combination, and it will create the actual property for you in the background.
Technically, unless you have an actual Java Bean, the getters and setters are just a matter of convention.
So much so, that IDE's will offer you automatic code-generation for getters/setters on fields.
 
Anyone here who knows JavaFX atm?? I could use some help in changing the status of a lable from not visible to visible
 
1:07 AM
@Gemtastic Have you asked the Google Gods?
 
@Phrancis I did and it gave me nothing
Though I kinda figured why it wasn't working anyway
Wrong import fml
 
Well there you go :)
 
1:28 AM
I wonder if you can set the time for how fast a tooltip appears
 
-1
Q: Coding for Car Rental System using C programminng

aliyinHye, can someone help me. I need a car rental system coding in c programming. Using linked list, structure, stack, sorting and searching. I use code block before

 
@Gemtastic You can, but depends on the application
 
@rolfl It's javaFX
It's not terribly neccessary, but it annoys me that it's not instant
 
1:47 AM
1
A: control JavaFX Tooltip delay

jewelseaThere is an existing feature request for this: RT-19538 Customizable visibility timing for Tooltip. The feature request is currently scheduled for integration into Java 9. Attached to the issue I linked is a patch you can apply to allow you to get this functionality in earlier Java versions. ...

 
0
Q: Memoization for calculating minimal traversal distance within a positive matrix

KevinThe code below is for calculating the minimal traversing distance from the top left point of the matrix to the bottom right point of the matrix. https://gist.github.com/anonymous/92033633c26cf9fb4b10 Here is the core functionality Please note that y is a global variable keeping track of the me...

 
@rolfl That seems a bit too complicated for me to try it now
But thanks :)
(I will look into it later)
 
2:08 AM
@rolfl how would you modify \S.+\S regex to remove starting and ending spaces even if we have one character " i " ? :D
it's not important at all
I am just curious
obviously changing it to \S.*\S makes it capable of doing down to 2 digits
but not (1) :D
 
2:34 AM
I'm confused. \S is non spaces
 
2:46 AM
Interesting...
two labels will be hidden when one if case fires (where I have not specified their status), but if I state them to be hidden, they won't hide...
If you ignore that bugg, my application is done~
 
3:00 AM
Stack Overflow has a new review queue: stackoverflow.com/review/triage
62
Q: Help us test question triage!

Shog9tl;dr: there's a new review queue. It'll be getting somewhere around 1-2 questions per minute. The only thing they have in common is that the system is unsure of what to do with them. Some are great, some are awful, some are in-between. We need you to help the system decide which category these ...

 
 
1 hour later…
4:27 AM
0
Q: Container adaptors

OrientHow to improve the functionality, exception safeness and other aspects of the following container adaptors? Allows to write more generic code (not working for, say, <set>): #include <utility> #include <iterator> #include <type_traits> template< typename container, bool = std::is_const< std::re...

0
Q: Chaining Applicatives

Kevin MeredithI wrote this code to append Maybe's: ghci> (:) <$> Just 5 <*> ((:) <$> Just 100 <*> Just []) Just [5,100] Similarly: ghci> (:) <$> Just 5 <*> ( (:) <$> Just 10 <*> ((:) <$> Just 100 <*> Just []) ) Just [5,10,100] Is this code idiomatic? Perhaps there's a more concise way to append a bunch o...

 
0
A: Should code be forcibly translated into English?

rolflStack Exchange in general has an English-Only policy. There are some exceptions for language-specific sites (like Stack Overflow in Portuguese). Code Review is not an 'exception' site. It is clear that there are benefits and drawbacks to having an English-only policy, but the Stack Exchange 'pow...

 
I agree
 
@rolfl if I have a property like this
public List<ITemplatePart> Options { get; private set; }
I am gonna need to have new List<ItemplatePart>(); later on to be able to use it
would you put the new in the constructor or just before the point you're going to add something into this list?
or even non
 
4:42 AM
@Mehrad couple of things -- generally advised against to expose List<T>, as the fact that you're using a list is an implementation detail. also you can generally make your backing list readonly, and manipulate via its methods. so i usually end up with code like this: private readonly List<ITemplatePart> options = new List<ITemplatePart>(); public IEnumerable<ITemplatePart> Options { get { return this.options; } }
 
@mjolka so just to clarify. you're suggesting not to use auto property on the list items and back them up with a read only field. right?
 
also making the return type IEnumerable<T> means client code can't directly do things like blah.Options.Add(...) -- you maintain control to of your list
right
plus you can swap out List<T> for HashSet<T>, T[], etc at a later date if you want -- client code won't break
 
in terms of not exposing it, wouldn't private set do the trick or i am missing a point
just want to understand the correct wording
 
sorry, "exposing" was a bad choice of words on my part
 
and also wouldn't readonly stop me from adding the part's options in my methods?
 
4:49 AM
if Options has type List<ITemplatePart>, client code can directly manipulate the list -- calling Options.Clear(), Options.RemoveAt(), etc
this is generally more than the client code should be allowed to do
 
Oh correct... IEnumerable does the trick in that case. that's a very good point
 
readonly just means it can't be re-assigned -- you can still call Add, AddRange, Clear, whatever you want
you just don't expose that functionality to the client
 
Oh... somehow I was under this impression that readonly fields could only be assigned through constructor and not else.
 
0
Q: adding classes with javascript

user59405I am working again and got this to work. I was just wondering if this is the best way to wright this code? $(window).load(function(){ var $window = $(window), $sticky = $('#contentSideIner'), elTop = $sticky.offset().top; $window.scroll(function() { $sticky.toggleClass('sticky', $window.scrollT...

 
Never thought of using IEnumerable for that trick... it's quite nice
 
5:04 AM
@mjolka I always though adding or removing from the list counts as an assignment.
how did you know this :D
You guys are so helpful sometimes. can't say how much I am learning just listening to you guys talk : ))))
 
Pleased I could help ;-)
 
@Mehrad learned it by making a lot of mistakes :)
 
@mjolka man you must have done so many mistakes. very good learn. I am still pumped from learning that greedy + you pointed out yesterday and now another good one ...
 
5:20 AM
@Mehrad greedy +? i think you're thinking of someone else. but glad i could help :)
 
@rolfl babahahahaha... just seen your comment.
oh... I couldn't figure out some regex not working and somebody pointed out that + is greedy in regex unless +? and vola ....
 
C# programmers: This new user posted the same generic answer to two questions.
I'll take recommendations on what action to take, if any.
 
@Mehrad also, install resharper if you're not already using it. then convince your work to buy a license for you
 
we actually own it on our VS 2010 but since VS 2013 introduced lots of features of Re# by itself I haven't installed it on 2013. @mjolka
 
good to hear. writing c# without it... sorta sucks
 
5:24 AM
@200_success One answer was self-deleted just now.
 
but you're very right. I miss those little tips and tricks Re#er used to throw now and again and fix issue missed out
 
@Heslacher I deleted your comment
> isLeaf can be simplified to return (position > size/2);
on this question:
0
Q: MinHeap implementation in Java

Ishan SoniI have made my own MinHeap in Java. I would like to get review comments on the same. package heap.minheap; public class MinHeap { private int[] heap; private int size; private int maxSize; private static final int FRONT = 1; public MinHeap(int maxSize){ this.heap = new int[maxSize+1]; ...

All suggestions for improvements belong in answers.
Commenting could be interpreted as an invitation to change the code in the question.
 
5:40 AM
0
Q: Php PDO class extend

miasyntaxI am moving in to oop php and having some problems extending my database class to my objects. Here's some of my code thanks in advance! I am still new to the variable scoping in OOP php, so if it a tiny syntax error I apologize. If my methodology looks wrong or can be improved, I would love to he...

 
5:51 AM
I've spent so much time and energy on this parallel project (due tomorrow), and there's still some large flaw in it. Hybrid parallelization seemed out of my league anyway.
 
Hmm this GUI looks nice now at least
 
6:48 AM
Monking @all
 
0
Q: which is faster + operator or append in python

Tirupati Raos=s+'a' s+='a' s.append(a) Is there any difference between above three? I am confused with these choices. Which needs to be used at what time and is string append method faster than the others?

0
Q: scan keyboard arrows and backspace keys in python

Tirupati RaoI can able to scan all the ascii characters using in build function . but is there any way to scan arrows and backspace ?

-2
Q: i need suggestion to develop this java application which displays java API

Tirupati Raoi wrote a java application.with this application we can see java API by typing java package name in the text box.i need suggestions to improve this application .please help me. public static String getOutput(String cmd){ String line; String output = ""; try { ...

 
7:30 AM
0
Q: how can I refactor this JS?

bezzoonIdeally I would have one draw method in the parent class (Player) But I can't figure out how to do this. I don't know if there is anyway to decouple it totally..any ideas are welcome. I don't mind modifying the sprite sheet so that it can handle this sort of thing. Any tips are very welcome!! ...

 
7:52 AM
0
Q: Test if a string is a number in C

Oz123In need for testing if a string is a number which could be a double or integer, I wrote a simple skeleton, which parses a string like this: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> int main(int argc, char *argv[]) { char* to_convert = argv[1]; char* p = NUL...

 
8:30 AM
@200_success I put it in an answer now. Basically I thougth this nitpicking is to less to be an answer hence the comment.
 
Thanks.
21
Q: Short answers and code-only answers

ChrisWWhat should we do with: Short answers (for example, "I suggest you use [hyperlink to this standard API] instead.") Code-only answers (for example, an improved version of the code in the OP) Such answers could be improved (e.g. by adding an explanation of why the suggestion is helpful). Is it...

 
9:04 AM
0
Q: Simple Poker Game

topherI'm building a simple poker game, it is almost complete, but I want to refactor it early. To calculate hand strength / ranks, I use this library from NPM : poker-evaluator For deck shuffling, I use the Fisher-Yates algorithm. My code is mainly about game-play, determine if ready to start next rou...

 
morning
 
Monking @Pimgd
 
You will neeeeever get me to switch
neeever
 
we'll see ;)
 
9:22 AM
Monking @Pimgd
Monking @Vogel612
 
9:54 AM
0
Q: Unit of Work Cancel vs Commit

dav_iI use the Unit of Work pattern in my ASP.NET MVC projects in the following way usually: public interface IUnitOfWork : IDisposable { void Commit(); } public class SomeController { private readonly IUnitOfWork work; private readonly ISomeRepo someRepo; public SomeController(IUni...

 
hey
 
hey
 
0
Q: INDEX & MATCH - Identify the Range and Change it Function written in VBA

MohammedI have written the below mentioned function in one cell, I want to write below function in VBA code to run as a Macro. But instead of fixed range, I want to change the range based on number of rows, because the row is going to add as days progress. =IFERROR(INDEX($A$2:$A$169,MATCH(0,INDEX(COUNTI...

 
hey
@CaptainObvious Pseudo code
 
@Heslacher probably just changed names to protect the innocent..
from a quick glance there's nothing important missing..
 
10:03 AM
if (vm.Property != null)
{
this.ModelState.AddModelError("Property", "Can't be null");
// no changes so nothing to cancel in this instance
return this.View(vm);
}
^^^this is flawed
 
@Heslacher hmmm... yes
 
@Vogel612 Also it wouldn't compile because the Add method doesn't always return a value.
 
hmm... quick glance ftw;)
 
0
Q: Refactor method to reduce conditionals

jbailie1991I've been given the job of trying to reduce the line count for a file that helps generate a PDF for a web app. I came across this particular method: public String getLocationToString(Page aPage) { if (aPage.getSiteDetail() != null || aPage.getLocationDescription() != null) { if (...

 
 
1 hour later…
11:23 AM
1
Q: Get the list of xml file best way within vb.net application

Lamloumi AfifI have the following method Shared Function GetListByType(ByVal intIndex As Integer) As List(Of FileInfo) Dim strWorkingPath As DirectoryInfo = New DirectoryInfo(GetWorkspaceDir) Dim lstAllFiles As FileInfo() = strWorkingPath.GetFiles("*.xml", SearchOption.AllDirectorie...

 
11:55 AM
@rolfl using Lambdas for Card effects in Cardshifter is nice and sweet, but then you need to describe the effects in the client as well. com.cardshifter.effects.Damage.lambda$41@42fe34a doesn't display well in the client. I think that either I am approaching it all wrong, or my idea about making a class for the lambda that adds a string description is totally correct and it's just me being reluctant to implement it for some strange reason.
 
ehh you can capture a final String argument in a lambda..
alternatively you could create a @FunctionalInterface and override the toString of it..
 
@Vogel612 capture a final String argument? How do you mean?
 
I don't quite understand what exactly you're trying to do...
 
essentially, change the output of toString() for a lambda.
I know that I can create a class for it, pass a lambda and a string, and case closed.
 
why not:
 
12:02 PM
Monking, @all
 
@FunctionalInterface abstract class DamageEffect {
     public abstract void apply();

     @Override
     public String toString() {
          return "Damage Effect";
     }
}
 
@Vogel612 You can't put @FunctionalInterface on an abstract class
you need to make it an actual class and implement the interface, and pass a lambda to the constructor
 
the Javadoc states differently
> Conceptually, a functional interface has exactly one abstract method.
 
> An informative annotation type used to indicate that an interface type declaration is intended to be a functional interface as defined by the Java Language Specification.
 
> If a type is annotated with this annotation type, compilers are required to generate an error message unless:

The type is an interface type and not an annotation type, enum, or class.
The annotated type satisfies the requirements of a functional interface
meh...
okay point taken...
 
12:14 PM
so the only solution seems to be:
14 mins ago, by Simon André Forsberg
I know that I can create a class for it, pass a lambda and a string, and case closed.
 
@SimonAndréForsberg - you could leave off the @FunctionalInterface, and leave it as an implied interface?
 
@rolfl well, the class that I would make for it would of course not have @FunctionalInterface
 
abstract class DamageEffect {
     public abstract void apply();

     @Override
     public String toString() {
          return "Damage Effect";
     }
}
^^^ no @FunctionalInterface, but can still be the target of a lambda
 
@rolfl You can't use that with a lambda though AFIAK
 
Monking @rolfl
Monking @SimonAndréForsberg
 
12:17 PM
you can't use () -> doSomething and have that become an instance of DamageEffect
 
are you sure? I'd say you can...
 
class DescribedFunction<A, B> implements Function<A, B> {
   constructor(Function<A, B> function, String description) {
   }

   String toString() {
       return this.description;
   }

   @Override B apply(A a) { return this.function.apply(a); }
}
I think that that ^^ is the way it needs to be done
@Vogel612 AFAIK, only interfaces that is or could be annotated with @FunctionalInterface can be turned into lambdas.
 
incorrect.
that much I know ;)
 
Monking @Heslacher
@Vogel612 prove me wrong!
 
or do you see Runnable annotated with @FunctionalInterface in jdk8?
 
12:20 PM
@Vogel612 is or could be
it doesn't have it, but it would be valid to put @FunctionalInterface on it.
 
sure it would be valid, but it can still be turned into a lambda easily, without having it
 
@Vogel612 (...)/openjdk/6-b14/(...)
I see...
 
0
A: iOS Terminating app due to uncaught exceptions when parsing JSON object

nhgrifSo, as KerrM's answer points out, this exception is happening because we're trying to access an index which doesn't exist in our array. jsonData = [tArray objectAtIndex:1]; This is exactly what the bolded part of the exception you put in the question is saying. So what should we do to fix it?...

 
because it can have it. It is an interface and not a class, and it has only one abstract method. Then it can have the annotation @FunctionalInterface.
 
12:23 PM
grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/… http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/j‌​ava/lang/Runnable.java
Java 8 version
 
even if it wouldn't have, then
> However, the compiler will treat any interface meeting the definition of a functional interface as a functional interface regardless of whether or not a FunctionalInterface annotation is present on the interface declaration.
 
T.T I should've checked better..
 
simon simon is it faster yet? =D
 
@Pimgd todo-overflow. Preparing non-coding things today, working tomorrow, visiting a friend on saturday... no time for Minesweeper code :/
 
awwwwww
 
12:38 PM
@SimonAndréForsberg - It appears you cannot create a lambda off of an abstract class.
additionally, you cannot override the toString() as a default-method in an interface
 
@rolfl exactly. That's what I told @Vogel612
@rolfl that is also true. I remember having read that.
 
Thus, there's no way to change the toString of a lambda, but you can wrap the lambda in to another container with a toString.
 
yeah, exactly.
 
By wrapping the lambda, though, you lose almost all the value and convenience of the lambda anyway, so it's pointless.
 
12:53 PM
new DescribedFunction(a -> a.doSomething(), "Some effect") is less optimal than a -> a.doSomething() but I wouldn't call it "pointless".
 
@rolfl What's wrong with using an (functional) interface with a default method?
 
because you can't override toString
which is the point of the problem.
 
That's some issue, yes
I sense some Swedish Overengineering
3
 
Ohhh... see there's a bountied Java question .... I like the message ;-)
 
@skiwi Then you try to make a nice way of doing the card effects with their descriptions in Cardshifter!
 
@SimonAndréForsberg I'm afraid it would then turn into Dutch Overengineering
2
 
You could take a leaf out of my German Overengineering where I had the "same" problem with the JavaBot's commands
 
@Vogel612 you had?
 
well at least very similar
But it wasn't just one string, but 3...
plus a predicate, but eh...
we might even throw the predicate over board since the current CommandHandles are subject to discussion
 
1:35 PM
0
Q: creating large csv files in Java getting really slow

aironmani have a performance problem when trying to create a csv file starting from another csv file. this is how the original file looks: country,state,co,olt,olu,splitter,ont,cpe,cpe.latitude,cpe.longitude,cpe.customer_class,cpe.phone,cpe.ip,cpe.subscriber_id COUNTRY-0001,STATE-0001,CO-0001,OLT-0001,...

0
Q: Services for classes with common parent

dav_iI have three related classes: Article and Document which both inherit from Publication: public abstract class Entity<TKey> { public virtual TKey Id { get; protected set; } } public abstract class Publication : Entity<int> { protected Publication() { this.Created = DateTime.N...

 
2:05 PM
0
Q: Segment Tree Implementation in C++

NamsI have been trying to implement segment tree to find sum of a given range.It is also required to update the segment tree.I am trying to solve this problem. http://lightoj.com/volume_showproblem.php?problem=1112 As mentioned n<1000000 and q<50000.So I think segment tree which have a complexity o...

 
I am frankly amazed by the rep-generator that "Hello World, @Phrancis" still is
 
@Vogel612 who are "we"?
 
Uni, Michael & me...
 
@SimonAndréForsberg I hear your government is 'close to collapse'... what gives? Just normal politics?
 
@rolfl too bad I didn't get any rep from helping @Phrancis in chat before he asked the question.
2
 
2:13 PM
Yeah, there's a fair amount of that.
Stars don't count nearly as much as votes.
2
Here, have a star.
 
@rolfl Swedish parliament consists of three parts: The Left-Center, the Center-Right, and the Swedish Democrats (far-right anti-immigration folks). For the past 8 years, the Center-Right has governed the country. 4 years in majority and 4 years in minority (< 50 % of the seats in parliament, but still bigger than the Left-Center block).
After the election three months ago, the Left-Center got bigger than the Center-Right, and the Swedish Democrats got 13% of the votes (they had 5% in the previous election)
So it was decided that the Left-Center should be the ones to pick the Prime Minister and form the government.
 
OK, that sounds 'normal', so what's the problem....
(I could just google it....).
 
However, the Swedish Democrats are pretty much mortal enemies with the Green party, that are now inside the government together with the Social Democrats.
 
greens?
 
The problem is that the Swedish Democrats voted for the Center-Right budget. So the Left-Center folks didn't get their budget through.
 
2:16 PM
izzat the left center?
 
the greens are in the left-center, yes.
 
@SimonAndréForsberg Ahhh, so, a 'vote of confidence' failed, and the government has a crisis.
 
And our prime minister didn't want to rule the country with a Center-Right budget, hence the chaos.
 
BBC is helping me too, with this.
 
it wasn't exactly a 'vote of confidence', but a budget vote.
The center-right always said that they would vote for their own budget. So because the Swedish Democrats also voted for that budget, that's the budget that got through.
Sorry for the long explanation, I just thought you could get some of the back-story as well.
 
2:18 PM
Isn't the back-story the important part??
2
 
@SimonAndréForsberg Sorry, your governments crisis is not important enough for the Dutch news :(
 
It makes sense. In Canada, there are a few types of votes that are called 'confidence votes', items that need to be passed in order for a govenrment to maintain control. One of them is the budget. If there's no budget, there's no money, and no government.
 
So, our prime minister has said that there will be a new election, on March 22nd.
 
@rolfl Over here we always have money, no matter what crisis, for some reason
 
@rolfl I guess that effectively, you could call the budget vote a 'confidence vote' here as well, considering the implications of a government not getting their budget through.
 
2:22 PM
I think the national budget over here is kind-of confirmed right after the elections once the government gets formed
 
OK, what I see as the interesting news in that (because, frankly, it's fairly routine otherwise), is that the far-rights voted out of spite, it seems, and that Sweden has blanket immigration 'open doors' for Syrian refugees..... odd.
 
@skiwi if there is a majority government, that's often the case here as well. Swedish governments tends to be minority ones though.
@rolfl The Swedish Democrats said that they would never vote for a budget that gives more money to immigration.
 
The BBC says 2000 syrian refugees enter each week, that's interesting for two reasons... one, that's a very 'hot' issue to have as a Government, and the other is that so many Syrians will go to such a cold place ... ;-)
 
It will be interesting to see the turn-out of the March elections. Worst-case scenario is that the parliament will look exactly the same.
@rolfl Canada would be colder ;)
 
@rolfl Especially the second point
 
2:25 PM
@SimonAndréForsberg thanks to the golf stream eh?
 
<3 Gulf Stream!
 
Both Canada and South Africa are built on a policy of immigration.... It can work well (see Canada), but it's hard to get right.
 
A possible problem in Swedish politics is that the Swedish Democrats are often seen as "racist", and not many politicians seem to openly debate with them and talk about the actual issues, so the Swedish Democrats gets to play the victim card, which apparently seems to give them more votes. (this is my view of the situation)
I am not a Swedish Democrat, and would never be one, but ignoring them doesn't seem to solve reduce the votes they get.
 
0
Q: Which is better code (more readable) and why?

WalkmanThe first version contains less lines, one statement and a simple tuple: def open_error_files1(path, logfile): """Open error files for writing and return a dict. Keys are error types, values are opened files based on log filename.""" error_types = ('ip', 'data', 'json', 'time', 'base...

0
Q: Optimizing Powershell loop

GiantDuckIs there anything I can do to this code to optimize it to use less resources? Thank you! write-host (get-date -format s) " Beginning script..." Add-Type -AssemblyName System.Windows.Forms do{ $len = [System.Windows.Forms.Screen]::AllScreens.Length; if($len-eq1){ $ie = Get-Process...

 
Greetings, Programs.
 
2:33 PM
Hello, @Donald.McLean.
 
Greetings, Sir @Donald.McLean
@rolfl remember when I was talking about the code with the nested Try-catch? both catches catch SqlException
should this be migrated to Super User?
1
Q: Optimizing Powershell loop

GiantDuckIs there anything I can do to this code to optimize it to use less resources? Thank you! write-host (get-date -format s) " Beginning script..." Add-Type -AssemblyName System.Windows.Forms do{ $len = [System.Windows.Forms.Screen]::AllScreens.Length; if($len-eq1){ $ie = Get-Process...

Delete Please
-2
A: Checking if multiple user-entered numbers are in the right range

bobpoo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo poo

 
@Malachi that's not "delete please", that's abusive
 
@Vogel612 I already flagged it.
 
no downvotes / delvotes required then...
 
2:43 PM
Delete votes doesn't hurt as well
 
the community should delete it and let the mods handle the spam/abuse flag
 
I flagged, downvoted, and delete-voted
And @Malachi starred.
 
what is a "TLE verdict" in C++?
 
0
Q: Acceptable method for conditionally including a python dependency in setup.py

JonlineI have a small project that requires a third-party module that's rarely updated (once every other year or so) and not maintained by any package management system. The context, here, is cognitive science & research, the module is for linking proprietary hardware to custom scripting. Can anyone p...

 
@SimonAndréForsberg oh yeah
 
2:46 PM
@SimonAndréForsberg yes they do...
 
@Malachi Deleted.
 
@Vogel612 why/how?
 
@Pimgd saw that thank you
 
@SimonAndréForsberg for one, they are wasted on this after flagging (both downvotes and deletevotes) and won't be refunded.
and for two, they aren't helping in determining how many flags are still needed to community♦ nuke a post
 
@Vogel612 I don't think that's entirely correct.
@Vogel612 6 spam flags IIRC.
 
2:48 PM
@SimonAndréForsberg same goes for offensives
they work exactly the same way ;)
 
3:08 PM
-1
Q: Asking for a suggestion: partially obscure the source code

ReviousI'd like to ask question related to some source code here but every time I have to think: "what would happen if a colleague would see it and say: what have you done???? I guess it could be hard to explain to a manager that the name of the columns of a database is not stealing the source code" :D ...

 
@Malachi what the hell happened to that question ?
 
@JaDogg got deleted
 
Oh right It was a crazy answer, LOL, We are so famous now we get vandalized, nice or not nice. :p
 
@Phrancis Hello, Phrancis Hello World.
I read that question title as I would read someone's name when it's in LastName, FirstName format
 
3:21 PM
@Malachi Time Limit Exceeded - too slow (wrong algorithm).
 
0
Q: how to call android's drawLine()

New2Androidbase on the this app : https://github.com/valerio-bozzolan/AcrylicPaint/blob/master/src/anupam/acrylic/EasyPaint.java i want to add another item in the menu, which is drawing a line. I'm new to android, so please don't judge me :) here's my attempt: public boolean onTouch(View v, MotionEvent ev...

0
Q: Extracting information from .txt with fgets

hysteriaisticI'm writing code that extracts text from a .txt document and I'm having trouble with an fgets statement. fgets(lineOfText, 100, textFile); When I print lineOfText it seems to omit the first letter of the textfile. For example if the text I want to extract is: StackExchange is great! It will...

 
@Pimgd careful with that guy you answered on meta. He is known for starting strange discussions... If you think he's that certain kind of person, disengage and flag :)
 
2
Q: Recycling Internet Explorer

GiantDuckIs there anything I can do to this code to optimize it to use less resources? write-host (get-date -format s) " Beginning script..." Add-Type -AssemblyName System.Windows.Forms do{ $len = [System.Windows.Forms.Screen]::AllScreens.Length; if($len-eq1){ $ie = Get-Process -Name iexp...

^^^ better title.
@Malachi So? That often makes sense in the case of close-cleanup.
@SimonAndréForsberg and I destroyed .... ho ho ho!
 
3:38 PM
hiya~
 
Hey Alex, long time ;-)
 
0
Q: Segment Tree Implementation in C++

NamsI have been trying to implement segment tree to find sum of a given range.It is also required to update the segment tree.I am trying to solve this problem. http://lightoj.com/volume_showproblem.php?problem=1112 As mentioned n<1000000 and q<50000.So I think segment tree which have a complexity o...

 
@rolfl yeah, I've been busy playing games working very hard
4
I have some time on my hands now so I thought about dropping by to see if there's stuff I can review
 
Plenty ;-) We are also ramping up for a quick community challenge, if you are inspired by that sort of thing.
 
1
Q: "event_foo" method event system in D

Colonel Thirty TwoThe goal is to be able to call a method event_<name> method on an object if it implements it, or otherwise do nothing, without needing to explicitly define and implement an interface for every event. The object may also forward the event to any sub-objects it has. Here is my current code: modul...

 
3:54 PM
Welcome to Code Review! This looks like example code, class Foo, obj.event!"test"();, etc. Could you post your actual code? — Phrancis 16 secs ago
 
Ooohhh, got a hello-world accept ;-) thanks Santa ( @Phrancis )
 
In the end, all the answers seemed good, but yours seemed the most thorough and had the most votes :)
2
I have yet to put in the changes because BTW.Work but I'm hoping to rework it today
 
@rolfl I'll take a look
 
4:15 PM
0
Q: Fill an array of objects with some default object

JazminI have an array of objects. Whatever may be the size of this array, I need to ensure the size of the array as n using a default object. function fillRemaining(arr, n) { var defaultObject = {'id' : 0, 'name' : ''}; var temp = 0; while(arr.length + temp < n ) { ...

 
4:29 PM
0
Q: Refactoring IEnumerable<ValidationResult>

DreamBigI have the below code which increases the code complexity. Any way to refactor it? I am trying to refactor the below code so that the CCM can be reduced for the code. i.e code complexity matrix //// TODO: Needs refactoring public IEnumerable<ValidationResult> Validate(ValidationContext vali...

 
hi
 
hello
 
I was wondering ....
coding sad crying faces ); all over your code, does affect your mood? Did you even notice ? Do you think will be great if we code more like : var something = DoSomething(; instead of DoSomething(); ?
 
lol I noticed that too!
@Bart You should look into LOLCODE if you want code that makes you feel happy ;-)
 
didn't ever heard about lolcode... let's see
 
4:34 PM
@Bart usually I put my smileys eyes on the left hand side..
); <-- not a smiley
 
54
Q: Down with FizzBuzz... LOL

Mat's MugThis post is the result of reading through and following the LOLCODE Specification 1.2, and writing and executing my code on compileonline.com. My "hello world" was going to be a fizzbuzz. I like it because it nicely illustrates the basics of a language - variables, operators, looping, condition...

^^ @Bart
 
@Bart The unclosed braces would make me hyperventilate
2
 
lol, LOLCODE doesn't look that happy after all...
;( <-- this is not crying ? how do you make a crying face @Vogel612 ?
 
:_:
;_;
T.T
 
:`(
 
4:36 PM
you are so pro ...
damn ... wish I had that style. now I can't stop seeing faces crying all over my code
it makes me sad
 
that's just winking face in saddened.
;)
 
did this guy edit his q to remove all of his code?
3
Q: PHP OOP calculator form

Freddy15I aim to improve my PHP OOP skills and made a simple calculator. Visitors can choose 2 numbers and a prefix, so they can add, subtract, divide and so forth. The output is the sum. The good thing is it's working, but is it also clean coding? Also, is it wise to use the switch statement in a functi...

 
@AlexM. He had. I rolled it back.
 
glad I can share with you, it's so depressing to handle it by myself :D
 
I'm not sure why you had removed all your code from the question. I rolled back your edit. If you wish to remove the code you should delete your question instead. — Phrancis 16 secs ago
^^ Is this a good response?
 
4:48 PM
@Vogel612 uses asian emoticons, the others are western-style
asian ones revolve around the eyes, western ones around the mouth
 
@Phrancis no, beause it's mostly... wrong.
if he wants to remove the code for real, then he better file a DMCA Takedown
 
Ah ok. I deleted the comment, thanks for clarifying
 
if not, he hasn't got the right to remove the code (and the question) as per the license agreement.
 
I'm not sure why you deleted your code from your question. I rolled back your edit, as it would make your question off-topic, as well as invalidate the answers. — Phrancis 6 secs ago
^^ Better?
 
wonderful ;)
 
4:52 PM
Awesome. Learn new things about this site everyday.
 
5:21 PM
0
Q: Java Quicksort. Partition method

Panagiotis PavlatosMy exercise is to write a partition method for the Quicksort class below. I want to know if the qsort code is correct. Can you help me please?? I believe that there's a problem on the qsort code (nb=n-na-1). public class QuickSort { public static void main(String args[]) throws FileNot...

 
5:32 PM
member for: 1 year, 1 month     visited: 400 days, 400 consecutive
 
yes.. definitely the DoD ;)
 
0
Q: First markup ever using html five

DEdesigns57This is my first website. I would like to make sure I am using the HTML5 markup correctly and if you have any advice I would really appreciate it. Heres the code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>DEdesigns</title> <script...

 
6:03 PM
0
Q: Multiple CSVHelpers from one file. Split up a file into separate memory streams based on delimiting blank lines

Nathan CooperI need to get multiple CsvHelpers from one file, separated by spaces. Here is my file: Code,Scheme 12,Scheme1 Event,DateTime SENT,2013-09-27T00:00:00Z RECIEVED,2013-09-27T00:00:02Z To get multiple CsvHelpers I believe I need to get multiple Streams from the file. Below is...

 
6:17 PM
1
Q: How can I make this C# code run faster?

BobI am looping through this code 18411 times, it takes about 1 second to run the method. So (18411/60)/60 = 5.11416667 -> about 5 hours and six minutes. I was wondering if anyone had any ideas of how to speed this up I need to get back my array of data in order. Any ideas for multithreading or link...

0
Q: N-ary tree bad design?

user15992I want to convince a friend of mine, that he designed an N-ary Tree very poorly, and with this design he will face problems. Due to lack of experience in complex projects from my side -- I can't convince him with my arguments. template <typename T> class Tree { private: T data; vector<...

 
2 more performance votes for another badge! codereview.stackexchange.com/search?q=user:18427+[performance]
 
I like how the csv helpers question states "Obviously it works", but it doesn't :P
 
6:31 PM
okay, now that I have a couple of new answers out there, I need to finish my tasks for the day! LOL
 
-1
Q: Code organization when using threads

MikeFrom OOP & OOD point of view, is it good idea to define Java-threads inside of the static method? Or in this case it's better to use instance-based method. public class A { public static void test(...) { Thread t; t = new Thread(new SomeClass(...)); t.start(); } }...

 
okay so I gave another answer.
anyone want to double check my C# work?
0
A: How can I make this C# code run faster?

MalachiYou have a lot going on in this little bit of code that doesn't need to happen. Like the StringBuilder. Get rid of that for (int i = 0; i < InterpolatedXLength; i++) { InterpolatedXPoint = InterpolatedX[i]; InterpolatedYPoint = InterpolatedY[i]; double BobInterpolatedValue = BobIn...

 
6:54 PM
@Malachi You mean, we need answerreview.stackexchange.com ?
 
I replaced pseudo code with the real one. computeSentiment calls the static method of forked version of StanfordCoreNLP which is a big separate project. — Mike 1 min ago
 
@skiwi that's not a real site....
 
Hey all.
Has the style sheet for code review changed recently? The formatting for code blocks is not looking as nice as before I was wondering if it was my browser screwing up or something intrinsic on the site has changed.
 
@LokiAstari what do you mean by formatting? I didn't see anything new, though a pilot redesign seems to be on mso...
 
0
Q: Additional information expressed through comments

MagusToday, I was browsing CR and saw a comment on this answer suggesting that "" in C# is always better than string.Empty. I responded that the latter is in fact less ambiguous, with reasons. The person I had responded to lashed out at my examples, and the thread was moved to chat. This part is fine,...

 
7:09 PM
0
Q: Basic multiplication in C by changing starting code

sydwys8I need to take the following code and replace the calls using mpz_ with my own code. void Product32(void *a, void *b, void *c, unsigned int wa, unsigned int ba, unsigned int wb, unsigned int bb, unsigned int *wc, unsigned int *bc){ mpz_t x,y,z; mpz_init(x); mpz_init(y); mpz_init(z); /...

0
Q: Obj-C wrapper for OpenLDAP

piccianoThis section of code reside in a utility class. It's purpose is to subscribe or unsubscribe a user from an LDAP group. My main questions are if I am using the LDAP library correctly and if I am handling the memory management correctly. + (BOOL)addUser:(const char *)userDN toGroup:(const char *)g...

 
-1
Q: I'm not sure what the error is here

MonstarulesWhile working on my java card game, I'm not getting detections for "Flushes". The other detectors in the method work, but the flush one doesn't, even if I set the suit array to just one suit. I debugged it by printing out the values of the cs1, cs2, fs1, fs2 and fs3. When all the suits match, eve...

if(cv1.equals(cv2) || cv1.equals(fv2) || cv1.equals(fv2) || cv1.equals(fv3) || cv2.equals(fv1) || cv2.equals(fv2) || cv2.equals(fv3) || fv1.equals(fv2)|| fv1.equals(fv3) || fv2.equals(fv3)) {
            if(cv1.equals(cv2) && cv1.equals(fv1) || cv1.equals(cv2) && cv1.equals(fv2) || cv1.equals(cv2) && cv1.equals(fv3) || cv1.equals(fv1) && cv1.equals(fv2) || cv1.equals(fv2) && cv1.equals(fv3) || cv2.equals(fv1) && fv1.equals(fv2) || cv2.equals(fv2) && fv2.equals(fv3) || fv1.equals(fv2) && fv2.equals(fv3)) {
 
now who would've thought this doesn't work
 
@JeroenVannevel That's just crazy.
 
that last first post review was kind of hard.....
sorry just saw this
0
A: Memes related to The Mission

MalachiCreate a new Meme Post for a new Era! Lock the Pre-Graduation post and create a new post for new memes (link back to the veteran memes)

 
7:39 PM
I approved this Edit...assuming it is the friend that wrote the code....
figured the OP could rollback....?
 
0
Q: Getting Spotify Metadata and Sending it via Bluetooth

mattdondersThe Spotify for Android application does not support metadata over Bluetooth (to my car at least) so I was looking to build a helper application to detect when the metadata changed in the Spotify App and send it via A2DP / AVRCP. Just want to make sure my broadcast receiver is being registered c...

 
@Donald.McLean so beautifull ..
 
00:00 - 20:0020:00 - 00:00

« first day (579 days earlier)      last day (3455 days later) »