« first day (1332 days earlier)      last day (2683 days later) » 
00:00 - 22:0022:00 - 00:00

12:00 AM
RELOAD! There are 3242 unanswered questions (91.9681% answered)
 
Well you have to update the UI thread. Can't just grab any thread you want
seems like that's a really sensible solution
They use that same pattern in WinRT as well: stackoverflow.com/a/24997047/1864167
 
This basically is WinRT.
It's just the upgraded version of it.
 
0
Q: json pretty print

Lin MaHere is my simple program to pretty print json object. Written in Python 2.7. Looking for advice of (1) better pretty print solutions, (2) functional bugs, code style and algorithm time/space complexity improvements. BTW, I have fixed all PEB8 issues I met with using Pycharm auto-annotation feat...

 
12:16 AM
Hmm interesting how C "wraps around" the bit width, rather than causing an error
#include <stdio.h>

// limiting the width to 3 bits allows only numbers from 0-7
struct {
	unsigned int n : 3;
} ThreeBits;

int main(int argc, char **argv) {
	printf("sizeof(ThreeBits): %d\n", sizeof(ThreeBits));
	ThreeBits.n = 4;
	printf("ThreeBits.n assigned 4: %d\n", ThreeBits.n); // 4
	ThreeBits.n = 7;
	printf("ThreeBits.n assigned 7: %d\n", ThreeBits.n); // 7
	ThreeBits.n = 8;
	printf("ThreeBits.n assigned 8: %d\n", ThreeBits.n); // 0
	ThreeBits.n = 10;
	printf("ThreeBits.n assigned 10: %d\n", ThreeBits.n); // 2
 
@Hosch250 I got curious...
0
Q: What happened on December 9 and 10, 2016?

EBrownSo I periodically grab data from the API and publicly report the statistics (according to this question I'm allowed to do that) and I noticed a really bizarre inconsistency with my graphs, but it was consistent across multiple sites. On December 9, 2016 at 00:03:08UTC the Software Engineering si...

 
Not sure if it's a quirk or something desirable
 
possible answer invalidation by Tolani Jaiye-Tikolo on question by benz: codereview.stackexchange.com/posts/150673/revisions
 
@Duga it's fine, just removed a blank line
 
overflow is default behaviour in the C family
 
12:27 AM
0
Q: Simon says in Unity

denisI've made the Simon says game in Unity You start by guessing a pattern of 3 colors and each time you complete the pattern a new, random one, is generated and the length of the pattern is incremented by 1. The game utilises a custom generic collection I wrote CircularListNavigator<T>. I also ...

 
 
1 hour later…
1:34 AM
Guess what I just spent two hours at?
Trying to get a combo box value to populate the UI the first time I loaded the window, when the SelectedItem binding was above the ItemsSource binding.
 
@Hosch250 Got answered.
1
A: What happened on December 9 and 10, 2016?

animusonRoomba was modified that weekend to add new criteria. When migrations were rejected, we used to just leave them sitting around for all of time. Now those locked, rejected migration stubs get automatically deleted in the same way that the initial migration stubs get deleted from the origin site. T...

 
Interesting, but I didn't care that much about it.
 
I do. It totally borked my graphs, man.
 
LOL.
Anyway, I answered a question today. It went hot, and I have the top answer at 3 votes.
Talk about SE being slow...
OK, now I need to write a selfie on SO.
 
Yeah, it happens. Lol
That answer also explains why we were unaffected.
We don't really have a lot of those types of questions.
In fact, we don't have a lot of migrations at all.
 
1:42 AM
@EBrown Do you know how to specify languages in an SE post?
 
Yeah, <!-- language: lang-LANGUAGE --> IIRC.
Put that before your code block but not formatted as a code block.
 
OMG someone got me a Tetris Light as a present woot!
 
See also:
266
Q: Syntax highlighting language hints

Rowland ShawDo you think it would be worthwhile to provide hints as to what language to use for the syntax highlighting? Sometimes I find the highlighting on SQL or VB.NET answers is more distracting than helpful; for example: Converting MySQL select to PostgreSQL Retrieving data from a VB.NET arraylist o...

 
possible answer invalidation by Jamal on question by Lykos: codereview.stackexchange.com/posts/144435/revisions
 
Selfie posted:
0
Q: Combobox Binding Not Updating

Hosch250I have the following ComboBox: <ComboBox SelectedItem="{Binding SelectedTheme, Mode=TwoWay}" ItemsSource="{Binding Themes}" /> It is bound to the following values in my VM: private Theme _selectedTheme; public Theme SelectedTheme { get { return _selectedTheme; } set { ...

 
2:02 AM
@Hosch250 Personally I probably would have VTC'd as "Lack of research effort" but in this case I +1'd both.
If I didn't know you though, VTC would have come in.
 
@EBrown Why? I certainly looked long enough, and I did solve my question before posting.
I couldn't find an equivalent on SO, or I wouldn't have posted.
 
2:16 AM
Killed a couple of my old SO posts, and flagged another as offtopic/simple typo.
Hope I don't get banned, but if I do, I probably won't be asking for anything there for a long time anyway.
 
2:29 AM
make the title more informative
e.g. add 'despite setting SelectedItem and ItemsSource', for example
 
0
Q: Tree abstraction - Code structure

overexchangeBelow code provides Tree abstraction. Would like to finalize the code skeleton in tree directory, before implementation, because there are multiple conditional compilations, written at function level. Code is compiled & linked successfully. /code $ ls -LR .: list testList.c testTree.c tree...

 
Uh that's strange
int main(int argc, char **argv) {
	// get and put a single character:
	int c;
	printf("Enter a character: ");
	c = getchar();
	printf("\nYou entered: ");
	putchar(c);

	// get and put a string of characters:
	char str[128];
	printf("\nEnter a string: ");
	gets(str);
	printf("\nYou entered: ");
	puts(str);

	return 0;
}
C:\Scripts\C>input-output
Enter a character: h

You entered: h
Enter a string:
You entered:

C:\Scripts\C>
When I compile this it appears to skip the gets() and puts() calls. But if I comment out the first portion with the getchar() and putchar(), and compile&run like that then the gets() and puts() work fine
 
@tuple_cat I have done the changes, as you recommend, shown hereoverexchange 23 secs ago
 
2:48 AM
@Phrancis try consuming the newline character inbetween
 
@JeroenVannevel Good thinking, that fixed the issue, thank you!
 
3:33 AM
0
Q: Maximize profit on a trade route

PaparazziFixed trade route with goods and prices and fixed cargo capacity How to optimize profit This is just a single pass starting with an empty vessel It does a semi brute force on all possible trades test Int32[,] portsProducts = new Int32[,] { { 1, 1, 1 }, { 2, 1, 1 }, { 4, 2, 3 } }; Int32[,] a...

 
4:01 AM
0
Q: Injecting stereotypical role implementations by IoC container

Dmitry NoginI am trying to define a plug and play architecture which leverages stereotypical role implementations (Validator, Reader, Writer, Logger, Query, etc) by automatically instantiating associated services through a very limited use of Service Locator. Demo code: let’s say we have a query object to ...

 
Needs to go to code review — Gurwinder Singh 34 secs ago
 
4:25 AM
I got a very strange present today. It was a tiny package, smaller than a deck of cards, and weighed practically nothing. When I opened it up, I found a packet of Cheese & Bacon flavored... crickets!
I ate one, it wasn't bad, but wasn't great either. Definitely unique. The flavor reminds me almost of grass, and the texture was quite fibrous and slightly crunchy
 
4:40 AM
0
Q: C# Quick Sort Implementation

DyaRi BaRzaniWhat is the Problem ? stack over flow is thrown when my code has an infinite recursive loop. Check my stopping conditions. Do you have any Idea ? static void Main(string[] args) { int[] a = { 3, 4, 1, 6, 7, 8, 2, 5 }; int[] R = Quick(a); foreach (int item in R) ...

 
4:51 AM
0
Q: Java SQL JTable, my first project, how can i simplify my code any suggestions

Em AslamI am studying java for 4 months and this project is what i came up with, i know i should make more classes and methods for quality but i am still learning. Please help to me if there is any simpler and cleaner ways to achieve the same results as this. thank you. import java.awt.FlowLayout; impor...

 
@RMunroe LOL
 
5:21 AM
0
Q: Substitute for `std::array::operator[]` in C++11 by using template-based recursion

Flávio LisbôaWhat follows is a simplified version of a tentative implementation for a template-based set, named TemplateArgs. For the sake of clarity and focus on the question at hand, TemplateArgs was converted into a non-parameterized class, and its size and elements are hard-coded. It should be C++11-compl...

0
Q: Unable to upload asynchronously to my webserver using Ajax

timmackI'm wondering if anybody here has experienced this type of issue in which after your website has been deployed to a webhost server, it is not anymore able to upload files asynchronously to the web server using Ajax request but it works fine in a local machine. Here's my Ajax script below for furt...

 
@CaptainObvious this is scary stuff...
        JButton btnUpdate = new JButton("UPDATE");
        btnUpdate.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                String sql_stmt3 = "UPDATE employees SET full_name = '" + txtName.getText() + "'";
                sql_stmt3 += ",gender = '" + txtGender.getText() + "'";
                sql_stmt3 += ",department = '" + txtDep.getText() + "'";
                sql_stmt3 += ",position = '" + txtPosition.getText() + "'";
                sql_stmt3 += ",salary = '" + txtSalary.getText() + "'";
If I entered the name Bobby'; DROP TABLE employees;-- I think it would be bad ;-)
 
@PaulHankin thank you I never had heard of codereview before. I'll be sure to use that next time. — Vik 13 secs ago
 
@CaptainObvious sounds like broken code
 
5:43 AM
0
Q: Handling signout flow

BarabasThere is backend which connects with IdentityServer using WsFederation. Backend is dotnet core project where there is derived class from AuthenticationHandler. The issue is when the time of user's token is expired, the user should be signed out. I've implemented this in the following way: ...

 
5:56 AM
Error "handling" in C looks difficult
Did I read somewhere that exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) are not good practice?
 
6:30 AM
 
7:18 AM
It is unclear to me whether this code works correctly or not. Only working code is allowed on Code Review site. If it is not working, then you should specify the problem(s) here on Stack Overflow. — Phrancis just now
 
0
Q: Connecting database and exe query

Alex13I have been trying to create encapsulated class with three methods update, insert and delete from my base where my data is stored. I use these buttons because in other class there is form and user input is supposed to be written in my base. I also want my insert to return ID because it is necessa...

 
@CaptainObvious dat code formatting though, man
 
7:36 AM
TTGTB
 
8:26 AM
0
Q: Jesse and Cookies

CodeYogiJesse loves cookies. He wants the sweetness of all his cookies to be greater than value K. To do this, Jesse repeatedly mixes two cookies with the least sweetness. He creates a special combined cookie with: sweetness = (1 * Least sweet cookie + 1 * 2nd least sweet cookie). He repeats this pr...

 
 
2 hours later…
9:59 AM
Also this is more like a code review. — Jeroen van Langen 40 secs ago
 
10:33 AM
0
Q: Java: Double Linked List which uses a dummy element as zero element

mizechI have to implement a double linked list as an exercise for a further education. There are three interfaces which have to be implemented: IValueElement package schnittstellen; // schnittstellen == interfaces public interface IValueElement { public String getName(); public void setName...

 
10:50 AM
1
A: Probability distribution of two different probabilities

Glen_b[While this is indeed a special case of the Poisson-Binomial I wouldn't approach it that way; it's more general than you want in this case.] Let $X_6$ be the number of $1$'s on $n$ six-sided dice. Let $X_8$ be the number of $1$'s on $m$ eight-sided dice. Assume the results on each die are indep...

I've got my answer... Now the next part is trying to understand it
 
11:11 AM
If you're code is working correctly you might want to try Code Review. — José Sánchez 15 secs ago
 
@skiwi That's the best part, the part where you learn something.
 
11:31 AM
@Phrancis A signed decimal integer. You wanted an f instead of a d.
While this is a C++ reference, the table should also work for C.
 
11:45 AM
possible answer invalidation by Greg01re on question by Greg01re: codereview.stackexchange.com/posts/150822/revisions
@AlexHall is there no way to check whether it exists or not? My plan was to later do something like event.alert is not None? I am going to put this onto codereview.SE though, I really need to learn how to Python. — theonlygusti 1 min ago
 
11:58 AM
0
Q: Representation of a calendar event

theonlygusticlass CalendarEvent: """Represents a macOS calendar event.""" __allowed_properties = ["name", "location", "starts", "ends", "repeat", "end_repeat", "travel_time", "alert", "notes", "invitees"] def __init__(self, **keyword_arguments): for key, value in keyword_arguments.items(...

 
12:32 PM
It's astonishing how little the most-often used words in a book tell you about the book.
'the': 292, 'and': 264, 'of': 187, 'to': 152, 'a': 97, 'or': 86, '\xc2\xa0': 85, 'in': 84, 'on': 81, 'that': 68, 'The': 59, 'as': 58, 'is': 52, 'be': 51, 'will': 46, 'for': 44, 'are': 42, 'an': 40, 'by': 39, '\xef\x82\xb7': 37, 'reports': 35, 'NOC': 35, 'media': 33, 'o': 31, 'with': 28, 'other': 28, 'MMC': 27, 'information': 26, 'not': 24, 'have': 23
 
Monking v2
 
Only after that does it get slightly interesting.
@skiwi Monking!
 
Any cool stuff today?
Thanks for the edit . [BTW]
How did I write dies instead of dice... lol
 
Np.
 
You get a die, and you get a die and you get a die and everyone dies!
2
 
12:35 PM
'0.000': 128, 'the': 83, 'of': 57, '..': 35, 'is': 27, 'to': 25, 'and': 25, '\xe2\x86\x91': 24, '-': 22, 'Keep': 21, 'a': 20, 'are': 20, 'each': 19, '350.000': 17, 'all': 16, 'The': 16, 'A': 15, 'that': 15, 'elected': 14, '4': 14, 'in': 13, 'Meek': 12, '->': 12, 'B': 12, 'candidates': 12, 'Value': 12, 'they': 11, 'Elected': 11, 'C': 11, 'G': 11, 'Hopeful': 11, '|': 10, '1.00000': 10, '284.000': 10, 'D': 10, 'for': 10, 'be': 10, 'E': 10, 'F': 9, 'Excluded': 9
 
0.000?
 
@skiwi Must have been in a table somewhere, a lot.
@skiwi Cool? No. Hacky? A lot.
# The following might throw a PDFTextExtractionNotAllowed exception.
# Lacking a method to handle this specific exception all are caught.
try:
    for page in PDFPage.get_pages(infile, pagenums):
        interpreter.process_page(page)
except Exception, e:
    print "Extraction not allowed:\n%s" % e
    print "Process %s manually." % fname
 
I probably need to find a better way to do that.
Hi @Hassan
 
You guys review "English" Language?
The best programming language.
:]
 
12:39 PM
@Mast Possibly hacky
 
@HassanAlthaf We review all programming languages with a compiler or interpreter available.
 
How would I write "STILL NOT CONVINCED? I AM SURE YOU WILL AFTER READING MY TESTIMONIALS." in a fewer words?
 
Try losing some caps.
 
Hmm @Mast, I assume you read that stats question of mine, is that sum simply going from max(0, k - m) to min(n, k) and that's all there is to it?
 
If you're looking for fewer words, you might be interested in CodeGolf.
 
12:43 PM
0
Q: Classes for Facebook graph API

Vladimir Costa de AlencarI tried to run this Facebook API: import simplejson as json import urllib class Facebook (): def __init__ (self, access_token): self.access_token = access_token self.id = None self.name = None def user_information (self, fbuser = "me"): """ returns User Information ; fbuser c...

 
Not necessarily fewer.
More efficient.
Which, I believe is a part of CodeReview
Just kidding.
 
@skiwi I read it, but that's about it. I'm not really a stats guy.
 
Wanted to see some reactions
 
@Mast I'm more on about the maths part, it's just that it looks really simple to me, except I couldn't have figured this on my own :P
Actually, what he wrote down is exactly the case distinction I was thinking about earlier, but now it's in fancy typesetting and it's solved for P(x = k) instead of P(x >= k) which I was trying to solve originally, but the conversion from P(x >= k) to P(x = k) elements is trivial
 
So you're a happy man now :-)
 
1:01 PM
Yes, and now for Christmas I'd like a fully implemented program :)
 
lol
 
1:47 PM
monking
 
Monking @Vogel612
 
0
Q: Left rotate array

iLiveInAPineappleUnderTheSeaI'm trying to do circular left rotate an array. I get the expected answer but the website shows I'm wrong. Also, I don't know if this is very efficient and some large test cases timed out. What I've done: I create a new array, add elements of the input array into it from its second element. Then...

 
2:06 PM
0
Q: Mini RPG equipment code

wdsawhat do you think about this code? It's upgraded version of: Classes representing items in an RPG game using System; using System.Collections.Generic; public class Item { public string Name { get; protected set; } public int Cost { get; protected set; } public override string ToSt...

 
@CaptainObvious Hammertime
 
2:20 PM
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Basic web scrape project written in NodeJS
 
2:31 PM
0
Q: Follow up: AT&T assembly - Basic loop & write

Greg01reThis is a follow-up question to this one: AT&T Assembly - Basic loop & write The code loops to display "Hello, World!" ten times. I implemented the syscall instead of int $0x80, used a decrementing loop to avoid a useless instruction and commented the code. Is there any way to make it better? ...

 
2:42 PM
-1
Q: Class refactoring

NarayanaI have an C# class library that builds a network graph by reading some stored procedures, building basic entities (nodes, edges etc) and then runs many algorithms and does lots of computations on them (including some simulations). There are many levels of edges (let's say L1, L2, L3), each defini...

 
Monking!
 
Monking @Phrancis
looking for a game that doesn't make me ragequit
Dark Souls
 
@skiwi tetris?
 
@Vogel612 You underestimate my abilities
 
Knights of the Old Republic?
 
2:50 PM
That's a looooooooong time since I played that, at a friend probably :P
This is the issue if you like mostly competitive games :P
 
@CaptainObvious VTC, example code.
 
Putting strictly competitive games aside and also ignoring single player games there isn't a whole lot of things remaining though
 
Multi-player RollerCoasterTycoon?
UTTT?
What genre are you looking for anyway?
 
I do have OpenRCT2 :) But not really feeling that either :P
@Mast Not sure, I can consider anything, would like an mmorpg the most but these days it's difficult
 
0
Q: Long If statement to select correct Enum value in a String

VahxI have written a small function that will check a string to see if it contains a certain word. Depending on the word that is found first, the function will return the correct Enum value that needs to be used further down the line of the program. Would there be a better way to check a string to ...

 
3:00 PM
Wow.. Dark Souls has a coop mode, I didn't know that
Though I feel like I may lose more friends over that than it's worth :P
 
@skiwi tehee ... "coop" mode.
 
Co-op usually feels like cheating though.
In games like Saints Row 3 & 4, co-op makes you nigh invincible.
Did you know Knights & Merchants has a multiplayer mode?
 
I don't really mind spending money on games, but it sucks if you keep doing it and don't find one you like
 
You've already tried Guild Wars 2, right?
 
Looks like Paladins is worth a try, never heard of it but it's made by Hi-Rez Studios so I've got hope
@Mast Yep, although it was a long time ago, I didn't really like gear/end-game system though
 
3:06 PM
Paladins was fun for a while, but they had server issues large enough to make the game lag like heck. So I quit.
 
Right now I've just got too much free time, and next month once I'll have the job I'll be short on time :D
 
hrngh. ... nothing more frustrating to just have to put things into working state and being called away for food unrelentlessly
 
At least you've got food
 
Nothing wrong with food, except when it gets in the way of progress.
 
With food you can refill your energy to work twice as fast afterwards
 
3:10 PM
TTGTW
 
Work? Oh, right. The muricans don't have 2nd Christmas.
 
1
Q: Snake game in Unity

denisI've made a simple snake game in Unity and it has 3 different types of foods. Note - 5 blocks = 1 point This is a screenshot from the game here I'm colliding with myself and the game is restarted after that. As you can see the snake has a highlighted head (the light green block) and it consis...

 
@Mast heard in the radio: 'second christmas is when the whole German nation is collectively in a coma on the sofa watching Sissi movies'
2
 
3:33 PM
0
Q: Java primitive data types quiz

Fane FonsekaI've created a little text based game in the console. the game randomly chooses two primitive data types and the user is asked to pick which has the larger memory allocation. I've tried to use TDD to create this application however I have noticed places where I may have tried to do too much at on...

 
@Mast It's an interesting game for sure, though the tutorial was a bit lacking
And after my first Casual match I just realized it was vs AI... Skill crushed
And in the "Match Ready" screen I was waiting a long time until that last player would finally ready up, then I figured it was me :D
 
4:20 PM
1
Q: A JavaScript implementation of the Python's range() function

GothdoRecently I implemented the Python's range() function in JavaScript. The function has three parameters: start, stop and step. The range includes elements from start and up to, but not including stop. The step parameter defaults to 1 and specifies the distance between two elements. It uses Proxy (...

 
4:43 PM
0
Q: Using namespaces: Aliasing/Importing practices

itsazzadItemPost and ServicePost models are inheriting Post model: namespace App\Models; class Post { } class ItemPost extends Post { } class ServicePost extends Post { } Then which one of the followings is a good or bad practice? And why? namespace App\Http\Controllers; use App\Models\ItemPost as...

 
Since you have a working example, and you are looking to optimise it the code, would it be more suitable for the question to be asked over at CodeReview? — Terry just now
 
5:02 PM
Maybe a C# WPF application isn't that bad
 
@skiwi It's nothing at all.
 
Nothing?
 
0
Q: Synchronised AKKA actor best practice

user_mdaI have the following requirement I need to complete a major task Actor A: Performs the major task, if the message is 'special' it passes it to actor B for processing and then finishes the task Actor B : Performs special logical task for the major task and A and B together complete this A The i...

 
Pretty much.
 
5:06 PM
Nothing what? Sorry, I'm confused
 
Basically, it isn't hard at all.
It takes nothing to do it.
I guess the next step is re-adding the New Game button (Checkers).
I made it so you can change the theme, but that needs a bit of UI work still.
 
I only dislike markup, because I'm terrible at it
@CaptainObvious UWYA?
 
I gained 75 points on SO "today".
 
@skiwi Pseudo-code I think.
 
5:34 PM
12
Q: Other students report that a student faked illness and asked classmates about the final exam before taking a makeup. Is it academic dishonesty?

Jackie WangI am an instructor at an American university. A student of mine, Student H, claimed that he was very sick and had to miss the final exam. Based on my trusting students in general, I allowed Student H to take a make-up exam, which took place about 4 hours after the actual exam finished. About two...

Those comments... someone didn't think something through
 
-1
Q: c++ code that work driveless car using circular linked list

Charwrite a full c++ code that will be implemented on a car that travels without driver.you have to use circular linked list.the car should have the following information: 1.car name 2.car number 3.car color 4.starting time you need to assume that inserting of node means travelling of a car from one ...

 
@CaptainObvious wat.
 
5:58 PM
I'm voting to close this question as off-topic because it's code review — MLavoie 36 secs ago
 
> You should ask a new question if the coffee has changed significantly
s/coffee/code ?
You gave him the same final exam as the rest of the class, even though he took it later??? — ff524 ♦ yesterday
Fail.
 
Does this code work? If yes, your question might be suitable for Code Review. — ForceBru 40 secs ago
 
Naruto answer; accepted non-selfie answer with 0 score: Basic JavaScript counter
 
Agreed should be moved to codereview — Darkchili Slayer 33 secs ago
 
@EBrown Wow, that's pretty long
 
I'm pretty good at that. Lol
 
0
Q: Send arp reuests with libpcap in C

GeorgeGkasI use libpcapto send arp requests. My programming language is C. I just want to make sure that I created the arp packet correctly. I don't know if my code works correctly, but I don't believe this should be posted in stackoverflow. There are mainly two functions I use. First, I call: sendARPRe...

 
I used to have to use the C# compiler/IDE/intellisense to do anything with the language, now I can do most of the simple stuff without even looking at a compiler/IDE.
 
7:07 PM
@EBrown Would you be interested in my latest F# question?
I think parts of it are pretty messy.
 
I can look, might not have much time.
 
Don't worry about doing it right away, it has been up for a while now.
I'd just rather not post a bounty for needing an answer.
 
I'll look later today.
 
Thanks.
 
let internal chooseNewAlpha currentAlpha (candidateAlpha :float Option) =
    match currentAlpha with
    | Some x -> if candidateAlpha.IsSome then Some <| max x candidateAlpha.Value else currentAlpha
    | None -> candidateAlpha

let internal chooseNewBeta currentBeta (candidateBeta :float Option) =
    match currentBeta with
    | Some x -> if candidateBeta.IsSome then Some <| min x candidateBeta.Value else currentBeta
    | None -> candidateBeta
That is ugly.
 
7:11 PM
Reed Copsey said to use ifs when I'm testing a true/false condition.
 
Where?
 
He's one of the top F# people.
In the F# chat on SO.
 
Give one good reason.
 
He said it is cleaner than doing a match and testing against true/false.
 
Because in that case you're testing for a Some / None.
 
7:12 PM
Ah, I see.
OK.
I have a few of those I can change back then.
 
match currentAlpha with
| Some current ->
    match candidateAlpha with
    | Some candidate -> Some <| max current candidate
    | None -> currentAlpha
| None -> candidateAlpha
Better yet, I have another alternative.
match (currentAlpha, candidateAlpha) with
| (Some current, Some candidate) -> Some <| max current candidate
| (current, None) -> current
| (None, candidate) -> candidate
| _ -> None
You might need to modify the second to be (Some current, None) -> Some current and the third to be like that as well.
I don't remember.
But that brings you down to exactly one match.
And the intentions are extremely clear.
I'm putting that in an answer.
 
Wow:
15
A: I'm too cold, turn up the temperature

Rudolf L. JelínekMinecraft 1.9.0+, 204 162 bytes + 58 36 28 24 blocks = 262 240 232 186 blytes Since TNT normally explode after 3.0s in Minecraft, this one has to be placed by a command (/setblock) with a specified fuse. Also uses a more compact design to remove redundant command block (containing 42 bytes) ...

 
@Mast Paladins is surely an interesting game, but a bit too much action in my opinion
 
Want to play UTTT? Very interesting, but not quite as much action.
 
7:29 PM
Not really at le moment
Actually, I don't have the slightest idea of what I want to play :D
 
no there is no way. you cant do magic. but you can post your code at codereview so others can give hint to optimize it — M.kazem Akhgary 15 secs ago
 
@Phrancis What formatting?
 
@Hosch250 Some of your functions can use function composition more to make your code a bit easier to follow.
 
OK.
 
I.e. this one:
let internal isValidHop startCoord endCoord (board :Board) =
    match (square startCoord board).Value.PieceType with
    | PieceType.Checker -> isValidCheckerHop startCoord endCoord board
    | PieceType.King -> isValidKingHop endCoord board
Also, why does isValidKingHop not take a startCoord there?
 
7:46 PM
It doesn't need it.
It just needs to check that the end coordinate is open.
 
let jumpFunc =
    match (square startCoord board).Value.PieceType with
    | PieceType.Checker -> isValidCheckerHop startCoord
    | PieceType.King -> isValidKingHop

jumpFunc endCoord board
That should work for that function.
 
The start coordinate must be valid and have a piece for anything to work, so I do that in the initial isValidMove. Also, I tried offloading it, but it just didn't work out without getting messy.
 
Alright, just wondered.
let internal isValidHop startCoord endCoord (board :Board) =
    let jumpFunc =
        match (square startCoord board).Value.PieceType with
        | PieceType.Checker -> isValidCheckerHop startCoord
        | PieceType.King -> isValidKingHop

    jumpFunc endCoord board
That's what it should look like in the end.
 
8:01 PM
Umm, a Coord List -> Coord List isn't exactly an Option<Move> List.
 
Hmm?
I just updated it, I had it wrong initially.
I still have it wrong, updated again.
And fixed the missing parenthesis.
 
A List<Coord> isn't a List<Move>.
 
Ah I see what you're saying, I can fix that.
I had assumed that your moves list was the right type.
 
-2
Q: OutOfMemoryError: Java heap space for array list

RuwangiI wrote the following java code for an Euler problem: public static void main (String[] args) { int max = 0; int num = 0; int result = 0; List<Integer> num_array = new ArrayList<Integer>(); for (int i = 2; i < 100000; i++) { num = i; num_array.clear(); ...

0
Q: Can i pay someone to optimize this code?

Monerolover1999Im programming illiterate. Anyways, I think this Code has got some intentional junk in there to make it slow. I tried Upwork but upwork totally sucks. Also the jobs board wants like 600 just to post a job...but I'm not like Microsoft or something. I just need someone with talent to fix this code...

 
@CaptainObvious lol nuked
 
8:15 PM
@Hosch250 Should be fixed now.
 
Put parenthesis around head::tail, and it does.
 
This is the problem with writing code without a compiler...lol
@Hosch250 Just got to the Minimax
I'll look at it in a short while.
 
Yeah, that is some evil code.
 
I want to eliminate those mutable's and make it a little cleaner.
 
Me too.
 
8:20 PM
You're not wrong about it being pretty bad looking.
But I think it can be cleaned up pretty easily.
 
Hi @denis
@CaptainObvious Let discussion begin about that question.
2
 
Hello
 
Hi, @denis.
 
I consider this question off-topic since the OP is looking for a fix to a known bug rather than a review
 
what is "this question"?
 
8:25 PM
-3
Q: OutOfMemoryError: Java heap space for array list

RuwangiFor Project Euler 14, Longest Collatz Sequence ("Which starting number, under one million, produces the longest [Collatz Sequence] chain?"), I wrote the following Java code: public static void main (String[] args) { int max = 0; int num = 0; int result = 0; List<Integer> num_arra...

 
@denis He is asking for how to fix a problem with larger numbers. For smaller inputs, the code works.
If he would have an infinite amount of memory and an infinite amount of time, the code would work.
It's an optimization problem, not a bug.
 
Well it's easier to fix that in a smaller program but imagine a huge program connected to a database where some data is overflowing, it's still an optimization problem, but it might require quite some code to be changed turning it into more of a problem solving rather than code improving, don't you think ?
 
huh ... but then you're not discussing the current question ...
don't move this into a question about principles, because that doesn't apply there
 
@denis So let's say if there was 2147483648 rows in the database? Then I'd deal with that question as it comes.
 
Well if this question is on-topic any other questions having a performance bug should be on topic too..
 
8:31 PM
@denis that's a fallacy, IMO. ..
 
My experience is that it is usually pointless to discuss hypothetical questions.
@denis There are many performance-related questions that are on-topic here. See the tags and
 
There are three specific types of "not-working" questions that I think can be on-topic if presented correctly: , StackOverflowException, and 'out-of-memory` errors.
If the code can be demonstrated to work with small input values (up to a reasonable amount, "works on input of 1 but not 2" is not a reasonable amount) then it should be on-topic, as the code does what it intends it is just bad at it.
We're here to fix the 'bad at it' part.
 
@EBrown A) What is "presented correctly"? B) Is codereview.stackexchange.com/questions/150878/… presented correctly?
 
@SimonForsberg "Presented correctly" simply means the OP didn't just say "I have this code that gives , how fix?"
In the case of that question, I would say it's very borderline, but I'd probably error on the side of accepting it.
 
@EBrown What more would be needed than saying that?
 
8:37 PM
@SimonForsberg All the usual requirements. I.e. a good title (not "this code throws OutOfMemoryError"), a good description, demonstration of intent to receive more than just fixing that error, etc.
 
That makes sense but still a review might not necessarily mean improving the performance or the memory management of a program it might be some way of shortening the code or applying some design patterns here and there, while fixing a problem with the performance is what the OP is looking for.
 
If you can take the question and metaphorically remove or StackOverflowException or 'out of memory' error and it would be on-topic, then it should be on-topic.
Does that make it a good question? Not necessarily.
Does it make it an acceptable question for our site? In my opinion, yes.
 
How can I resolve this? is the line I don't like as you pointed in the comments below the question @SimonForsberg. If the question was asking for a review as it is, that's completely fine in my opinion.
 
@denis Okay, so it sounds like you are thinking about one of our "magic questions" for determining if a question is on-topic: Do I want feedback about any or all facets of the code?
 
@denis A quick algorithm change can easily fix that issue for the OP. It may not get pointed out, but chances are, with people around here like @200_success, it will be pointed out at some point.
 
8:41 PM
That magic question is probably the most difficult one to handle and I feel that there are some disagreement about how we handle that one. Generally, if I feel that I have some value that I can give the OP, I will do it no matter what it is he is really asking about.
Related:
16
Q: Can we ask reviewers to *not* focus on something?

Simon ForsbergOur Help Center says: Do I want feedback about any or all facets of the code? However, sometimes we might have some code that we are aware has flaws in it, or we would just for one reason or another want reviewers to not comment about something. When asking a question on Code Review, can w...

 
Having a small bug in a question happens all the time, once that's pointed and the OP says that he doesn't mind having the bug or that he is going to fix it sometime in the future and he is looking for a review on the code as a whole, is completely fine but again in this case the OP is asking specifically for a bug fix.
 
@SimonForsberg The last company I worked for had a few bits of code that were really ugly, but because of what we had to do with them it was required.
> This works for i < 100000 but gives "OutOfMemoryError: Java heap space" for i < 1000000. How can I resolve this?
Personally, I think that if that last sentence was reworded to "Is there a way to resolve this?" it would be perfectly on-topic
 
@skiwi Just try a couple and see what sticks.
@SimonForsberg In fairness, it's a programming challenge and it fails the challenge.
Simply put, it's broken.
So, simply put, it should've been closed instead of answered. I fail to see a valid defence to keep it open.
 
0
Q: A heart.lisp I wrote with my 6 year old doughter

Alexander Artemenko(defpackage heart (:use :cl)) (in-package :heart) ;; Usage: ;; sbcl -l heart.lisp -e '(uiop:quit 0)' ;; (defun print-line (&rest args) (loop :for type :in args :by #'cddr :for num :in (cdr args) :by #'cddr :do (loop :repeat num :do (princ (ecase type ...

 
If something can be made ontopic by omitting the fact that it's about a programming challenge then you're being pedantic
 
8:53 PM
For once I agree with @JeroenVannevel.
@SimonForsberg Do you object to me editing that question?
 
@Mast Nothing does... that's the issue for today
 
@JeroenVannevel In that case it still doesn't do what OP wants it to do, so there's no pedanticism going on.
We aren't desperate for questions and we want to prevent turning into SO.
Quality matters.
2
 
I agree with @Mast
 
@SimonForsberg ++. It can be easy to get lost if what-if scenarios and lose focus on the issue at hand
 
@Ruwangi I have edited your question to be more on-topic with our site, please roll-back the edits if you are unsatisfied with them. — EBrown 6 secs ago
 
9:07 PM
@denis @Mast I honestly think that focusing so much about how the question is worded is useless. The code is still the same and the answers will still be the same.
@Mast To me it is not that black and white.
@EBrown Nice edit.
 
@SimonForsberg Thanks, didn't know if it would be allowed or not.
Personally, I think it eliminates a lot of the confusion about the question, though OP may not like it.
 
I don't know, if the question is getting downvotes then it's probably for a reason, I myself am undivided about the issue, I cannot vote in favor or against it
 
@Mast I honestly believe that handling this question in the way that you are suggesting will turn us more into SO.
@skiwi I downvoted mainly because it lacked description at first. Then I edited and upvoted.
 
@Mast Quality matters, yes. But who is to say we can't increase the quality of questions coming in by demonstrating how an off-topic question can become a good question?
@SimonForsberg I don't know if you saw, but I removed as well.
You (or OP) may like to re-add it, but since this doesn't technically satisfy the requirements of the PC, I figured we can safely remove it for now.
 
Providing the OP with answer that doesn't resolve the issue will only make it harder for him to improve it as that's not his own code (assuming he is beginner level) in my opinion.
 
9:13 PM
@EBrown That I didn't see, and that I think is totally unnecessary.
 
@SimonForsberg Feel free to put it back.
 
@denis You mean like answering about indentation, naming, code formatting?
 
Yes
 
@denis Personally, I answer with what I believe the OP needs to hear the most. If naming and code formatting is at an unacceptable level for me, then I add that to my answer. Normally though, I prefer to focus on the more important aspects of things (use of data structures, algorithm...)
 
0
Q: Use only necessary fields in an object for URL params

EFHI'm trying to cleanly grab some fields I need from an object. The scenario is this: I've got an object that is stored with certain 'extra' properties that exist because of the way we've set up our store in Redux. It'll look something like this: var formData = { account_name: 'SomeAccountNa...

0
Q: Optimizing sound generation in Java

user3233089Is there any legroom left for optimization (without switching to C)? static byte[] generateSound(double frequency, int sampleRate, int samples) { byte output[] = new byte[2 * samples]; int idx = 0; double _tone = 2 * Math.PI / (sampleRate / frequency); for (int i = 0; i < samp...

 
9:22 PM
@SimonForsberg It has nothing to do with the wording, but apparently I've already lost this fight. It's no longer my problem.
 
@SimonForsberg Replacing some of his data structures with a different one that he hasn't used before will make it even more difficult. Think of replacing an T[] with an IEnumerable<T>, sure he will learn some new stuff but he will most likely use a lot of bad practices as he might be unaware of some of the functions an IEnumerable<T> can offer, not being able to index the collection for example, how an IEnumerable<T>.Count() is working compared to ICollection<T>.Count() , etc..
I don't know java, that's why I'm using C# as a reference.
 
@denis All we have to do sometimes is to point people in the right direction. Hopefully they can figure out some future problems on their own, or they might come back and then we'll deal with the problems they have encountered then.
@Mast So... you're implying that it is my problem?
 
@SimonForsberg You might argue that hypothetical examples are incorrect but say your car broke more specifically your car's engine, you go to the service and you ask if they can fix it, they reply no but we can apply some grease to make it work better, are you happy with that response ?
While that's cool and all (free grease), your car still doesn't work right ?
 
0
Q: shuffle data Simulation

Lion KingIs the following procedure good for shuffling data in general (not just for javascript). function Shuffle(array) { var temp = null, len = array.length - 1, rnd = null; for (var i = len; i > 0; i--) { // Generate a random number in which does not exceeds the length of array. ...

 
@denis Here on CR though, if someone asks about slow code or code that uses too much memory, we can give them that advice in addition to helping them improve code style and naming etc.
 
9:35 PM
We accept TLE, but OOM is a different category IMO. I've stated this opinion earlier on meta.
> Code on CodeReview should work to the best knowledge of the OP. If the objective of the code is to handle 500 kB at most but the code crashes at 2 GB, the code is considered working. If those are reversed, it isn't.
2
A: Does getting OutOfMemoryError really mean broken code?

MastNote: I can not read the question, so my answer is based on the information given by the OP. Code on CodeReview should work to the best knowledge of the OP. If the objective of the code is to handle 500 kB at most but the code crashes at 2 GB, the code is considered working. If those are reverse...

It's an old answer though, so I may not agree with all of it today. But I still think there's a truth to all parts.
 
I got nothing else to say tbh, if you want to help people go ahead that's what stackexchange is all about, but I have to agree on 100% with @Mast here that if you tolerate that practice we might end up having tons of off-topic question.
 
@Mast Commented.
 
Way ahead of you :-)
I'm not sure whether we should have this discussion in the comments if we've already had it in chat though.
 
@Mast Comments on meta are more permanent than chat.
 
Both are usually not removed so they're both quite permanent, but fair enough.
At least they're not at the right place.
 
9:49 PM
@Mast I really don't get from where you got "you're basically stating the intent of the code is irrelevant"
 
Yea, I figured as much or we wouldn't still have this discussion. That's probably on me.
It boils down to you suggesting to remove the notion of the code being broken. Which is important.
 
@Mast "That would be true if the code would work for the cases given", what would be true?
@Mast For the record I'm not a fan of the word "broken". I don't consider input size relevant for the "working as intended". To me, working for 10^5 but not 10^6 is still working code (assuming that 10^6 would give correct results if sufficient resources were available).
 
00:00 - 22:0022:00 - 00:00

« first day (1332 days earlier)      last day (2683 days later) »