« first day (1218 days earlier)      last day (2799 days later) » 

12:00 AM
RELOAD! There are 2671 unanswered questions (92.8218% answered)
 
12:20 AM
Monking.
So much harder to get a train going now.
 
12:39 AM
0
Q: Monte-Carlo method to estimate Pi runs slower in multiple threads, than in single thread

AdamsanI'm learning scala, and I wrote a program to estimate the value of PI. When I'm using multiple threads, it takes 5-6 times longer to calculate the same iterations. I wrote a similar program in java, with plain old threads, and with ExecutorService, and the results are the same. Why is this the c...

 
1:23 AM
0
Q: Would this benefit from inlining?

JeffI've never bothered to inline any function, and I'm fairly unfamiliar with how it works. I was wondering, would this function benefit from being inlined? const char* GetNameByID(int ID) { auto itor = std::find(Achievements.begin(),Achievements.end(),ID); if(itor != Achievements.end()) { ...

 
1:50 AM
Monkevening
 
Structure is fine in my opinion, i prefer dashes rather than underscores for CSS-classes though, for code reviews you can go over to: codereview.stackexchange.com for CSS naming conventions, I mainly use this great guideline: cssguidelin.eswest efan 27 secs ago
 
Hello Phrancis
 
2:27 AM
Hey how are you @user2296177?
 
0
Q: Small implementation of a singly-linked list in C89 (Beginner)

James KoI'm very new to C. I have extensive experience with C# and very little with C++, but basically none with C. I wrote a small program that declares a singly-linked list struct, a few methods operating on the list, and then uses it from the main method. Even though I've read about it a lot, this is...

 
@Phrancis Alright, pretty tired, just relaxing now.
 
3:05 AM
0
Q: Clone a LinkedList with each node having a next and a random pointer

Neelesh SalianThe LinkedList nodes can be 1-->2-->3-->4, where --> indicates next. For their random pointers: 1--> 2, 2--> 4 3-->2 4--1. There can be duplicate data values of the nodes. I'm looking to see if the solution can be improved upon. class Node { int data;//Node data Node next, random;//Next and rand...

 
3:58 AM
0
Q: Reverse lookup ID by value

CharlesIs there a faster way of getting the key of 1 or 2 by using the "accs" value for my getID function? Unfortunately I cannot use an inverse dict due to the fact I'm using a list for the value which causes a unhasable list error. Mainly I'm worried more when the db gets larger in size the getID func...

 
Well, I've found the weakest link in my SE data processing: my PC.
I think I'll have to cut up the XML files in much smaller pieces than I had planned
Takes a full 3 minutes to load one single 1 GB XML file into a database row; and if I try to select it afterwards to display it, I get a System.OutOfMemoryException before it ever completes the process, making it basically impossible to use
 
4:28 AM
Actually even 100 MB gives OOM exception... around 20 MB doesn't -.-
 
4:53 AM
0
Q: Customized date and time display

user556068This is a smple reworking of the Bash date command to my own personal liking. It's possibly a rather trivial task, but I just wanted the date and time to be in the form of: Fri Sep 2 2016 11:37 P.M. I think this accomplishes that: #!/bin/bash today() { now="$(date | awk '{ OFS=" ";...

 
5:10 AM
Is it appropriate to edit out parts of answers to my own question that are blatantly wrong?
 
0
Q: JavaScript retrieving Google Spreadsheet

JeonI've made a JavaScript library that retrieves a Google Spreadsheet. It's a something like Sheetrock.js, while mine is just a prototype, less powerful. I've uploaded the source code and example in GitHub. But you can just see the implementation and demo in JSFiddle. A sample spreadsheet is here ...

 
 
2 hours later…
6:51 AM
Btw, in case the code review question intrigued for its similarity, that is because we are part of same team finding solution of same issue, just that I thought ThreadLocal is a newer approach to the ThreadStatic suggested — Mrinal Kamboj just now
 
 
1 hour later…
8:04 AM
0
Q: Complex component state delegation with React?

OlivierI'm currently reviewing some different ways to have reusable components enforcing both most of the style & logic. The use case is a generic MainList with children components (eg. MainListToolbar, MainListContent, etc.) that can all be used together to create multiple mostly agnostic lists for bus...

 
0
Q: Determining if the array provided is complete binary tree

Joe4356Well the title says it all... I'm not sure how to go about creating a boolean method which checks if the array provided is complete binary tree. My code already checks if its a binary tree. I'm new to programming and would really appreciate any help.

 
8:20 AM
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Archiving an SQL table of sessions and statistics
 
8:47 AM
0
Q: Merging the knots vector to get the common knots vector

Shutao TangGiven that I have a serial of vectors \$\{\mathbf U_1,\mathbf U_2,\cdots,\mathbf U_n\}\$. Below is a simple instance U1, U2, U3 U1 = {0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 0.8}; U2 = {0.21, 0.25, 0.3, 0.6, 0.7, 0.8}; U3 = {0.25, 0.3, 0.7, 0.8}; Now I would like to calculate their common vector , i...

 
8:59 AM
0
Q: K-means clustering implemented in Python 3

SorropHere is the classic K-means clustering algorithm implemented in python 3. My main concern is time/memory efficiency and if there are version specific idioms that i could use to address issues of the former. import numpy as np class kmeans(): ''' Implementation of classical k-means clustering al...

0
Q: PHP code reveiew for job application

DeebI have been using PHP for a few years now, but I'm self taught so I may have picked up some bad habbits. I recently got rejected for a job interview based on the following project. Can I please have some feedback from PHP developers on what's wrong with it and pointers into how to make it better?...

 
Better to take a crack at a design and have it reviewed in The Code Review forum. — Mike Wise just now
 
@Hosch250 @Mast Yes, I would also like @Duga's old picture back.
@Hosch250 Gravatar changed their algorithm
The only question is if I have @Duga's icon somewhere...
NOTICE: A blue icon showing @Duga's beautiful face is MISSING. Anyone who finds it may receive a reward.
5
@zyabin101 Didn't I send you @Duga's profile picture? Do you still have it?
 
Zak
@SimonForsberg We can get a (really low res) image from the chat transcript.
 
Ugh, that would not be the same
but if you can find it and upload it to imgur, that might be a start
 
@SimonForsberg I have the cover.
 
9:15 AM
We are desperate. Anything that can bring the old icon back is welcome at this time.
 
Zak
damn
Best I have so far.
 
@_@
user image
2
@SimonForsberg Cut Duga's picture ^ out of the cover.
 
Zak
@zyabin101 Beautiful
 
9:40 AM
user image
4
 
Zak
@SimonForsberg I'm surprised it's only in 4 digits.
 
If you don't see the old icon yet, you know what to do.
 
@SimonForsberg I don't see the old icon in chat, yet. Refresh Duga's chat profile?
 
Blame caching.
@JoeWallis a) github.com/Zomis/MinecraftScripts b) If you want to fell trees, use the Tinker's Construct mod and make a Lumber Axe :)
 
10:01 AM
Duga has her icon back :D
 
@DanPantry Not yet in chat, waiting for her message...
 
I found the perfect picture to describe my coworker's attitude after I refactored some (really bad) code the other day which I posted here
@zyabin101 oh :(
 
@DanPantry Linked to it in the Nineteenth Byte. :3
 
Beware... The golfers are coming
2
 
10:10 AM
my irish sim has arrived :) this move is getting very real now
and i just managed to launch it across the room by opening the iphone sim slot. crap
 
10:50 AM
0
Q: Can we free dynamically allocation memory using realloc?

Pankaj Kumar ThapaMy friend and I had a discussion over freeing dynamically allocated memory. He told that a memory could be freed with realloc(), to which I denied. Let's consider the below code: int main() { int *p = (int *)malloc(sizeof(int) * 10); int *q = (int *)malloc(sizeof(int) * 10); free(p)...

 
11:37 AM
0
Q: shoud i use property or method here?

programmer1I have a calss Activity and this class has two property, i don't know should i use property or method for activity's progress member? class Activity { public float TotalTime {get; set}; public float Done {get; set;} //Method: public float Progress() { return Done/TimeInMo...

 
418 I'm a teapot hours
 
Zak
11:58 AM
@SimonForsberg I don't want to know what my number is. Definitely a lot.
 
Are you sure the question doesn't fit better to the codereview? — W.F. 40 secs ago
Yes, because the code doesn't compile. Code review is for working examples only... — Killercam 32 secs ago
 
12:27 PM
@bradimus not code review but looking for a solution to my issue. As dynamic data is being overwritten — newbieprogrammer 31 secs ago
 
1:06 PM
Monking!
 
0
Q: create monthly calendar with number of days and offset (day of week) as user input

homer150mwI am taking a beginning programming class and have been given the assignment to create a calendar as described in the title. Per the assignment the user entering offset of 0 will begin the calendar on a monday and 6 will start on sunday. There are to be 4 spaces per column and the request for i...

0
Q: Double linked list in java (How to get started)

yoyoyo jansenI'm following a course where this weeks assignment is to implement a doubly linked list (from scratch). My problem is how i get started with the get and add method. I've been stucked on implementing these two methods for days now, and really don't know how to get started. I've have tried to write...

 
1:32 PM
0
Q: Simple logging library in C

Remo.DThis header implements a very simple set of C (only) functions for logging. This is part of a larger collection of utility functions aimed to be used during the development process, meaning that they are intended to provide quick, easy to use solutions that could be replaced in the production cod...

 
2:03 PM
I think you'll get better answers at Code ReviewRakete1111 16 secs ago
 
0
Q: Is this HTML & CSS code compatible with recommended practices?

DamienI have coded free .psd layout first time. I did not make it responsible, because I would like to know if that code is correct for now. Layout's appearance in Firefox and Chrome seems to be ok (though in Firefox there's a bit white space), but I know sometimes despite good look its code is not so ...

0
Q: Slicing Stack Exchange data dump XML files into small bites

PhrancisI was posed with a challenge when trying to load XML files from Stack Exchange into a SQL Server database; some of these XML files are extremely large (largest one being a whopping 67 GB in a single XML file), so much so that the database just cannot handle them without throwing a System.OutOfMem...

 
2:19 PM
@SimonForsberg Oh wow, that's more scripts then I ever made, :O I don't remember the Lumber Axe from TC, but I remember quite a few felling axes.
 
@SimonForsberg I realize the question was somewhat off topic and more appropriate to SO where it had been answered before, but the OP seems to have reasonable code and I really didn't want to scare them away. I was going to answer in a comment, but when I've done that before I've been chastised. I didn't flag the question. codereview.stackexchange.com/questions/140361/…
 
2:45 PM
0
Q: solving a String puzzle

YaSh ChaudharyGiven a string S S of length N N, you have to tell whether it is playful or not. A playful string is one where the distance between any two adjacent character is exactly 1 1. Consider that the alphabets are arranged in cyclic manner from ' a a' to ' z z'. Hence, distance between any character ...

0
Q: Reduce time complexity, decrease runtime - Google CodeJam 2010

jaa1235I have been working on a past Google Codejam algorithm from 2010, but the time complexity is awful. Here is the question from Google Codejam: https://code.google.com/codejam/contest/619102/dashboard TLDR - Imagine two towers that have a number line running up the sides, we draw a line from one ...

 
@pacmaninbw If the question is somewhat on-topic, then it's perfectly alright answering it in an answer. All seems well now to me.
 
@JoeWallis There's also ways to make automated tree farms (but I have not yet done it). And to do mining, it's much more efficient making an "Ender Quarry". Btw, most of my scripts are really short. I used to play a bit of Infinity Evolved but I'm not really playing any longer.
 
3:00 PM
@SimonForsberg I made an auto (non-large) Oak tree farm before, but I've lost my scripts, ): I've also not played Minecraft properly in about 4 years...
Also what do you mean by "Ender Quarry"?
 
@DanPantry Did you see that I got my new PC parts?
 
Zomgking
 
@JoeWallis thanks for fixing formatting on my post
 
@Phrancis No problem, I found out the problem is having both and changes the text formatting to the default one. Where without the text formatting is lang-py. I don't know if they'll fix it tho, :/
 
@SimonForsberg @Zak I got into my Factorio account.
 
3:12 PM
Then why do you addChild() the Tile objects? You shouldn't have to deal with regular DisplayObjects when blitting. If your code is working as expected and you want get it reviewed, maybe try asking over at Code Reviewnull just now
 
@JoeWallis it's some mod that has a block called "Ender Quarry" (IIRC) that can be used to mine all kinds of blocks in a really really really huuuuuuuuuuuuge area and either replaces them by dirt or removes them completely. All the mined blocks are put into a chest, that can then in turn be connected to a ME system from Applied Energistics 2
 
Great idea. I never knew about code review. Thanks for the tip. To answer your question, I'm just doing addChild to do a quick z order fix. The tiles that get removed from the game screen get stacked in sorted piles (just a method I've been using to visually see what's happening to my arrays; addChild is not necessary for the final outcome). But you say I wouldn't have to use normal display objects... wouldn't a Sprite still be the best object to use for an interactive block (i.e. player needs to be able to collide with tiles)? — Neal Davis 50 secs ago
 
@SimonForsberg That just looks OP, and it's not that expensive. Takes you to the end-game pretty quick.
 
@JoeWallis Well, I can't deny it's useful. But I really like it. I'd rather use that instead of mining stuff manually or using some other mining technique.
 
@SimonForsberg Well you're not wrong there. BC quarrys and turtles are my preferred mining methods, however. I used to play Greg-tech, so I prefer a hard experience, ;P
 
3:27 PM
Nowadays I only use turtles for building stuff. Such as the buildfloor script
 
possible answer invalidation by ultra on question by ultra: codereview.stackexchange.com/posts/138537/revisions
 
0
Q: Trying to identify matching consecutive numbers in Java by using for loop

Iona-Kathryn EvansHi I am trying to identify matching consecutive numbers in Java using a for loop. My code first establishes a binary number of base 10 (n) but I cannot figure out how to identify matching consecutive numbers. I am getting compilation error because of [x + 1] but I don't know an alternative to th...

 
@SimonForsberg Fair, to make turtles useful you'd need to put a lot of effort into it.
 
3:42 PM
0
Q: Time taken to run a program in python

Mohammed Fahad KaleemI am new to Python programming. I started working on Project Euler this morning and I wanted to find out how long it takes to execute my solution. I have searched online for a solution to my import time class Solution(object): def fibonacci(self,limit): sum = 0 current = 1 ...

 
3:54 PM
@Mast sorry Mast, I have been trying to post more often.
I am thinking that every time that I have to explain something in writing that I might as well share it on my blog as well because, well, why not.
 
0
Q: File Upload validation client side

AyanI am trying to build a multiple file uploader with jQuery and Ajax. I would like to know how this code could be improved. I feel the client side validation of file types in my code are presently not good enough. app.js $(document).ready(function() { $('#upload').click(function () { ...

0
Q: Pyramid array builder

Jose Hermosilla RodrigoI'm developing, just for fun and learning, a TypeScript Class that creates an Array<Array<string>> that represents a pyramid. So, for length = 5 the array would look like : [ ['X', 'X', '0', 'X', 'X'], ['X', '0', '0', '0', 'X'], ['0', '0', '0', '0', '0'] ] The class constructor can take ...

 
I am kind of curious whether or not I am on the right track with my posts because right now I am posting stuff that I am learning about rather than something that I have been doing for years and think other people should know or in case I have a memory loss of some sort
 
@Malachi, for some reason I've read memory loss as memory leak
 
lol
 
btw got my professor always writing this: for (int i = 0; i < n; i++). It's like rejecting to write optimal code that is almost free
hi @Mast
 
3:59 PM
@Malachi It's your blog.
You decide.
hi @OlzhasZhumabek
 
possible answer invalidation by chharvey on question by chharvey: codereview.stackexchange.com/posts/140152/revisions
 
@Duga, strange indeed
anyone tried to say their professor that his/her code is bad? It works at least, but that's all there is to say about it
 
@OlzhasZhumabek What is bad about it?
 
@skiwi, bad variable names and suboptimal code in some places
 
how do I do a language none in a post?
 
4:10 PM
@OlzhasZhumabek I don't understand the context, I don't see anything bad (yet)
 
@skiwi, not telling the difference between postfix and prefix increment and their meaning in terms of performance.
 
@OlzhasZhumabek postfix and prefix have a difference in performance? if it does, it's going to be so minimal it won't matter.
the main thing would be that they do different things
 
sometimes they use sub par code to teach new programmers and then as they go along they add new functionality that makes the code cleaner...sometimes there is method to madness
 
@Malachi this also, it's the same reason why when you're young you're taught that gravity is a pulling but PSYCHE it's actually a curvature of space time.
@EBrown Nope
 
@OlzhasZhumabek I still don't get the context, that line of code literally tells me nothing, except that it is very plausible code
 
4:12 PM
@DanPantry Well I did. ;)
 
Would you suggest the professor do for (int i = n; i <= 0; i--)?
Because that's just harder to read (and write, I probably wrote it wrong)
 
@DanPantry, the thing is that telling people to write ++i costs the same as to write i++. So why to not do the former?
 
because ++i and i++ do different things.
 
@DanPantry, it is a iteration expression on the loop. It gets discarded
 
@OlzhasZhumabek Why do the former?
 
4:14 PM
@OlzhasZhumabek It is different, and depending on the machine architecture one can be faster.
 
@EBrown, it's slightly faster
 
in this instance, i++ and ++i do do the same thing
how much is slightly?
 
@OlzhasZhumabek Define "slightly"
 
exactly how much time are we saving here
 
push 4 bytes to the stack,one copy, pop 4 bytes from the stack
 
4:14 PM
I'd wager that whatever algorithm you're using that requires a loop over the contents of the array could be made faster instead of changing the increment operation which is probably the cheapest part of the loop
 
instead of copy
 
also note that most of the time when you use the increment operator you almost always want the postfix rather than prefix
 
I know that, but the thing is why not do that small thing in a better way if doing in a better way costs nothing
 
so it's just "more natural" to use postfix here
it doesn't cost "nothing", cognitive load is not free
 
The problem with prefix is readability.
 
4:16 PM
@OlzhasZhumabek It does cost something, it causes confusion to all future readers of that piece of code
 
You can't tell what's being modified immediately.
 
having to remember to do something different to save literally one cpu cycle...
 
for my peer prefix was easier to understand in the loop rather than postfix
 
your peer is not a representative sample
it's such a trivial point to make an issue over
the reason your professor is probably teaching it is because 99% of the time you want postfix, not prefix, and it's just easier to use postfix and not have to introduce people to prefix and the difference between the two
I have used the prefix operator exactly once in the past 2 years, and it was a couple days ago :P
 
@DanPantry, in C++ I use it a lot. Quite a lot. They have very big semantical difference because it supports overload. The prefix increment says that it will be the same or faster
 
4:18 PM
13
Q: Avoid Postfix Increment Operator

Mateen UlhaqI've read that I should avoid the postfix increment operator because of performance reasons (in certain cases). But doesn't this affect code readability? In my opinion: for(int i = 0; i < 42; i++); /* i will never equal 42! */ Looks better than: for(int i = 0; i < 42; ++i); /* i will...

 
@EBrown, so they are equally easy to read. Why not do the prefix?
 
> In at least some cases, the postfix operator will be less efficient.
> However, in 99.99% cases, it won't matter because (a) it'll be acting on a simple or primitive type anyway and it's only a problem if it's copying a big object (b) it won't be in a performance critical part of code (c) you don't know if the compiler will optimise it or not, it may do.
 
44
A: Avoid Postfix Increment Operator

Martin BeckettAlways code for the programmer first and the computer second. If there is a performance difference, after the compiler has cast its expert eye over your code, AND you can measure it AND it matters - then you can change it.

 
There's literally no compelling argument either way.
 
> Always code for the programmer first and the computer second.
Even in C++.
 
4:20 PM
maybe we should call it ++C. It'll save a copy. ;-)
 
@EBrown, I'm not saying strictly about C. I'm talking about the "idea" it introduces, at least for C++ developers. Every C++ developer knows that prefix increment is always the same or faster
 
and 99% of C++ developers aren't going to care because it's a micro optimisation
 
> GCC produces the same machine code for both loops.
 
@DanPantry let me find one interesting answer
 
if you have an o(n^2) algorithm, changing from i++ to ++i won't be the best thing you can do
unless you are writing extremely, extremely performance critical code, it doesn't matter.
and students in a class aren't writing performance critical code. /thread
 
4:22 PM
@DanPantry, if everyone will write it right from the beginning, no one will need to remember it
 
we seem to have postfix/prefix conversation every so often...
 
Yup.
 
ok, I won't say that prefix is better. It was nice to understand what community thinks about it, so that I won't be talking garbage on my lectures
 
We should probably put an end to it.
 
@Mast, how to it then? We could run a benchmark as an option.
 
4:24 PM
The general consensus is yes it might be faster and it might be more readable, but use the one that makes the most sense for what you're trying to do and don't be mad at other people for not teaching what is essentially a micro-optimisation.
 
@OlzhasZhumabek Keep in mind, for students it's more important the code works than that it's the most performing.
 
The general rule with any optimisation discussion on CR is don't optimise unless you have to
or rather, until you have to
 
@DanPantry, I follow the rule "If I can do it in less than 2 seconds, then I will do it". The problem might be that I'm kinda obsessed with performance, but not that much as to write faster modulus or faster comparison, which performs like 20% and more faster
 
So you're obsessed with writing code that looks optimised, but isn't. :p
5
 
but I think they are good to know. So that when the time comes I will immediately pull it out
 
4:27 PM
@OlzhasZhumabek So you want to eliminate one potential instruction, but not actually make any performance impacts?
 
@DanPantry, I look at assembly. It is optimized
 
Meh, I've written code in Assembly that turned out to be less performing than the C++ version I already had.
A language isn't optimized.
 
@OlzhasZhumabek Let's not forget optimizing compilers here. Some optimizing compilers may even change i++ to --i for speed reasons.
 
@Mast, because compiler is much clever than most of the assembly programmers
 
Exactly.
So leave the optimizing to the complier.
 
4:28 PM
that's what I'm talking about. I've looked at assembly. It's not enough yet
 
@OlzhasZhumabek It's pretty good, it'll probably be able to do anything that you're doing...
 
@OlzhasZhumabek This depends on the compiler in use, the operating system and the hardware.
 
@JoeWallis, not really. There is a intrinsic to bias compiler towards some result in branch predictor, which can have drastical impact
 
0
Q: Sending email using libcurl (continuation)

UfxThis question is continuation of Sending email using libcurl I developed a class to send email. Does this code have any problems? #include <ctime> #include <cstring> #include <curl/curl.h> class Email { public: Email (const std::string &to, const std::string &from...

 
Does this question belong on CodeReview?Weather Vane 20 secs ago
 
4:32 PM
this is the talk why I'm so curious about performance:
hi @user2296177, I will post it on Tuesday for sure. For now, I'm procrastinating
 
@OlzhasZhumabek Ok.
You are doing just the basic features of it, right?
 
@user2296177, I'm thinking about assembling a frontend that will deal with references and not default constructible thing and then bass to backend
 
Are you following the standard's specification or just implementing it on your own?
 
Yes, pure standard std::variant.basically it will do the following: first it will check if the beginning of the list is not def constructible, if so, it will prepend monostate to the list. Then substitue std::reference_wrapper to all refs.
the std::variant has a some restrictions though, operator= is kinda restricted to the types in the list. But it would be really hard to implement natural operator=.
 
5:07 PM
Small remark: since you've already solved your "problem", your question is probably eligible for Code Review. — Zeta 34 secs ago
 
Why does @Duga have a different icon on PC and mobile?
On mobile I see a purple one with a different pattern than the blue one on PC
 
Caching
 
7 hours ago, by Simon Forsberg
Blame caching.
 
lol
That explains it then
 
Also read up on
8 hours ago, by Simon Forsberg
NOTICE: A blue icon showing @Duga's beautiful face is MISSING. Anyone who finds it may receive a reward.
 
5:15 PM
OIC, nice
 
0
Q: Getting columns from lines of uneven length

NoumenonI am given pasted data from a table, so I have spaces as delimiters and in some of the fields I don't care about. I want the first field and the last three fields, and got them using this code: testdata = """8/5/15 stuffidontneed custid locid 55.00 8/9/15 stuff i really dont need with extra spac...

 
@SimonForsberg I found it
 
8 hours ago, by zyabin101
@SimonForsberg Cut Duga's picture ^ out of the cover.
 
0
Q: C# Basic Api Wrapper around a Restful service

user2859298I'm writing a basic wrapper around a restful service that returns a list of Stores. I'm using RestSharp which I'm injecting into the class. Naturally i want to make it completely testable (that's a major requirement!). I'm also thinking that it could be more generic i.e. GetStores but I'm strug...

-1
Q: Can this be optimised further to run faster?

chiichBeen trying to make this run faster, less than 7000ms taking into account records upwards of 10,000,000 items: it's been weeks now and I really would appreciate some guidance or signpost to some helpful resource to set me on the right track. var sum_pairs = function (ints, s) { //your code h...

 
5:39 PM
-1
Q: GetUserName c++ method explanation

RedIconTCHAR username[UNLEN + 1]; DWORD size = UNLEN + 1; GetUserName((TCHAR*)username, &size); This method used to get logged user on windows. Could anyone explain those 3 lines of code?

 
Migrated from Code Review because the question is not asking for open-ended suggestions for improvement, but rather asks for an explanation about a specific programming issue. — 200_success 43 secs ago
 
0
Q: C++ coding convention vs. C

GiladI don't have a lot of experience in C++, i'm more of a C# guy. I'm trying to convert some matlab image processing code to C++. I would appreciate any feedback about c++ coding conventions. which data structures to use, what kills performance? And anything which is considered to be good or bad co...

 
6:31 PM
@Phrancis He didn't say the reward would only go to the first person who found it ^^
 
6:49 PM
0
Q: Filter options of select box using input box value

zombieI have a select box with some options in it and a input box. I have to filter the values of select box on the basis of the keyword entered in the text box. JavaScript function filter() { var keyword = document.getElementById("search").value; var select = document.getElementById("select"...

 
I think that the Code Review community would be a better fit for this question. — StardustGogeta 40 secs ago
 
8:02 PM
0
Q: LinkedList Implementation in Java

Sandeep KumarPlease review my code for Singly LinkedList implementation in Java. I know there is already an implementation in Java, but I just wanted to come up with my implementation. Suggest me if I can improve this. import java.util.NoSuchElementException; public class LinkedListImplementation<T> { p...

 
Naruto answer; accepted non-selfie answer with 0 score: Import data module
 
8:20 PM
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Implementing Functor Instance for ITree
 
@EBrown I still have sleepless nights.....
3
 
I never knew SE could be traumatizing.
 
Maybe CodeReview. — Luke Park 38 secs ago
 
8:42 PM
0
Q: Lambda to obtain a new merged object

arinThe requirement is to iterate over a list of Foos, and when 2 Foos have the same id merge their list of inputs together and obtain a new object. I have achieved this with 2 streams and a private method to do this: import java.util.HashSet; import java.util.Set; class Foo { private String i...

0
Q: Scrolling 2D Tiles (AS3)

Neal DavisFirst time posting here. Most of my interactions on stack exchange are over at Stack Overflow, but I had a suggestion there to post my code over here to see if anyone had some pointers for me. For brevity, I have just posted 1 out of 4 conditionals that comprise this function. They are all nea...

 
9:34 PM
@rolfl lol :p
For added drama you could tell one of the girls that that guys fly was down, now it's her task to tell him or stare at his crotch
/s/her/him/ - gender matters
 
9:47 PM
Oh no
If you move the mouse with my new motherboard the PC comes out of hibernation mode.
This will not do.
 
pretty sure thats a BIOS setting
 
It's UEFI
Either way, I'll just power the mouse down for now.
Woah
When the Windows 10 boot screen is reached it's there for less than 3 seconds.
 
This question might be better for Code review since it's a working script. — Ted Klein Bergman 40 secs ago
 
Blaming perf issues on Garbage Collection is like blaming your hangover on your liver... Its the thing that's saving you from your code
 
10:03 PM
@DanPantry Saving me from my code? What does that mean?
 
No idea, but it sounded funny.
which is probably what most politicians say to their colleagues after making promises on a podium
 
Maybe it means that certain code causes GC to perform worse?
I think D's idea of having an opt-in/opt-out GC is great.
 
I like Rust
has no GC, but is very explicit about memory etc
 
From what I just read, it looks like Rust simply uses RAII by default for all dynamic memory allocations.
 
That's basically it
Everything in Rust is deallocated when the scope ends
Except stuff that is stored in a Box, which is stored on the Heap
actually, I'm still wrong, that is deallocated too
 
10:11 PM
Yeah, that's what I meant by RAII
Basically the pointer is wrapped in a struct and the destructor frees the memory. And that's all done for you.
 
Yeah, but there are a few other tricks up its sleeve that prevent you from doing silly things
for example when using a value to a thread that thread may outlive the current scope
so you have to explicitly move it to that thread or use a reference counter that creates clones of the object ,etc
this is all enforced by the compiler and has no cost at runtime, as compared to C++ where this mostly has to be done at runtime with the programmer making sure he isn't screwing up
Wow, so this is how it feels to be an evangelist.
 
How exactly does one value in memory get moved to another thread at compile time?
 
fn foo() -> SomeType {
  ...
}

fn main() {
  // This is fine, foo takes ownership of return value, will be deallocated at end of scope
  let someType = foo()

  // unless...

  std::thread::spawn(|| {
    // We can't do this, because this thread may outlive the scope of main(), but
    // someType would be deallocated at the end of main(), so someType may be
    // null here. Rust yells at us.
    doSomethingWith(someType)
  })

  // The solution is to 'mvoe' the value
  std::thread::spawn(move || {
@user2296177 it's not physically moved, it's semantics
I hope the example above explains it
there's no cost to this abstraction, it's just rust making sure that you aren't doing dangerous things with object lifetimes and such that only one thing may have one biding at any one time. make sense?
 
Yes, that makes sense.
A lot of C++ compilers do spit out warnings for dangling references though!
 
this is just one example :p
Also this isn't a warning, it's a hard error, you cannot compile without it (though there is -Wall for gcc)
 
10:19 PM
If you ain't compiling -pedantic-errors -pedantic -std=c++14 -Wextra -Wall that's kind of your own fault!
 
fn foo() -> SomeType {
  ...
}

fn main() {
  let someType = foo()
  let foo = someType

  // Illegal
  doSomethingWith(someType)
}
This is also another side effect of that borrow system, though
  let anotherFoo = foo()

  doSomethingWith(anotherFoo)

  // Illegal
  doSomethingElseWith(anotherFoo)
another example ^
 
Wait what? Why is that illegal?
 
Because you're moving the object itself, not a reference to the object
 
Because doSomethingWith takes ownership?
 
Yes
if you pass something in to a method (or assign it to something else) and it doesn't implement the Copy trait, then the thing you're giving it to takes ownership
ahh damn
i went to answer the door and took my headphones off
they landed on my printscreen key
and now i have about 100 screenshots in dropbox
 
10:22 PM
Next time, carefully place the headphones instead of throwing them at your keyboard like a madman.
 
I did place them carefully
I just didn't consider where I was putting them
 
@DanPantry What is the Rust-like way to make that previous example legal without involving copying if doSomethingWith does actually need ownership?
 
You use a borrow
let something = whatever();
doSomethingWith(&something);
doSomethingElseWith(&something);
and yes, that is exactly like taking a reference of something.
that lets you view the object, anyway, not mutate it
if you want to mutate it, you need to use a mutable borow
 
I see.
 
and the original type needs to be mutable as well
you can't take a mutable borrow of an immutable object, and you can only have one mutable borrow at any given time
Heya @quill
 
10:34 PM
As I understand it, the language pretty much forces you to use the equivalent of std::unique_ptr<T>, std::shared_ptr<T> and references unless you use unchecked scopes.
 
Correct
 
That's definitely good.
 
but it does it at a language level at compile time, rather than at runtime in userland (or library land)
That's both a good and a bad thing, I guess you get the option to opt out in C++ though I don't see anywhere where you would want to do that
 
It's pretty difficult to have a good reason, but reference counting does have its overhead.
 
all of this is done at compile time
afaik there's no reference counting done at runtime unless you explicitly opt into it by using the Rc/Arc types
standard borrows or mutable borrows do not add reference counting/overhead
 
10:42 PM
I understand. I see the merits, it seems to be just as performant/controllable as C++.
@DanPantry How much C++ have you done?
 
not a lot. I dabbled when i was (much) younger
certainly, nothing commercial
 
Well, if you like Rust, you might enjoy C++ as well!
 
I actually learned Rust in lieu of C++
I wanted to learn something low level, either C++, C or Rust
 
Haha, yeah... that's what I thought.
 
so I picked Rust :p
 
10:46 PM
Well, it seems like a good language from the little peek I had into the documentation.
 
Code review is for questions about "Improve code that you wrote or maintain", and Stack Overflow is for questions about programming and not as much about reviewing code. You might get an answer here as well but Code review is made for these kinds of questions. — Ted Klein Bergman 19 secs ago
 
0
Q: My own Stack Implementation in Java

Sandeep KumarPlease review my Stack implementation in Java and let me know if you people have any suggestions. Thank you. public class StackImplementation<T> { private StackNode<T> first; private StackNode<T> top; private StackNode<T> head; private int size; static class StackNode<T>...

 
11:38 PM
0
Q: JQuery array of functions validation

googabeastI am attempting to validate a set of business rules in order for a user to successfully add to cart. The rules vary from requiting to add/decline a requested add-on to not having more then 60 items in your shopping cart. So for my end goal I need to be able to have several dozen rule sets and if...

 
11:57 PM
@PietroSaccardi: The reason would be, that Mozilla code reviewers don't understand how to use innerHTML themselves. I use innerHTML to populate a document fragment once in the entire program and they flip out. This results in my code being rejected. Their parser flags the use of InnerHTML and they only see that. — Jedimaster0 59 secs ago
 

« first day (1218 days earlier)      last day (2799 days later) »