« first day (1567 days earlier)      last day (2448 days later) » 

12:00 AM
RELOAD! There are 4258 unanswered questions (90.8654% answered)
 
12:50 AM
@RubberDuck Just convinced my GF to buy it for my for my B-Day (Monday) so guess what I'm about to start reading. :)
 
1:01 AM
0
Q: Java - fill triangle function

MCMasteryI am starting to work on a basic 3D renderer for fun, so right now I have made a triangle fill function to be used when I draw faces on models: public void fillTriangle(Triangle2d t, Color color) { // triangle points are already sorted Line2d ab = t.getAB(), bc = t.getBC(), ac = t.getAC(...

 
1:19 AM
> Unfortunately, the truth is that test-driven development (TDD) is a difficult skill to master, and if done “wrongly” can be extremely costly - with fragile unit tests that are difficult to reason about and hard to change.
Speaking of TDD
 
1:31 AM
Holy crap @RubberDuck did you know F# shadows by default?
3
let x = "Hello"
let x = 10
let x = 50.1
And I just got to chapter 5, "Trusting the Compiler." :)
 
1:52 AM
0
Q: Sharing file descriptor between an under-privileged and a privileged process (using c++ and Qt)

ChinmoyThis code is part of my Google Summer of Code project. It will be used in a file manager to provide file management in root owned directory. As the title suggests this will be used to share file descriptor using unix local domain socket. There are two classes: FdReceiver and FdSender. FdReceive...

 
2:10 AM
@EBrown I didn't!
 
If you want to get refactoring tips, post your code on codereview.stackexchange.com but make sure that it's complete and works correctly. — skrx 11 secs ago
 
 
2 hours later…
4:05 AM
possible answer invalidation by somenath mukhopadhyay on question by somenath mukhopadhyay: codereview.stackexchange.com/posts/53768/revisions
 
4:21 AM
0
Q: Task Scheduler and concurrency

user3833308import java.util.Comparator; import java.util.Date; import java.util.Queue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; ...

 
@Duga handled
 
0
Q: Extract left text outside the parenthesis if any

spicyramenIm trying to extract the text on the left, outside the parenthesis (): import re clean_title = re.match(r'(.*)\(.*\)', title.lower()) if clean_title: return clean_title.group(1).rstrip() Any suggestions to improve it, maybe without regex? Expected results: >>'Alone in the Dark (The Cinci...

 
5:14 AM
Monking
 
5:31 AM
Monking
 
0
Q: Python and pandas column search optimization

spicyramenI'm using Python and have a Pandas Dataframe. This dataframe (products) is created from a CSV file. The CSV file may contain or not a country column. In case it exists, I need to use the value, otherwise I will use a default country value. Any suggestion how to improve the following code, trying ...

0
Q: Maximum consecutive subarray sum for a variable sliding window size

alecxeThe Problem: Given an array of integers L find the longest consecutive subarray of size k or less. Constraints: 2 <= len(L) <= 10000 3 <= k <= len(L) each element in the array will have an absolute value no more than 200 there will be at least one positive integer in the ar...

0
Q: Are we supposed to put var in on ready?

SmartestVEGACould you please code review the below chunk of lines? <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DocumentUploader.ascx.cs" Inherits="Fortius.CMS.CMSFormControls.WorldVentures.DocumentUploader" %> <div> <div class="control-group-inline image-selector"> <asp:TextBox ...

 
6:12 AM
Monking
 
6:46 AM
-1
Q: code blocks: c++

WasiuI find it really difficult to create new project in code blocks for c++. Anytime I create a new project from the console application, main.cpp file always appears with hello world content. I urge the house to guide me, please.

 
7:03 AM
Sounds good! Though, release branches is in no way needed if you try to achieve a more fluid branching model. Trunkbased pretty much removes all excess branches, the exception being feature branches used for pull requests and code review etc. — sp1nakr 42 secs ago
 
7:18 AM
This is the correct site for code which is not working as it should. Once you have it working, you can get help improving the code at codereview.stackexchange.comMawg 19 secs ago
@CodyGray I'm afraid you're incorrect. He literally says that the code is working but wants it to run more efficiently. If this question doesn't make the cut to get moved to Code Review, I wonder what does. Additionally, this question is so incredibly specific to his one-off situation that I strongly doubt many future users (if any) will either (a) find this question when searching for help with their own use-cases or (b) find the answer below useful for improving their own code. In sum, this is nothing but clutter on SO but a Good Question on Code Review, therefore it should be moved. — Andre Terra 30 secs ago
 
0
Q: If and else without curly brackets

SmartestVEGAIs it possible to have an if condition with curly brackets and else conditions without brackets? Also what is the good practice to format it , should there be a new line after else keyword? if (!String.IsNullOrEmpty(CssClass)) { fuDocumentUploader.CssClass = CssClass; CssClass = null; } ...

0
Q: Anagram Generator

Carl FujinamiThis is a program that takes lines from 'wordList' and prints it's anagrams . Please give me feedback regarding good coding practices. import java.io.File fun main(arg: Array<String>) { val wordList = File("wordList.txt") .readLines() for (word in wordLi...

 
Kaz
Monking @all
 
@Andre There's an error message displayed right there in the question. This could be made suitable for Code Review by editing, but it is not ready for migration in its current state, which is all that moderators look at. "If this question doesn't make the cut to get moved…I wonder what does." Not much. It's rare that questions asked on one site are sufficiently tailored to the rules of another site that they can be migrated directly. Your "usefulness" justification for migration is...odd. Why do you think a question that is too narrowly scoped to be useful would be useful somewhere else? — Cody Gray ♦ just now
This question is better in Code ReviewSwellar just now
 
7:36 AM
0
Q: Custom Fonts in Derived Classes

Danny GoodallThis is how I have set a custom font to all of the controls inside my winforms application (with a streamlined InitCustomFont method). Is this the best way to do it? Is there any way I wouldn't have to call base.InitCustomFont(this) in all of my derived classes? public partial class WizardPage {...

 
8:12 AM
If you're just asking for feedback on your SQL, the proper site for that would be codereview.stackexchange.comErik von Asmuth 54 secs ago
 
8:24 AM
0
Q: How to avoid code duplication in ordering system

DisappointedHere is the piece of order system. And this is hierarchy of order classes in this system Public MustInherit Class BaseItem Public Property Id() As Guid Public Property Sku() As String Public Property Quantity() As String Public Property TransactionId() As Integer? End Class Pub...

 
8:39 AM
-1
Q: code platform for me to use

kevin youngso you know how programmers will have to use some sort of platform to write the codes into the platform but im wondering what platform they use how to get it becuase i want to write codes to create games its just that i dont know what to write the codes into to create that game

 
@CaptainObvious Nothing to do with CR
 
9:25 AM
0
Q: Simpler way to convert vector image to matrix?

LeogoutI am playing with the cifar-10 dataset (available here) and for now I would like to plot one of the images of a batch. The images are represented as vectors when I get them from pickle: From the cifar-10 documentation: The first 1024 entries (of an image) contain the red channel values, th...

 
10:10 AM
Thank you so much for your help to solve my problem. I have hard time implementing your code into my file, as it's to advance for my current VBA knowledge, but I checked your code on a new document and it works like a charm :) Would you mind helping me implementing the changes into my full code ? I could share the file also for the code review. Thanks again for your help. — Omen 56 secs ago
 
1
Q: Is this javascript game's code any good

AsherThis is the first time I have used this forum (so forgive me if I have some ignorance on the matter) but I was wondering if this javascript code I wrote was in any way acceptable. This is the first game that I have made that I consider somewhat acceptable code but I would like a proffesional opin...

 
@TheFizh Good spot - not sure why I put in a calculation after each DataTable. Moved it now to the end of the sub, but no change in time... The main question that remains is why the 'For each s...' calc method suddenly stopped working, forcing me to use Application.Calculate to get correct results? Since the index/match is tiny, I think the calc method is the main reason for the slowing down, but maybe it's all the additional variables - perhaps some of them are of the wrong type...? Happy to try in code review - will search for that section on here, as never used before. — L.J. 22 secs ago
 
10:29 AM
0
Q: Conditionally applying and removing css based on a table row clicked

Brian JI've a added a click event to each row on a table element. Which I then use the $this context from the event to add some css styling to that clicked row. The behavior is as follows: IF tr doesn't have kpi-selected css applied WHEN tr is clicked on table THEN remove css style from all other tr e...

 
10:39 AM
Monking
 
11:26 AM
1
Q: Two maximal value in array. Sorted and Array.Sort()

Aleksey BudaevCompare the two methods of sorting the array in ascending order, where can I optimize? How best to handle exception handling? class Inside { Random rand = new Random(); // step 1.1: Fill array, output array public void SortedArray(int arrSize) { int[] arrO...

 
Greetings, Programs.
 
@Donald.McLean Greetings
 
Assembly of the sun shield for JWST is complete: nasa.gov/feature/goddard/2017/…
 
11:51 AM
@RubberDuck I learned it from that F# book last night. That's pretty awesome.
 
@EBrown Since I don't know F#: does this just create three different x, but only the last is available in that scope afterwards, since all three have the same name?
 
@Zeta Basically. The second declaration of x takes the first out of scope, though it still exists. The third declaration of x takes the second out of scope. :)
 
So it's like let in do-notation in Haskell. let in F# is non-recursive by default, though, right?
let x = 0
let x = x + 1
Does that lead to x = 1 afterwards, or is that a syntax/semantical error?
Found an online compiler. leads to x = 1.
 
12:13 PM
@Zeta Sorry about that, was on my way to work, but yeah, that should lead to x = 1, but it basically just rebinds the variable, rather than changing the value.
It's also interesting because in the root-level scope shadowing is invalid, since it considers them alternate definitions.
But once you're scoped into something then you can shadow.
Also, @RubberDuck you can write an F# script in an FSX, then select a line (or lines) and hit ALT+ENTER to run in F# interactive...pretty neat. :)
 
@EBrown Yeah, I'm familiar with that concept from Haskell, although you cannot write let x = x + 1 there (unless you're willing to wait a long time).
@EBrown I guess shadowing is nice if you want to have some inbetween steps, but I really hope that you get warnings for shadowing if you never use a binding at all.
 
@Zeta You don't get any warnings for it, which is bizarre but not unexpected. Because F# is "top-down" (that is, you can never access anything "below" you) it's not necessary.
Basically, F# compiles everything in order like C/C++.
 
possible answer invalidation by rubenvb on question by rubenvb: codereview.stackexchange.com/posts/173163/revisions
 
@EBrown Is that like kinda how "Python has "names""?
 
@EBrown Which still means that you might access the wrong "above you".
 
12:27 PM
@Peilonrayz Sort of, yes.
@Zeta Not necessarily, it's always the most recent "above you".
 
@EBrown Nice
 
@EBrown Refactoring session, you get rid of a binding but forget to remove the upper one (for example an index of some structure). You get distracted for some time (a call, a meeting, a coworker). You come back and forget to adjust the code that came after the now gone binding. Everything compiles fine since the name is still in scope and the type fits, but you end up with a run-time exception (if you have index checking) or a SEGFAULT (well, in C++).
 
@Zeta That's possible, but that's possible with all the .NET languages, really. Ideally, I would not recommend rebinding anyway, but if you are then you assume that risk.
 
That's why I hoped that there were warnings ^^.
Huh. Rust also supports shadowing. But it warns if the variable is unused.
 
@EBrown you didn't know that? Works in VS Code too. Love the repl.
 
12:35 PM
@RubberDuck Nah, I've never touched an FSX file before.
 
Yeah, so the shadowing thing.... I'm really glad you told me that because I would have expected an error, not the shadowing. I don't like that it does that.
Works in regular fs files too. (At least in code)
 
Indeed, I only tested it in code, but it is a good thing to know. It makes immutable state look like mutable state which can be a bad thing.
And only at the module/root level does it throw an error.
 
1:00 PM
@RubberDuck When you see POCO what does that abbreviate to you?
 
0
Q: Using two similar part numbers to share data between workbooks

FrenchPMy code can currently work between multiple workbooks, find part numbers with the same name looking through column E or m(1) to find them and, if they have data in columns T through X, copy that data into the found same part name's columns. It also counts the number of duplicates and changes the ...

0
Q: GeoPlugin based redirect PHP script

Mohit SinghI have multiple versions of my website for different countries. So the 'www' sub-domain will host index.php page that will validate user's country and redirect them on the respective country's site. The main target are 6 countries they have respective sub-domain (ex, in.mydomain.com, us.mydomain....

0
Q: Lua - Convert UINT to hh:mm:ss

Martin Router KingI have found the convert_to function in the lua-user wiki, and I created the convert_to_time function which does what I want it to do. Which is, basically: Having a number, return it's value in a Time format. The values range is: [0..863999] as we want the data in 0..24 hours format by step of ...

 
@CaptainObvious My words aren't really the best words today. Either way, code in image, and asking how to do something.
 
Kaz
TIL that the original pokemon games were written in assembly!
That's hardcore.
 
@Kaz The original Roller Coaster Tycoon was written in assembly as well.
 
Kaz
1:18 PM
@EBrown That one I knew. Still blows my mind ^^
Guy did all the art himself as well.
 
Woah, in F# there's a "copy and update" syntax for records (classes) built-in.
let customer = { Age = 30; Name = "John Doe" }
let newCustomer = { customer with Age = 31 }
That makes newCustomer with the same values as customer but then Age is changed to 31.
 
@Kaz Gotta get all that performance :P
 
@skiwi More like gotta use all the space. Wasn't Mew in the original games only because the removal of the debug function left enough space for a single additional pokemon?
 
@EBrown plain ol' c object
 
@RubberDuck I always called them "Plain Old CLR Objects", but this book uses "Plain Old C# Object".
 
1:24 PM
@RubberDuck That sounds like POD.
 
Wow, that mention sound scared the hell out of me, my browser forgets that I've muted it every few months
3
@Zeta That I don't know
 
@RubberDuck Chapter 11: Building composable functions. :)
 
Sorry for the mention sound. But yeah, remembered correctly.
@EBrown do you cross read that book, or do you read so fast? Weren't you in chapter 5 only an hour ago?
 
@Zeta Each chapter is only a few pages - there are 43 chapters.
 
0
Q: Accept either a existing stream or a filename (to be opened) in a constructor

Serge BallestaContext: In a larger project, I am trying to build an utility class to encapsulate the parsing of input data. And I want it to be able to process either an already existing input stream, or a file given by its name. My first idea was to have a ref to a std::istream as a class member, and initia...

 
1:36 PM
@EBrown The online version is… interesting. I like their "encrypted paragraphs" variant, which really shows how much content is there.
 
@Zeta Yeah, I was actually worried yesterday because I thought those were a different language or something, but they're not. :)
 
They start with simple single-letter substitution and letter shuffle and then get weirder by each line/paragraph.
 
Yo @RubberDuck and @Hosch250 (and anyone else interested in Fonts, cc @Phrancis): This font is awesome.
 
Like after Figure 11.4: "Fkylciu, L# cap c piasecl atoprore dcalel rvd forarwd oujg hcihw…" might be "Luckily, F# has a ???? operator called the(?) forward pipe which…".
 
@EBrown I'm going to guess it's FiraCode
Ha! I was right.
 
1:48 PM
@Zeta Funny, I'm in that section right now. "Luckily, F# has a special operator called the forward pipe which,"
@RubberDuck Yeah, it's actually really cool.
 
I like it. I use it for all my dev now. It's funny in Java. "Oh. Someone's been playing with streams. Sweet!"
 
Haha, what editor/IDE do you use for Java by the way?
 
2:11 PM
 
0
Q: Hacker Gridland Metro

PaparazziPlease review for style and efficiency and any other comments. The city of Gridland is represented as an n X m matrix where the rows are numbered from 1 to n and the columns are numbered from 1 to m. Gridland has a network of train tracks that always run in straight horizontal lines along a ro...

 
2:27 PM
0
Q: Generating all possible combinations of a string using iteration

Gary InI am generating all possible combinations from a string concatenated. I have a \$O(n*2^n)\$ solution. public static String[] combinations(String[] array) { String[] res = new String[(1 << array.length) - 1]; int k = 0; int x = 1; for (int i = array.length - 1; i >= 0; --i) { ...

 
Kaz
So, I'm going to fix this mess:
 
I see cables
 
Kaz
So, obviously, first step is to audit all the ports in the office, and make sure I know what everything connects to.
 
At least they have different colors
 
Kaz
I've found ports for 1-28, 31-38, 43-52
 
2:34 PM
@Kaz First step is to pull a cable and wait for a coworker to scream "THE INTERNET IS GONE".
5
 
Kaz
And a separate set of ports from 1-12
The other ports just don't seem to exist, yet there are cables plugged into them.
Like port 42.
This may have been a bad idea.
 
@Kaz Could that be the blue cable in the middle far right patch field on the wall?
Oh wait. My bad, there is no cable plugged in there, sorry.
 
Kaz
@Zeta You were right the first time. There is a cable there.
 
@Kaz Man, that's barely disorganized much less a mess. Try having literally a thousand cables like that.
 
Kaz
@skiwi That would be good, if the colours meant anything.
@EBrown Well, that's what I'm trying to avoid ^^
 
2:41 PM
@Kaz I've done entire networking closets that looked like that (literally whole closets), you have the easy one. :)
 
@Kaz Oh god, that blue cable is a ninja.
3
 
@Kaz I think there's a reason that it's not fixed yet
 
Either way, buy Velcros and cables with the correct lengths. And tell management to excuse you from the boring meetings in order to maximize coworker uptime and minimize unprofitable coworker downtime. That way you don't get yelled at and you don't have to attend a boring meeting.
 
Kaz
@Zeta We don't have boring meetings. We barely have meetings ^^
And I already got the stuff bought.
Though not new cables.
Work give me a lot of latitude to "just fix stuff"
Mostly because nobody else has made it their responsibility yet ^^
 
@Kaz I usually have to justify "just fixing something", but if the justification is decent they tell me to go ahead and do it.
Which I can't blame them for needing justification: what does 20 minutes of me working on ____ get the company?
 
Kaz
2:54 PM
@EBrown I suspect it's mostly that I A) Have a reputation for getting stuff done. B) Have no day-to-day manager I report to. And C) Everyone else is far too busy to think about what I'm doing at any given moment.
 
@Kaz I have the same reputation for getting things done here, the only difference is that we have a backload of projects that also need done, that are a higher priority. We're already gearing up to go into maintenance-mode when the time comes, we just don't have the time right now.
My boss spent about 15 minutes yesterday literally complimenting me on how I handled a situation we had from an integration we link into.
 
Kaz
@EBrown Awesome.
 
Over here every new thing always gets higher priority than the last
 
Remember the file-type thing I mentioned the other day? It was that, but on a smaller scale. We waited about two days for another guy to fix it, hadn't been fixed yet, so I fixed it in ~10 minutes yesterday because we were losing $_,___ on it daily.
So, me being me, I built a workaround that fixed it. :)
Got many bonus-points for that.
I think the most impressive part was that I came to him late yesterday and said "did ___ get fixed yet? If not I have an idea."
Also, for anyone interested: CodePlex is shutting down. :(
 
3:19 PM
@EBrown File-type thingy?
@EBrown So all I missed was "piasecl" -> "special"? I think I'll take the challenge to uncipher the book :D
 
2 days ago, by EBrown
In the course of about 2 hours I successfully wrote and tested a DLL which can read a file's data and map it to the most appropriate file type (PDF, DOC, XLS, PPT, DOCX, XLSX, and PPTX)...including the peculiarities of different types of headers, the lack of a header, trailers, etc.
 
@Peilonrayz you around?
Monking everybody :)
 
@EBrown So like the file (man 1 file) program, but as a library?
 
@Zeta Yep.
There's more info on it in the chat transcript just past that.
 
Oh. Yeah, that sounds like losing $X,XXX.
 
3:26 PM
Basically what was happening is we had many users having to download documents, determine what file-type they were (99.99999% PDF), add the extension, and re-upload.
 
@MrGrj Yup, sup?
 
And now the documents get automatically renamed, so that Windows can open them with the associated program again?
 
So, we obviously want to automate that.
@Zeta Yep. :)
You'd be surprised what becomes a priority when the company starts bleeding $$$$ from it.
3
 
0
Q: Was my edit rejected or not?

Rather NotsayThis is very confusing to me. I think the rejected edit was not mine, but I'm just not sure. It says I have 0 edits rejected. However, the rejection notice on the second line uses "this" vaguely. This question? This edit? Also, I don't think I even edited it 10 minutes ago. So if it's no...

 
@Peilonrayz I need something like this: datetime.datetime.strftime(datetime.date.today().replace(day=1), '%Y%m%d%H') but for the last day of the CURRENT month. Any ideas?
 
3:28 PM
@MrGrj Could you then minus a day from it?
And add a month ofc
 
that's cheating and I don't even know if it works. But who cares, I'm such a Python whore. I'm gonna try it
 
If you're just interested in the date, why don't you use date?
Ah, nvm, didn't see the %H.
 
;P
 
@MrGrj today = date.today(); date(today.year, today.month + 1, 1) - timedelta(days=1) seems to work, but I'm not very good at datetime
It also is only a date, so you'll have to add the time part too
 
And keep in mind that your script will fail in December.
 
3:38 PM
Oh yeah...
 
import calendar; import datetime; calendar.mdays[datetime.date.today().month]
apparently this works :D
 
Oh crap, my holidays are over
 
@MrGrj That works too, much better than using a timedelta!
 
yup
and the whole thing will look like this:
In [82]: last_day = calendar.mdays[datetime.date.today().month]

In [83]: datetime.datetime.strftime(datetime.date.today().replace(day=last_day), '%Y%m%d%H')
 
mdays isn't officially documented, so it might get removed at some point. But it has been in there for 26 years, so you're probably save.
 
3:47 PM
yea...
 
Also note that mdays will fail in leap years in Feburary. You can use _, last_day = calendar.monthrange(today.year, today.month).
 
"Why is “Can someone help me?” not an actual question?", also this is more a code review request, which are off-topic here. — Mark Rotteveel 13 secs ago
 
def last_day_of_month_by_date(date):
    """Returns the last day of the month given in date.

    It returns date with the same properties as the original
    one, except that the result will be on the last date in
    the month of the original argument.
    """
    _, last_day = calendar.monthrange(date.year, date.month)
    return date.replace(day=last_day)
 
@Zeta IMO tuple unpacking is unnecessary, just index the tuple... monthrange(...)[1]
 
4:03 PM
Hey, I don't know Python. I didn't know you could use the index in a tuple. Neat :D.
 
heh, small adjustments:
In [5]: def last_day_date():
   ...:         date = datetime.datetime.now()
   ...:         last_day = calendar.monthrange(date.year, date.month)[1]
   ...:         return datetime.datetime.strftime(date.replace(day=last_day), "%Y%m%d00")
   ...:

In [6]: last_day_date()
Out[6]: '2017083100'
does what I need though that 00 is a bit ugly
but that doesn't botter me
:D
 
Why do I have all these tabs open?
 
@MrGrj So why the 00 to begin with?
 
well, because that's what that ugly API wants
:(
 
So, apparently my browser also freezes when attempting to close tabs
I'm trying to relieve you from your suffering!
 
4:09 PM
@Zeta Fair, I've just never come across someone that knows of unpacking and not indexing before... :)
 
4:26 PM
0
Q: asp.net mvc DependencyResolver inside of a custom actionfilterattribute

Ortho Home DefenseI'm trying to set up permission checks in my app with a custom ActionFilterAttribute I was wondering what is the best approach to take to check the user permission inside of the custom attribute. Here is the custom attribute, Is it a good idea to use DependencyResolver to create the user repo? I...

 
Should be a codereview question — rollback 37 secs ago
 
@Peilonrayz I think the unpacking was shown in the Python tutorial, but I never thought about indexing a tuple. Lists and arrays? Sure. But tuples? Nah.
 
4:55 PM
Is your code working? If it is, then you should move your question to codereview and not StackOverflow. — Dávid Pásztor 13 secs ago
 
0
Q: R code to read table, perform calculations, and write excel

agf1997I hear loops are best avoided in R. Is there a better way to do something like this perhaps using lapply, etc.? library(xlsx) files <- list.files(path="/tmp/data", pattern="*.xls", full.names=T, recursive=TRUE) for(i in 1:length(files)) { df <- read.table(files[i], header=TRUE) avgArea <-...

 
Yes, it is working, i dont know about codereview, thank you a lot for this link! — Vladyslav Tymchenko 56 secs ago
If you plan to repost this at code review, be sure you delete this post. — rmaddy 53 secs ago
 
5:33 PM
0
Q: inroder_iterator for syntax tree of markargs

IncomputableIntroduction It is a spin-off to my compiler creation. So ... after discovering the golden rule of newbie in compiler creation, I discovered that it also applies to inorder iterator on binary trees! When in doubt, write huge if-else/switch chains (in a raw loop if needed). (I know this is...

 
5:45 PM
Does anyone have an idea for a small 2h-4h project?
 
0
Q: Function dependence on iteration variable of another function

VivekConsider two versions of implementing the same functionality. Version 1 - Functions calculateA(),calculateB() and calculateC() dependent on iteration variable of calculateAll(). class Box { void calculateAll() { for(unsigned i = 0; i < _values.size(); i++) { ...

 
I'm voting to close this question as off-topic because I've moved it to Code Review site. — Sach 6 secs ago
 
6:02 PM
@Zeta Writing a BF compiler in Assembly
 
That's a matter of opinion, and SO is not for code reviews, it's for technical problems. You can try the Code Review Stack Exchange site, the Go mailing lists, Go subreddit, forums, etc. but this question is off-topic for SO. — Adrian 36 secs ago
This isn't the right site for code reviews and that type of thing; this question is too broad. — jackarms 21 secs ago
 
let rec setValue (source:ICell) (valType:CellType) (newCell:ICell) =
    match valType with
    | CellType.Formula -> setValue source source.CachedFormulaResultType newCell
    | _ ->
        match valType with
        | CellType.Boolean -> source.BooleanCellValue |> newCell.SetCellValue
        | CellType.Numeric -> source.NumericCellValue |> newCell.SetCellValue
        | CellType.String -> source.StringCellValue |> newCell.SetCellValue
        | _ -> source.StringCellValue |> newCell.SetCellValue
@RubberDuck ^^^ Cheating just a bit, but not really.
So I built a program that reads an Excel file in, matches up different (alternating) groups, accumulates the results and writes it out with exactly 1 if statement.
And now that one is gone.
 
6:31 PM
-232
Q: Stack Overflow now has its own app on iOS and Android

Kasra RahjerdiTL;DR: Today we launched a new mobile app specifically for Stack Overflow. It lets you view, post, vote, and comment on Stack Overflow questions and answers. Download links are included in this post. Huh? Don’t we already have a mobile app? Alert readers may notice that you can already do all ...

Look at what I just found in my old tabs ^^
 
 
1 hour later…
7:50 PM
@Zeta Write A* in an esolang.
 
@Kaz Careful not to break it while you fix it, there's more to Ethernet switches than the naked eye can see
VLANs and all that other fun stuff
 
@Phrancis Truly there's only one way to learn that.
 
lol
 
0
Q: Async ASP.NET MVC 5 controller method

SinjaiI'm attempting to correctly convert a synchronous controller method to asynchronous, given that the operation it performs is CPU-intensive. private MyDbContext db = new MyDbContext(); public async Task<ActionResult> Index() { List<DashboardItemViewModel> viewModels = new List<DashboardItemVi...

 
@Phrancis I modify our Firewall configs on a daily basis and don't break anything. :)
 
8:03 PM
BTW @EBrown thx for the link to that font, pretty neat
I find it slightly harder to read than Consolas, may just need some getting used to. I think the characters are a bit closer together
@EBrown Yeah but you're trained & certified :P
 
You might have more luck at codereview.stackexchange.com. — pingul 20 secs ago
 
@Phrancis Technically only trained. Lol
 
@EBrown Close enough, the cert is just a formality :)
I've said it before but I'll say it again: Python's re.VERBOSE is awesome.
Takes a lot of the pain out of regex
 
@Phrancis ^^^ I like that font too. :)
 
8:19 PM
@EBrown Which one is that?
Are the s:string etc. just optional type hints or are they required?
 
Then you will need to post the code on codereview.stackexchange.com and ask how you can make it quicker. This site is for code that does not work. But you will need to post the code, no one can help without that. — Scott Craner 34 secs ago
 
@Phrancis Mostly optional, every now and then you have to give the compiler a hint as to what to look for.
@Phrancis FiraCode Retina.
Damn autocorrect.
 
sounds more like a job for codereview.stackexchange.com — Jean-François Fabre 32 secs ago
 
@Phrancis In fact, the type-hint on stripQuotes is entirely unnecessary, the explode usage and String.Concat tell the compiler exactly what to do. :)
 
@EBrown Still useful to the reader/coder though?
 
8:26 PM
@Phrancis Depends, only useful if you have no intellisense at all, otherwise it's superfluous.
 
Hmm interesting. I use type hints in Python because Intellisense understands and analyzes them
Since the interpreter clearly doesn't care about types, only the compiler does
 
F# is still a strongly, staticly typed language.
Even if most things don't need an annotation for the type, it still defines everything with a strong, static type.
 
Ah OK, that makes sense
It's smart enough to infer types from the code
I often find myself writing stuff like this in Python:
if not isinstance(foo, str):
    raise TypeError("Input must be of string type")
Easier to fail early on TypeError than to fail somewhere else in the code where it can't do something because it's the wrong type
 
0
Q: beautiful-soup vs beautifulsoup

alecxeFor some reason, CR has a tag for the BeautifulSoup library named as beautiful-soup with a hyphen even though there is no - in the official name of the package and SO has this tag named as beautifulsoup. Is it possible to rename to be in sync with SO and the actual package name?

 
@Phrancis Yeah the F# compiler does most of that (which is great).
You might actually be surprised at what the F# compiler does for you, it's really intense.
 
8:50 PM
0
Q: How do I refactor these 3 very similar functions?

Augusto Dias NoronhaI have 3 functions which are annoyingly similar, but I can't figure out a way to refactor them without making the code unreadable. Here are the three functions: def ler_todos(caminho) -> set: definicoes = set() for file in os.listdir(caminho): if file.endswith(".ascx.resx") or f...

 
@EBrown I haven't heard of a compiler described as intense before
The C compiler is certainly intense, not in the ways I would like though
 
9:04 PM
@Phrancis But it is. ;)
 
0
Q: using jquery to determine if text is going to next line, if so add a div to make text smaller

HollerTraini am working on a layout where we have text in a certain height div. the div looks great and what it should look like with the mockup when the text is on one line. but sometimes the client creates an instance where the text is so long, it goes to the next line. first thing that comes to mind is...

 
Kaz
You know, all the lessons I've learnt refactoring code are coming in very handy with this wiring.
"Always make the smallest change that still leaves your system working as it was before"
 
@EBrown Shouldn't that last function be something like explode >> stuff >> implode?
 
Kaz
"Define the inputs and inputs and then start rearranging the intervening logic".
And, of course, "Always have a copy of your system before you started changing it" ^^
 
If your code does work it might be better suited for Code ReviewMibac 44 secs ago
 
9:13 PM
@Kaz That's what a VCS is for. Version control system for your code, and visually captured status for your cables.
 
@Zeta For what?
Oh, probably.
Looking at it now that wouldn't be a bad deal, but I actually want to modify it anyway.
 
Kaz
@Phrancis This is why I had a long talk with our sysAdmins before I started rewiring stuff. That, and I'm deliberately keeping cables plugged into the same ports as they were when I started.
 
@Kaz Live a little. ;)
@Zeta Actually it can't be, because explode returns an array, and implode expects a list, which I need to change.
 
@EBrown Would probably have lead to a type error at that point, unless string is a char list.
Ah.
 
Kaz
@EBrown Not when it comes to my work ^^ It only has to go wrong once for them to deicde "Never let Zak anywhere near IT systems ever again"
 
9:15 PM
Why don't you use the generic seq interface?
 
@Zeta But your mentioning it brings up a good point: they should complementary signatures. :)
@Zeta Because a string is already a char array so there's no overhead in processing it like that.
module String
    let explode (s:string) =
        s.ToCharArray()

    open System.Text
    let implode (ca:char array) =
        let sb = StringBuilder(ca.Length)
        ca |> Array.iter (sb.Append >> ignore)
        sb.ToString()

    open System
    let stripQuotes =
        explode
        >> Array.choose (fun x ->
            match x with
            | '"' -> None
            | _ -> Some x)
        >> implode
Bam, repaired.
You guys should see my actual logic to do the Excel stuff.
You'd kill me. :)
    match argv with
    | [|filename; mainSheetName; newSheetName; initialOffset; columnsLeft; columnsRight|] -> { defaultParameters with Filename = filename; MainSheetName = mainSheetName; NewSheetName = newSheetName; InitialOffset = int initialOffset; ColumnsLeft = int columnsLeft; ColumnsRight = int columnsRight }
    | [|filename; mainSheetName; newSheetName; initialOffset; columnsLeft|] -> { defaultParameters with Filename = filename; MainSheetName = mainSheetName; NewSheetName = newSheetName; InitialOffset = int initialOffset; ColumnsLeft = int columnsLeft }
Like that gross monstrosity.
 
Kaz
Turns out my Trading Robot crashes if the internet is disconnected ^^
 
@Kaz And then it boots up in an undetermined state and sells all currency for free
 
@EBrown What I meant is that implode can use a more generic interface.
All you need is Seq.iter.
 
@Zeta It could, and that's not a bad suggestion. For this project I only needed explode and implode for the stripQuotes.
The problem with that becomes the Length for the StringBuilder.
Sequences implicitly don't have a length.
So I would need to either initialize it with some weird default value, initialize it with no default value, or pre-calculate the length somehow.
Considering the nature of this programme, I'll just leave it with the Array requirements. :)
 
9:25 PM
And String.collect (fun c -> match c with | '"' -> "" | _ -> sprintf "%c" c) is probably to slow.
 
@Phrancis ^^^ I like the VS 2017 look better.
@Zeta No idea, I actually wasn't concerned with performance for once on this.
Basically, I'm automating a process that used to take 4-6 hours doing manually, that we do once every 2-4 months, so it could take a whole day as far as I care, as long as I can take the human factor away from it. Lol
 
Sure.
 
I'm surprised how you get away with writing F#, as you seem to be the only one with experience therein
 
He promised to write documentation.
4
 
Docuwhat?
 
9:30 PM
@skiwi I got away with it mostly because no one else has tried to do it before - I'll probably convert it to VB.NET now that I know how to make it work. The biggest issue is always getting the process down the first time, and for spending 2-3 hours entirely on building the process, it's not a bad deal.
 
@Zeta Documentation is not worth a lot when the company needs to hire a F# developer to maintain it
 
Like, my 2-3 hours of dev-time is spent from having no idea what to do, to being completely done.
@skiwi They did, that's why I'm here. ;)
 
@skiwi I was joking, but unfortunately my sense of humour isn't documented yet.
 
That's why we use std::array. Anyways, I don't think we can infer from the code what's causing the problem -- normal debugging seems to be the way to go. I'd post this question on codereview.stackexchange.com for some code improvements, however. — pingul just now
 
9:34 PM
@EBrown Fair enough, figuring it out the first time around can be difficult idneed
> If people are going to die if you get the answer wrong, pay attention!
82
A: How do you safely delete a piece of code that looks like it's never entered?

Cort AmmonThere are two halves to this process. The first is confirming that the code is indeed dead. The second is comprehending the costs of being wrong and making sure they are properly mitigated. Many answers here have great solutions to the former half. Tools like static analyzers are great for id...

lol
 
@EBrown Is that a C# specific documentation format? The /// looks like doxygen, but the XML is unusual there.
 
0
Q: Workflow with 1 or many states

CodingYoshiI have something which is a sort of a workflow. The items involved in the workflow can enter different states. Once they enter a state, they have to allow the caller to do some processing before they continue. The part of allowing the caller to do some work, I did it using a Func<boo>. Here is th...

0
Q: Generic Retry Logic Based on Action Result

GeorgethekenyanSupport for retry for action methods. One class RetryHelper that supports retry for four scenarios of action/function signature: Actions/functions with zero argument, and void return type. Actions/functions with zero argument, and generic type output Actions/functions with one argument, and g...

 
@Zeta Sorta, Visual Studio has an option to compile all /// comments as an XML documentation file during the compilation process.
It's how Intellisense works, it uses the generated XML docs to tell you what's happening.
So with all my code I have actual intellisense with more than just type names and such for those properties, classes, structs, etc.
Which makes it nice when building a large monolithic programme.
(Which is what 99% of that repo is for.) I was actually building a video game (in XNA) which is what I built all those utilities and such for.
 
possible answer invalidation by Serge Ballesta on question by Serge Ballesta: codereview.stackexchange.com/posts/173339/revisions
 
@skiwi It's also a thing that I usually end up dealing with exclusively, so it's nice to just have it done in something I enjoy and am good at. :)
At any rate, TTGH. Catch you all later. :)
 
9:49 PM
Finally, I'm under 1000 tabs in my main window :D
 
10:07 PM
1
Q: Project Euler Problem 12 in Python 3 (Find triangle number with 500 divisors)

RyanI am doing Project Euler, and 12 is the one that takes significantly longer then everything else. Here is my code: # The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be # 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. # The first ten terms would be:...

 
Kaz
10:43 PM
5 hours and 100 velcro ties later:
6
It's midnight on a Friday, definitely TTGH!
 
@Kaz Not bad. :)
@RubberDuck Apparently you can define interface implementations in F# without a concrete type.
 
Kaz
@EBrown Well, at least until somebody new turns up and we have to add some new wires ^^
 
@Kaz I mean, at least they're velcro, we used zip ties at my last job.
 
Kaz
@EBrown Who on earth thought that was a good idea?
 
@Kaz Hell if I know, that's just what I walked into man. Lol
 
10:56 PM
0
Q: Is this code _too_ DRY?

mcmurphyI have a class Comparator that does several operations (union, intersection, etc) on 'sets'. In this specific case each 'set' is a 3 dimensional array. in order to do these operations, I have to use a nested foreach to loop through each dimension before getting to the data I need to compare aga...

 
I'm voting to close this question as off-topic because there is nothing wrong with the code, the OP is asking for a code review and ways to improve working code. SO is not the site for this kind of questions, Code Review is better. — InBetween 57 secs ago
 
11:12 PM
@EBrown ahh zip ties. The other duct tape.
9
 
Chapter 17. :)
 
Have you seen this yet @EBrown? I think you'd enjoy it.
I want to implement it as my next endeavor into F#.
I need to get my abstracts in for CodeMash though.
 
@RubberDuck Are you presenting?
 
I hope to be.
 
Cool. :)
@RubberDuck Watching now
 
11:19 PM
enjoy. It's good.
 
He says "it can be done in most language except like COBOL or something" lmao
@RubberDuck When you get those done, can you email me a copy?
"Do you want to turn on narrator?" LMAO
Woah
 
11:41 PM
@EBrown sure. I can always use a proof reader.
 
@RubberDuck My email is soName.Concat(8534) at gmail.
And this video is awesome.
 

« first day (1567 days earlier)      last day (2448 days later) »