« first day (1154 days earlier)      last day (2857 days later) » 

12:04 PM
Monking
 
TL;DR: Driver was crazy enough to do things with the automatic driving that the company producing the car (Tesla) never agreed upon.
 
natural selection at work
 
I hope it ends well for Tesla, so far there doesn't seem anything to blame them legally, but they could update their detection
 
I did consider putting this on Code Review but it seems a little short for that. Is this the right place for this type of question? — josh 31 secs ago
 
public Dictionary<ExtraCostType, string> ToDescriptionDictionary { get; } = new Dictionary<ExtraCostType, string> { };
You know C# right @DanPantry? ^^
Oh
 
12:09 PM
@skiwi debatable
 
I didn't put that inside the enum
 
@skiwi yes =.=
 
Are you aware Python has a slicing operator? — Mast just now
 
Ahoy there landlubbers.
 
Anyway, I wanted to add a static property to an enum, but it looks like that's not possible
 
12:12 PM
lol nope
does this look like Java to you
 
@Mast Do you have time to look at something?
 
@skiwi enums are just, well, enums. they aren't classes.
they can't have properties of any kind.
 
I think your question belong on codereview.stackexchange.commeucaa 11 secs ago
 
they are more akin to a group of constants (C-like enums) rather than the bastardised enums in java
 
12:13 PM
Java enums rule
 
@JeroenVannevel LMFAO
that looks like when someone from SO suggests CR for migration and one of us steps in
which makes sense because SO are usually in their own bubble anyway
 
pastebin.com/Y8Q25hYd does this look reasonable until I implement i18n?
 
@skiwi and pastebin is blocked again (it wasn't yesterday
 
@JeroenVannevel WTF lol
@DanPantry Try adding https in front
 
@skiwi wow. that worked. so this proxy is still doing the whole herp derp rewrite response thing
That looks fine, but C# has an attribute for that sort of thing
 
12:15 PM
Though I see that I could also add an extension method to the enum and add a GetDescription there and switch on the enum
 
@N3buchadnezzar Time, yes. Without knowing what exactly I agree upon I can't guarantee I'm of any help though.
 
enum ExtraCostType
{
    [Display(Name = "Fuel Cost")]
    FuelCost,
    ShippingCost,
    ShippingIncluded
}
you can also use Display for localised strings through resource files
[Display(Name="TranslationTagName", ResourceType=typeof(ResourceFileType)]
 
Ah I was under the impression that that Display attribute would break down when going to i18n so I avoided it
 
@Mast I have a list of numbers a. If a[i] % a[j] == 0, I want to remove a[i]. Where j =! i
 
I have written a code to do it, however I really dislikes it.
 
@mods Are we transitioning to the July challenge right away? meta.codereview.stackexchange.com/q/6740/27623
 
@N3buchadnezzar [i for i in a if i % a[j] != 0]? I dunno how you get a[j] so... ):
 
@JoeWallis a[j] is any element in a.
def remove_duplicates(divisors):
    i = 0
    divisors = sorted(set(divisors))
    divisors_len = len(divisors)
    while i < divisors_len:
        j = i + 1
        while j < divisors_len:
            if divisors[j] % divisors[i] == 0:
                divisors.remove(divisors[j])
                divisors_len -= 1
            else:
                j += 1
        i += 1
    return divisors
Really not happy with the .remove() part :p
 
In which I explain why XSS is not a javascript problem
I guess I know more about security than I originally thought I did
 
12:33 PM
Dunno looks good, you could try changing the while j < divisors_len to use enumerate(i + 1, divisors[i + 1:]). But I have to go, ):
 
Hint: basically you are asking about improving existing, working code. That could also go to codereview.stackexchange.com — Jägermeister 16 secs ago
 
monking
 
0
Q: Improvements on JavaScript code for displaying "tooltips" in Highcharts?

vitozevI have the following piece of code: for (var i = 0, len = legend.allItems.length; i < len; i++) { (function (i) { var item = legend.allItems[i].legendItem; item.on('mouseover', function (e) { var posLeft = 0, posTop = 0, parentWidth = cha...

0
Q: Recursive Scala Case class Reduction

sparkrI have a case class that is recursive and looks like this: case class Config(name: String, isEnabled: Boolean, elems: Map[String, MyCase]) case class MyCase( id: String, isActive: Boolean, elems: Option[Map[String, MyCase]]) Where the Config contains the id of the MyCase entries contain...

 
Hello @RobertLong
@janos Hello!
 
hey @syb0rg, how are you?
 
12:37 PM
@janos Pretty tired
But hey, it's Friday
Can't complain
 
hey @janos, hey @syb0rg
 
hey @skiwi
 
@JoeWallis Won't enumerate get messy when you remove from divisors? @N3buchadnezzar
 
@Mast I just feels it is a really long code to do something simple
 
Hey @Pimgd
 
12:43 PM
stalk stalk
 
@N3buchadnezzar It's pretty readable I think. Probably not the most straight-forward way.
 
Maybe post it on CR
 
-2
Q: Python - What am I doing wrong?

tom790def ICP(x): numofrepeat=0 warning=0 x_str = str(x) while x_str[numofrepeat]=='2' or x_str[numofrepeat]=='3' or x_str[numofrepeat]=='5' or x_str[numofrepeat]=='7': if (x[numofrepeat]==0): warning=warning+1 if warning>1: numofrepeat=len(x)+1 if warning>1: return("false")...

 
today's rant about frontend programming: ng-disabled doesn't block ng-click on a div, but does on a button
 
angular is designed for forum manipulation that's why
 
12:48 PM
that sounds at least 3 steps of reasoning away from the direct cause
 
<button> was originally an <input type='button'> which 90% of the time was only found in forms
 
That's quite far away from the real reason
The real reason is that <div> is not meant to be used as a vector for human input
 
from my best understanding of angular, you can't disable something that was never enabled
 
It has no disabled attribute in the DOM
 
my div does
 
12:50 PM
button, input, textarea and so forth - actual input elements - do
 
why do you need to use a div for input? if it needs to be that large use a textarea like @DanPantry said
 
@Pimgd No, it doesn't. See the w3c specs.
<div> does not have a disabled attribute in the spec
If you're using a <div> as an input you should also be aware that because it is not triggered from a button/href any pop ups and such will be blocked by popup blockers by default.
use <button>.
 
there are no popups
 
I know, I'm just warning you
 
it's just gonna call a function in a directive
 
12:52 PM
If you use window.open or similar inside of ng-click on a <div>, you're going to have a bad time.
I'm only warning you because we fell prey to that recently
 
I'd have a bad time if I used window.open anywhere
 
@Pimgd Why? Are you using MS-DOS?
 
@syb0rg and the award for the lamest joke goes to....
 
no, I'd get murdered by co-workers
clubbed for not following standards
no popups! slide a div into the screen if you must have a "popup"
 
@DanPantry Well idk, first OS that popped into my head with a CLI
 
12:55 PM
@Pimgd window.open should only really be used for things like OAuth, where you have to actually open a window to an external site
Within the same domain, a <button> should prefer to trigger an action on the same page
Otherwise you should use <a>
@syb0rg lol :) window.open is a javascript function, though
 
And this is why I'm not a web dev
 
welp, fixed it
ng-disabled="condition" ng-click="condition || action()"
 
@syb0rg I mean you can say "screw it" to semantics and just use div soup, but that won't help anyone ^^
@Pimgd are you using ngDisabled for a style hook?
 
1
Q: Test if a string is a palindrome

481b8423202598ecfb233c5fa68cafI got this out of an article on interviews / code challenges. The challenge text goes like this: A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and wo...

 
yes
 
12:58 PM
if so I would prefer to use ng-class='{className: condition}' ng-click='condition || action()'
ngDisabled is not semantically correct on a <div>
better yet, you can use React and forget about all these stupid proprietary directives
 
@DanPantry I am not allowed to go over budget by a factor 100
 
@syb0rg Web devs are a rare breed
 
@Pimgd but going over budget is fun in seeing how execs react!
 
... basically we're using angular after failing with a weird java/server-side javascript hybrid
gotta rewrite all the features
"hey, let's use react" 6 months in is gonna be met with stabbings
 
1:05 PM
yes...
but needs some work
basically, you have a diff tool that says...
"yep, this file changed"
what changed?
"the first character got removed, the second character got replaced by the same character, the third character got replaced by the same character, the fourth character ..."
it's basically saying that it's some useless output which is technically correct?
 
possible answer invalidation by throck95 on question by throck95: codereview.stackexchange.com/posts/133504/revisions
 
nope lol - modified my code to remove redundancy :)
 
you sure...?
 
@Pimgd i mean it's my question and I just added a method that does what was common between two methods
 
Yep, rolling back
> You are open to SQL Injection via the $urlid parameter
you renamed it to $urlId
further more, that's a lot of code edits
and the reasoning "eh, it's an improvement" means that it should be an answer
 
1:14 PM
You mix between snake_case and camelCase (and sometimes just nocase, eg urlid). Choose one and stick with it.
I'm modifying the code based on tim
 
you don't edit code after getting answers
89
A: For an iterative review, is it okay to edit my own question to include revised code?

200_successYou have several options for follow-ups: Accepting an answer If one of the answers gives you good advice with clear directions for improving your code, just accept the best answer and upvote any other answers you feel were helpful. The checkmark that you confer is the best way to show appreci...

> You must not edit the code in the question, as that would violate the question-and-answer nature of this site.
> (An exception to that would be if a user wrote a comment saying that your code is completely broken, and needs to be fixed before it can be reviewed.)
 
Keyword: before
 
@throck95 if you want to get your new code reviewed, post a new question and accept tim's answer
@tim had the same idea (he's not in chat tho)
@throck95 Also, I reverted your edit, see What you may and may not do after receiving answerstim 1 min ago
 
yea I saw that, he did tho give me the direction i needed to make those edits and come back with a new question which is ultimately what i was going for :P
 
@throck95 thanks for understanding
We crack down on answer-invalidating edits pretty hard
 
1:21 PM
I'm voting to close this question as off-topic because it belongs on codereview, as it seeks improvement in working code — The Archetypal Paul 39 secs ago
 
but that's because if you let an edit like that stay for several hours then you'll have answers addressing rev1 and rev2 (so to say) and there's no way to clean things up anymore without removing someone's hard work
 
understand, biggest thin im working on right now before coming back with a new question is setting up the sanitization of URL input that is effectively random
 
if possible, make your questions targeted to a specific area, then they're not as huge
 
yea that one was rough because i hadn't had a code review yet and I was so far in
this was a huge conversation that was had yesterday with @Mat'sMug lol
 
takes skill to know when to stop digging yourself deeper into the hole and ask for help
 
1:25 PM
you got any links on good sites that explain some of the key things I should be checking in my input?
 
... not really
 
k, figured i'd ask
thanks
 
Made this image for a question I just asked ^^
 
i see math, should i be scared?
 
1:30 PM
@throck95 Nah, just be swayed by the pretty colors.
 
@N3buchadnezzar pretty on the outside, grey in the middle :(
 
*Marine blue
 
2
Q: Project Euler 1: A sledgehammer to crack a nut

N3buchadnezzarThe problem Project Euler 1 is one of the most asked questions on site. However I wanted to solve the more general problem of division. Multiples of a list If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23....

 
@DanPantry And it doesn't seem to be working either
@CaptainObvious "I have not put much though into the naming nor adding docstrings. This is because the code is not quite complete."
that's a question how
 
@Pimgd mm?
 
1:41 PM
Apparently we "don't use buttons"
but we do have <button> in the html
 
@Pimgd wtf lol
 
I tried to do it with div because "we don't use buttons" and... yeah, it doesn't work
time to revolt and use buttons anyway
 
just use button it'll save you less pain in the long run
 
@Pimgd I just moved that part. Sorry
 
@N3buchadnezzar It's a big red button, you have to press it. The why doesn't matter
 
1:46 PM
where will you be when build failure strikes
> Questions:
but then only 1 question
I think it can just go
always wanted shorter etc
 
@DanPantry
Any experience with Twitter/FB buttons?
 
@JeroenVannevel No, sorry
 
They take about 7 seconds to load their JS/HTML
 
@JeroenVannevel Display a static image with onclick set to whatever it was that made it blue text before
then swap it out for the real hidden element when it's done loading?
poof magic?
 
@N3buchadnezzar I think I've found a way to simplify the function! :) I had to go to lunch, otherwise I'd have said here earlier, ):
 
1:50 PM
That's my bad, but perhaps possible suggestion
 
@JeroenVannevel wait, are you doing that on document load or document ready?
it won't eliminate all 7 seconds but if you put it on document load it may be quite a bit faster
 
@JoeWallis Just leave an answer once you have time man, no hurries or worries.
Hakuna matata
 
25
Q: Why can <script> Tags be visible?

wutzebaerIn our Project it occured that a script-tag got display:block and was visible because of that. Is there any Usecase where it is wanted? td > * { display: block; } <table> <tr> <td> <script type="text/javascript"> var test = 1; </script>von 1 </td> <...

wot.
 
@DanPantry lawl
 
2:11 PM
@DanPantry I tried putting it on doc load and it didn't make a difference
giving it async or defer attributes didn't change it
putting the JS at the end of the file didn't help either
 
put it in a table cell which has the background image of a facebook button
(Pim no, pls stop)
 
Switch to React /s, FB integrates well with that
 
One thing that might be an influence is the fact that I'm testing this locally. Maybe fb/tw are trying to do a lookup on my domain and they can't reach it?
 
maybe block FB entirely
 
@JeroenVannevel not sure to suggset... maybe the connection to your pc is crap
 
2:14 PM
contact your inhouse IT - "localhost is slow" /s
 
@Pimgd lol
 
don't think that's it
3
 
the connection from the fb server to yours can still be crap even with great download speed
 
Yes but no
 
Have you tried looking at the network tab of chrome your profiler
 
2:16 PM
1ms pings to the server in question
 
then idk
as pimgd said, profile the request
 
Monking.
 
Banana
 
Not sure what to look for in there
 
@JeroenVannevel the length and colors of the bars
 
2:18 PM
@JeroenVannevel find the request that is sent for the fb icon
see how long the bar is.
 
there's a shitload of googleads requests
 
and when it is triggered
 
@JeroenVannevel you can filter (in chrome atleast)
look for "cdn" or "fb"
 
it's not the images (if I interpret correctly)
 
Yep, none of those requests are taking a long time at all
They aren't being run until 7-8s in, though
so something is prevent them from running sooner
I'm going to go ahead & guess javascript is adding those buttons, right?
 
2:22 PM
what's that long top one
 
if that's the case then the javascript that spawns those elements isn't being added until 7-8 seconds in
 
that greeeeey one
 
@JeroenVannevel you can drag across the top bar on the timeline to select an area to examine BTW
It's not on there @Pimgd it's probably a ws connection.
 
grey one is websocket
 
2:23 PM
oh
 
i think there's some js that adds those buttons
and it isn't being triggere duntil later on
 
So you're saying this JS belongs at the top of the file?
 
No....
I'm saying there is some js that is doing something like this
document.appendChild(document.createElement('share-button')) (or something)
and that isn't being run until 7 seconds in for whatever reason
 
So yes, that js you're talking about is in there but it's contained on the twitter side
 
add breakpoints in teh chromes
wait you can't because it's... inline JS
why do you have inline JS
 
2:27 PM
I copied it from the docs
We have a razor helper to put js code at the end of the file
separate js files aren't really used
 
@Pimgd You can, use the sources tab of chrome
 
ooh
so put a breakpoint
and then you wanna know, when does it run?
 
I just did
Breakpoint gets hit immediately
 
also
stab stab
if (d.getElementById(id)) return;
if (!d.getElementById(id)) {
 
2:30 PM
what is up with these functions, doing the same thing two different ways
 
I'm not touching the default doc functions
but
that's the facebook sdk
 
s/sdk.js/evilFbLogger.js/
 
5.69s of content downloading
 
0
Q: asp.net core mvc read image from folder and display

vsarunovI have a question concerning the correctness of the reading and displaying the image in asp.net core mvc web application. So this is the code: This is the way I am reading image names from a specific folder: public class GetRandomImageForGalleryView : IGetRandomImageFromFolder { ...

 
@JoeWallis Great idea! I always have troubles when it comes to removing elements vs creating new lists.
 
2:32 PM
Greetings, Programs.
 
> P.S I am using asp.net-core-mvc (Which tag I cannot create due to reputation lack)
 
I think this question is better suited for the on the code review section of Stack Over flow. codereview.stackexchange.comBearcat9425 46 secs ago
 
anyone know the difference between and - and whether it warrants a separate tag
 
Thanks, :) I hinted to it not working with negatives, so if at some point you want it to work with negatives you can do `sorted(set(divisors), key=abs)`, but then sometimes you may get positives sometimes negatives...
I normally make a new list if I'm removing from a list whilst looping through it, it's just a PITA to make it work
 
@Duga crexit
gotta get our independence from the evil SO
 
2:36 PM
lol
 
@JoeWallis Yeah, negative values will never be a problem. Removing values from the list while iterating truly was a pain in the abdomen :p
 
if it works, then we'd be happy to have it over at CodeReview stackexchange — Pimgd 1 min ago
 
2:48 PM
I would post it over @ "CodeReview", since to me it def. looks like valid working code. I feel that this is considered TDD development, granted its pretty basic but it gets the job done especially in a real world environment. Was this for a job interview or school project? — Kevin B Burns just now
 
@Duga added edit suggestion to clean up the spelling so that it can get migrated instead of double posted
XKCD puts plots in perspective:
 
@LeakyNun Abuse? That's what balancing groups are made for. :D — Martin Ender ♦ yesterday
 
what is this heresy
 
@Pimgd Are really rocket launches that more dangerous?
 
@N3buchadnezzar nascar car hits wall.
Driver is fine-ish.
Rocket hits wall.
Driver is...
 
2:58 PM
I would think that if a formula one car crashed into one of the spectactor booths more people would die than in a rocket crash.
 
@N3buchadnezzar That doesn't work like that...
 

« first day (1154 days earlier)      last day (2857 days later) »