« first day (585 days earlier)      last day (3434 days later) » 
00:00 - 17:0017:00 - 00:00

5:00 PM
I answered another math question......ugh, get to work
 
@xDaevax You lie here: " To make the code flexible in handling files of any size I chose to buffer the contents of the files (as opposed to a File.ReadAllText approach) into memory." .... you suck it all in to memory anyway.
 
@rolfl Edited (I worded it poorly), you are correct: both approaches read the entire file into memory.
 
0
Q: Look up parameters based on a numpy array of input values

Fred SI want to look up empirical parameters (A and B in the example) for a model based on (a numpy array of) the day of the year (doy). Currently, my code looks something like this: def set_parameters(doy): A = np.empty_like(doy) B = np.empty_like(doy) # parameter values for the first 30...

 
> The actual code involves some more parameters and idxs and both looks messy and is a pain to work with.
@CaptainObvious Example code...... maybe?
I'll give him benefit of the doubt with a comment...
 
5:15 PM
@Phrancis I think that is the actual code, that it works and that he wants to expand it, but not if it is going to get complicated
 
oh I so don't like it when he's "just going to experiment a little" bit with my custom validation system I created
2
 
@Malachi I just think that this is odd A, B = set_parameters(days) it may as well be Foo, Bar = set_parameters(days)
 
@Phrancis I see what you are saying, but it is a function to do simple calculations, right? sometimes I use generic naming in a simple function.
 
Hi and thanks for the welcome. I originally posted the question to stackoverflow and got asked to post it here because the code in principle works, so sorry if it is inapproriate here. It is kind of example / prototype code because I honestly gave up on the real code for now (i.e. it doesn't work at the moment) due to its messiness. The real code really doesn't do (/isn't supposed to do) anything else, apart from a few more parameters than A and B and similar idxs though. — Fred S 2 mins ago
I'll leave it up to the community to decide, I guess.
 
@rolfl Thanks for that. Those are both good ideas.
 
5:30 PM
@xDaevax np. See the latest edit? (with the byte[] method comment)?
 
0
Q: On the readability of implicit parameters

MironorAll methods in my DAO class that handles folders (the web application is about cloud storage, like google drive) has User as first parameter. This parameter is used so that the current user may only access folders that he or she owns. Some of examples: def findRoot(user: User): Future[Option[DB...

 
@rolfl Yes. I'm wondering though, since the length of the file stream is long (int64), wouldn't it be feasible for the length of the file stream to exceed the maximum length of the byte[] (Int32)?
 
Yes, very feasible. So, check to see if it exceeds the limit of 32-bit integer, then throw an exception if it does. Your current code will throw the exception too.
Just in a not-so-well-structured way.
 
true
Given that scenario, would it be a decent choice to have the ReadFileContents return a byte[][] as a Jagged array?
the first index could be initialized to fs.length / int.MaxValue
ish
 
Not really. Consider the circumstances.... if you need to return an array of > 2GiB, you're screwed anyway.
If you have a 10 Gig file, what then? An out-of-memory error?
 
5:36 PM
Right, I forgot about that limitation
 
When files get to be a certain size, you need to process them in streams anyway, reading the entire file becomes a problem.
In your String-based code, for example, you have both the StringBuilder and the string copy of the data at some points, requiring perhaps 4X the memory as just the file....
If the file is UTF-8 encoded, and most (all) characters are in the ASCII range, then a 1Meg file will become 2Meg in memory because there's the 2-byte-per-char rule..... and you have 2 copies in memory, so you have 4 Meg....
Make that a 1-gig file, and suddently you need 4gig mem ;-)
 
Well, that certainly halves the usefulness of this code.
You'd recommend removing the returnValue variable then and just returning the output.ToString()?
 
No, it's just an observation that processing files takes more memory than you may realize...
Based on your other notes in your question, though, your expectations are for small files.
Files larger than a few meg should be processed in streams anyway, if you can.
 
Most of the time I imagine they will be smaller, but in some cases they may be "large" (an internal "file hosting" dropbox, media files will be served from a web-server and streamed in an HttpResponse to a client). These files will likely be larger (though probably not in the gig range).
 
Oh, really? And you can get a FileStream on those?
For network-based (HTTP, ftp, etc), you often don't know the size before you stream.
 
5:48 PM
Haven't had any problems as of yet. Common scenarios are large e-commerce images that are reviewed in a web (Intranet) application prior to be launched on the public website. This is done from a web-server that buffers the binary file stream (from the file system to the HttpResponse output).
Large ~= 1-5 Mb.
The client requests the image by id, and the code identifies the physical store for the image based on the db location and reads from the file system.
 
In which case your concep should be fine.
 
6:04 PM
Nobel party!
 
6:27 PM
0
Q: Deepest node in tree

StiflerI have wrriten two classes one to represent tree and Util class to get deepest node from the. Below is the class for Tree package org.vik.ds.tree; public class BinaryTree<E>{ private E data; private BinaryTree<E> leftNode; private BinaryTree<E> rightNode; public BinaryTree(E data, BinaryTree<E>...

 
6:58 PM
2
A: Tic Tac Toe in the Console

user2023861Why not store moves as a string of 0s and 1s instead of 9 properties? For instance this: _ X _ _ X O X O _ could be represented as: string xmoves = "010010100" string omoves = "000001010" With this scheme, you can store all of the winning moves (there are only 8) in an array of strings: ...

^ I think this answer is quite dubious... no?
The connection to the question seems to be lost
 
@skiwi Looks more like a Code Rewrite than a review... to me anyways
 
I think it's all fine if people come up with alternatives to the code in question in their answers (I also do it myself!), but there's got to be some relationship to the code in the question
 
7:16 PM
0
Q: 2-opt algorithm for tsp

josibakeI wrote a 2-opt algorithm to be used in a program and noticed (using profile) that the 2-opt is eating up a lot of time. I have tried a few things to make it run faster, but I am out of ideas. Any tips on making it run faster? Or a better way to write a 2-opt algo? Thanks! code: def twoOpt(self...

0
Q: Object with highest count in a Groovy list

RanPaulI have a list of Parcel objects, am trying to write a closure that picks the parcel object with highest count class Parcel { int id, int count, String sender, String recipient Parcel(int _id, int _count) { id = _id count = _count } } def parcels = [new parcel(1,5), new parcel(2,1), new...

 
0
Q: Ridge Logistic Regression in R

user59875I write the code for Iterative Newton Raphson for logistic Regression. Now I need to use the Ridge logistic regression. Any help to edit the code to have the coefficients after applying Ridge. And the choice of lambda!! The Iterative using Ridge Logistic given by: \$\ \beta_{new}=(X^TWX+\lambda ...

 
8:13 PM
@Malachi You might like to take a crack at this, very interesting question!
1
Q: Ways to write "50"

Eleven-ElevenI know this might not be the forum for this, but here goes. A really good friend of mine is an elementary school math teacher. He is turning 50 and we want to put a mathematical expression that equals 50 on his birthday cake, but goes beyond the typical "order of operations" problems. Some si...

 
@Phrancis if I wasn't at work dealing with some stupid bug in an ASP.NET/SQL web application
 
Yuck.
 
yeah . for some reason it's not performing correctly on a test server, but is when I host it locally on my local IIS
same flipping code.... same connections. no errors
 
8:30 PM
I've got enough of those right now as well
Locally it recognizes an object as part of the dbcontext => tests work
same code, same scenario live => models are detached or something and I have to query them again by their ids
 
So what exactly makes you to think that code on local, test and production would behave the same?!
 
0
A: Ways to write "50"

Simon André ForsbergWhenever one of my friends has a birthday, I find out how old they get and then I visit their number on Wikipedia For your friend, I would write something like this: 50 is the smallest number that is the sum of two non-zero square numbers in two distinct ways: $1^2 + 7^2$ and $5^2 + 5^2$. It...

@Mat'sMug knows what I am talking about ^^
 
haha yeah
 
Jun 12 at 13:30, by Simon André Forsberg
32 is a Leyland Number because 2^4 + 4^2 = 32. 32 is the ninth happy number. It is the atomic number of germanium (Named after Germany!). It is the freezing point of water if you use Fahrenheit (which most intelligent people don't use). Ludwig van Beethoven wrote 32 completed and numbered sonatas. There are 32 Kabbalistic Paths of Wisdom. In Chess there are 32 black squares, 32 white squares, and 32 pieces. IPv4 uses 32-bit addresses, which is no longer enough. ASCII 32 is a space.
 
Well, that question is exactly what my genetic algorithm is about
If I'd have the time, I'd have to add some unary operators and that would be it
You can play with it yourself though, if you want to add them and get a bazillion different possibilities
 
8:38 PM
seems like the OP wants more advanced stuff than + and - though
> He is turning 50 and we want to put a mathematical expression that equals 50 on his birthday cake, but goes beyond the typical "order of operations" problems
 
Now it has +, -, *, / and ^
but adding more is trivial
 
it's C# though. So to add more I'd need to start up Visual Studio, which in itself is not a trivial operation.
 
0
Q: SQL GROUPING SETS in Python using Pandas

bernieThe code below is intended to provide SQL's GROUPING SETS functionality in Python with the aid of Pandas: http://pandas.pydata.org/. Background on SQL GROUPING SETS: http://technet.microsoft.com/en-us/library/bb510427%28v=sql.105%29.aspx. There are at least two advantages to doing this in Python...

 
8:45 PM
@SimonAndréForsberg bah-dum-tish
@JeroenVannevel that roughly looks like something I'm going to be needing soon, when I get to parse Expression nodes in my VBA parser...
 
@Mat'sMug thank you thank you ;)
 
Too much ammo
my 2 usual vote requiring SEDE queries return nothing much ..
 
Just curious @all, how much are this evening's Nobel prize celebrations covered in your different countries? Much much people are watching it?
 
I didnt even know that got covered
2
 
about 5 hours of the dinner is covered on Swedish TV.
 
9:00 PM
there are nobel prizes today?
 
yeah, the Nobel prizes are awarded today
 
Usually I read about that a few years later when it's mentioned in an article about something related to it
fingers crossed though: I haven't won any yet but maybe today is the day
2
 
@JeroenVannevel well, they reveal who the winners are a couple of days before. So today is probably not your year
 
What, not even a "random person from the audience" winner?
 
not quite :)
 
9:16 PM
0
Q: jQuery: How can I make this code more snappy?

shmuliI have this tap event in an iOS app that I'm developing with PhoneGap. When I click on the left arrow, it finds the desired content and retrieves it from a JSON file. It then displays those results on the screen. How can I improve this? There's a bit of lag... I know that some of the lag is attr...

 
@Phrancis I found the issue. it was a varchar(5) and I was using weird values for my test users for that field, so needless to say it was having awkward results...
 
Ahh ok, makes sense!
 
Looks like I'm going to cleanup the entire Windows Phone codebase of our project tonight while everyone is asleep
I feel like a kid in a candystore
You'd think it's a little much
5 different models to represent a booking
 
@Phrancis the value for my entry was under 5 characters, but the entry for everyone else was more than 5 characters
 
0
Q: Code optimization of de-duplicating code

TomasPlease help. I have a list of authors, where seeking duplicity. The indexes of these duplicates are stored in a list of lists named duplicity. For example, at index 0 in the list duplicity is nested list, which refer to indexes of authors list with duplicates author A, index 1 author duplicity B,...

0
Q: Project Euler - Problem #11 - Ruby

DuÅ¡an RychnovskýAs a beginning Ruby programmer I implemented a solution for Project Euler, Problem #11. I'll be greateful for any suggestions for improvement (especially regarding code readability). # Largest product in a grid # Problem 11 # # In the 20×20 grid below, four numbers along a diagonal line have bee...

0
Q: Is it correct to use Java Comparator with 3 conditions at the same time?

Katherine99I am trying to create a class whcih implements Comparator class. The thing is that I have a list with some objects. This object is composed of 3 fields (Strings). My purpose is to sort the list based first on the first field: if the first field is the same on the two objects that I am comparing...

 
9:32 PM
@Malachi I see. I was never a fan of the "hard" character limit of SQL Server VARCHAR(). In Postgres, you just set the data type to TEXT and it will adapt itself for any number of characters up to 1 GB per field.
 
Now I have seen a friend of mine on TV on the Nobel banquet, now I can go to sleep with good conscience :)
3
 
@SimonAndréForsberg good night
@Phrancis that would be so nice in SQL Server. but the tables are from old databases so I guess it would take a while for them to filter out anyway...
 
Speaking of things we hate about SQL server
 
@Malachi Guess so. Any downside to using VARCHAR(MAX)?
 
deleting all tables from a database: horrible
3
 
9:46 PM
@Phrancis not more me...lol it was in a stored procedure the table was set to 10 characters I think.
real life data is only going to be 4 characters for the foreseeable future
 
Got an SSRS question. We have a PK in a table where the type is VARCHAR (don't ask). Some of the values have leading zeros (also don't ask). When I run the report and export it to Excel, it works fine (aside from the crappy formatting from SSRS). But if I export to CSV instead, it trims out all leading zeros. Any workaround?
 
@Phrancis you're viewing it in excel, the CSV file?
 
My brain is about fried, does anyone want to double check my reasoning ? codereview.stackexchange.com/q/72271/18427 C# question
 
first segment is correct
I don't know what itemsSeen is though
what collection returns a boolean on Add?
he's talking about lists but List<T> returns void afaik
 
I thought most things would return a true or false based on whether or not the operation succeeded?
 
10:01 PM
@JeroenVannevel HashSet does
 
@mjolka I suppose that's the one then
@Malachi yeah, but List<T> doesn't have any limitations that might fail the add operation
 
i can't follow OP's description. at all
 
@JeroenVannevel he's doing the add on the Hashsets though and not on the Lists
but they are both Generic Collections......
 
@mjolka Definitely agree it's unclear. Something about authors, indices and edges but nothing really coherent
oooooooh
there's code above it
I had the code field scrolled all the way down for some reason
 
@JeroenVannevel Yes
 
10:03 PM
@Phrancis bingo
view it in notepad or something
You're looking at integer interpretation by excel fields
0000001 (in decimal) is the same as 1 (in decimal)
And since excel is all about numbers..
 
the static extension method GetDuplicates is referencing an external variable. that can't be good
 
what variable?
 
Implicit conversion, I see. Makes sense, thanks for the explanation @JeroenVannevel
 
authors
 
oh
yeah, that is ugly as hell
 
10:06 PM
... authors.GetDuplicates()
 
he has that same value in his source field
doesn't even need to change the code aside from swapping authors with source
 
why ElementAt and not []?
just adds two null checks and a cast
 
but it's called on an IList so we don't loop
 
oh right
darn it, no smart comment from me then
 
10:13 PM
"The indexes of these duplicates are stored in a list of lists named duplicity." nothing is named duplicity in the code
i'm so confused
 
10:30 PM
 
1
Q: Best practices, or passing by reference to clean up code

tophstarI posted this on Stack Overflow, but it was suggested that I move it over to Code Review. I would like some feedback on the way I decided to clean up code from the in a .NET project that had Page_Load functions that had been added to over many years to the point that they were a complete mess. ...

 
Morning fellas
 
@Mehrad Morning!
 
10:51 PM
This is faster, but gives me wrong result. In duplicate list, I store data in list of lists, so therefore I used authors.GetDuplicates()[i].ElementAt(k) , where "i" refers to upper list and "k" to nested list. — Tomas 13 mins ago
@JeroenVannevel can you see any problems with the answer i posted?
 
I'll look in a bit, I'm bashing the above question
 
thanks
 
euuuh critiquing
 
I actually went a morning without edits, and I survived. :D I had to take three back-to-back finals today.
 
@Jamal three :O how'd they go?
 
Not too bad, actually, even with five hours of sleep and a little coffee. My crappy thermos fell down during my Java final, spilling java coffee everywhere.
 
just be glad it wasn't a Python exam
the answers to this question ... baffling workplace.stackexchange.com/questions/37366/…
"Writing lines-of-code is seen (by some) as a drudge job for junior programmers." "First of all, "cut code" is slang for "writing code" in the same way that some people refer to "cutting a check" (or "cheque" for the Brits). It is often considered a derisive term for a complex task"
 
11:28 PM
0
Q: Class for formatting topics using BBCodes

renanI'm developing a program for users from a VBulletin's forum. This forum has a lot of people interested in write good articles but some of them don't know how to use the formatting bar in his favor. Sometimes, the others members don't read this threads/articles because it doesn't have a interestin...

 
@JeroenVannevel "You should derive custom exceptions from the Exception class rather than the ApplicationException class. You should not throw an ApplicationException exception in your code, and you should not catch an ApplicationException exception unless you intend to re-throw the original exception." msdn.microsoft.com/en-us/library/…
 
Lol
I used ApplicationException because I figured that's how people name their selfdefined exceptions
 
ah ok :)
 
Thanks, I'll change it
 
np
jeez this is thorough...
 
11:34 PM
@mjolka Well, I suppose it could make a difference when authors is modified why you loop over it. Then GetDuplicates() would return different values
 
yeah, but i can't see anywhere that authors is modified
 
True, no way to know from the code. I wouldn't be surprised if that's the case though
 
getHasTrial ew
 
aside from that the code should be equal
 
cool, thanks
 
00:00 - 17:0017:00 - 00:00

« first day (585 days earlier)      last day (3434 days later) »