« first day (1686 days earlier)      last day (3266 days later) » 

11:01 AM
I'm trying to run a loop that reduces the array inside a .map(). However, since I have to return in there, the array isn't flattened; it always returns the mapped array.
        skills.map(function () {
            var scores = this.innerHTML;
            return scores;

            var overall = 0;
            for (i = 0; i < scores.length; i++) {
                overall += +overall[i];
            }
        });
 
> Mission: Polar hop
> Objective: visit Santa Kermin
@StevensHaen are you looking for reduce?
also, anything past a return statement will not get executed
 
@JanDvorak Yes, that's my concern
 
!!tell stevens mdn reduce
 
The problem is I have need access to var scores, hence the loop inside the block. I don't know how to solve this
 
11:04 AM
uh, what? If you want to execute something, don't put it after a return statement
 
yes, but can I hoist the scores variable? I'd like to use it when flattening the thing
 
You can assign to a variable in an outer scope, but this can smell very easily
 
http://meta.stackoverflow.com/a/295530/1835379
Flag as "Not an answer" please.
 
it will cost you 5 bitcoins
 
does multi-flagging NAA help?
 
11:17 AM
does .reduce() is not a function mean I'm not executing it on an array, but an array-like object instead?
 
probably
 
Hi all! I have a big problem with a Javascript file
 
@Marc-AntoineJacob Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
So. I just answered a question about $.globalEval, whose existence was totally unknown to me a few minutes before, using functions ajaxStop and ajaxSent, whose existence was also totally unknown to me a few minutes before...
 
ok, so I am using Visual Studio to build an ASP.NET website
 
11:21 AM
@Marc-AntoineJacob :-(
 
so I added one Main.js javscript file to the projecct
what :(
 
What do I do in cases I have to deal with array-like objects?
 
@Marc-AntoineJacob I'm not fond of that choice in technology
 
@StevensHaen [].reduce.call(yourThing, function(){...
 
oh
why?
I am using C# but this is not related to the problem
 
11:23 AM
from what I've heard, it's almost as bad as PHP
 
and I thought that PHP and ASP.NET are the best
 
ASP.NET is great. Don't listen to these hippies @Marc-AntoineJacob
 
ASP.NET is super because you could write efficient .NET languages (C# VB.NET F#)
 
PHP is popular, but that's due to inertia
 
11:24 AM
ok so so I added one Main.js javscript file to the projecct
and I called it to run in my Default.aspx webpage
and it works properly
 
Now you're just doing WebForms; and that doesn't deserve respect :P
 
but when I modifying the Main.js file
Internet Explorer continue to load the previous version of the Main.js
 
caching
 
the file doesn't change even if Im saving it
what to do to prevent ? It's very annoying this caching
 
You need to force a reload
 
11:27 AM
if it doesn't even save, are you saving to the right location?
 
yes
<script src="Main.js"></script>
ìt is simple as that
 
103
Q: How to force Internet Explorer (IE) to REALLY reload the page?

EMPWhen using Internet Explorer 8 to test my web application I often find it doesn't reload the page, so I don't see my changes. This has resulted in a lot of wasted time and frustration wondering why my fix "didn't work" - when in fact the browser never loaded the fixed version. I've tried the Ref...

 
how to force reload?
 
^
 
Stack Overflow doesn't even support IE9
 
11:30 AM
I have IE 11
this don't work
it is very strange never had this problem before
 
CTRL+F5 to force it. Otherwise, edit your Web.config to NOT send caching headers during debug
 
nothing will help with IE11 ;-)
 
this actually works!
but I heard this will slow my internet
I don't want it
 
...
 
how enable this only when VS launch my website?
 
11:33 AM
...
 
in web.config maybe
?
 
@Marc-AntoineJacob edit your Web.config to NOT send caching headers during debug
Like I said just a little while ago
 
Pastebin your web config
Should have a static config thingy
 
I am dumb with XML
 
11:33 AM
Why are you developing again?
 
I'll totally believe that it was w3schools who told you that CTRL+F5 will slow down your internet
 
<?xml version="1.0"?>
<!--
Pour plus d'informations sur la configuration de votre application ASP.NET, consultez
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
</system.web>
</configuration>
her is config.xml
 
I simply cannot make this work. I'd like to fetch the HTML tag values in an array (stringified numbers), then convert the elements to integers with + or ~~ and then add them together.
        skills.map(function () {
            //skills array consists of HTML tags filled in with stringified numbers.
             scores = this.innerHTML;
             return scores;


        });

        var overall = 0;
        scores.reduce(function (p, c) {
            overall = p + c;
        });
 
so the web.config file is pretty empty what to add?
 
@StevensHaen scores = skills.map(...)
 
11:35 AM
scores ouputs 's' in my console. When executing the function, it returns the array-like thing.
 
how come?
@StevensHaen how come?
 
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00"/>
    </staticContent>
  </system.webServer>
@Marc-AntoineJacob ^
That's pretty shitty too, but at least it won't be quite as shit as the default.
 
@RoelvanUden nice words, buddy
 
scores ouputs 's' in my console. When executing the function, it returns the array-like thing.
["42", "38", "46", "48", "48", "60", "48", "s"]
 
fiddle?
 
11:40 AM
THIS doN,t work
 
@Marc-AntoineJacob uh, what?
 
this is NOt working
 
@Marc-AntoineJacob Did you restart the server
 
how?
IIS server
 
@Marc-AntoineJacob You added quite a bit more crap there.
 
11:41 AM
?
 
@Marc-AntoineJacob And you have two webServer elements. AKA, wont work.
 
ooh so I delete one
 
@Marc-AntoineJacob You probably want to dump this in:

C#

General discussions about the c# language, Squirrels | gist.gi...
 
11:41 AM
@Marc-AntoineJacob ctrl-shift-f5 in visual studio
 
not working!!
 
7 mins ago, by Jan Dvorak
@StevensHaen scores = skills.map(...)
@Marc-AntoineJacob stop shouting, please
 
but how to do that simple thing it is frustrating
 
@JanDvorak Makes a lot of sense
 
JS is very strange
 
11:44 AM
This isn't a javascript issue
 
map works like that in every language
 
@Marc-AntoineJacob It's an IIS issue with poor ASP.NET configs layered on.
It has absolutely nothing to do with JS. Spoiler: Your CSS has the same problem.
 
you can't just assign to a variable multiple times and hope it will keep all of the values
 
but how to solve that?
 
@Marc-AntoineJacob Read.
 
11:46 AM
I have heard that put JS code in separate file is good
4
I read !
 
@Marc-AntoineJacob keep reading
 
Protip: Let go of IE, start using Chrome and its Network tab. You'll learn something.
 
and then I did var overall = 0; scores.map(function(x) { overall += +x; return overall;}) to no avail
I tried this as well
 
11:48 AM
@StevensHaen ew
learn how map works
 
@StevensHaen Map creates a new array from things you returned.
It's not a forEach. For that, you have forEach.
 
Is { overall += +this; return overall;} possible? I'd like to add all entries to overall
 
oh dear god
 
@StevensHaen possible, but not what you're looking for
 
You're just trying to add all elements of score to overall?
 
11:51 AM
it will create an array of partial sums
 
boy, this isnot working
 
You don't use map for that
 
I can reduce() as well, exploring different options
 
do show your reduce approach
 
11:52 AM
yeah, reduce is definitely the way to go
 
@JanDvorak I'll have to add previous and current and then assign their sum to overall
 
so show us how you do it, and we'll tell you what's wrong
 
Let me take a leak first.
 
@StevensHaen TMI
 
If this was ruby, you could just do scores.reduce(:+). To be honest, I didn't even know js array had these function
 
11:55 AM
hi !
can you help me please
 
@Cereal sum = foldr1 (+)
 
my problem is not specific it is major!
for the love of JS
 
@JanDvorak haskell?
 
that's ruby
 
@Cereal yes
 
11:56 AM
@Cereal (reduce #'+ scores) in lisp
 
languages are fun
 
@FlorianMargaine not very readable though :P
 
Ok, so I flattened it like this var overall = ["42", "38", "46", "48", "48", "60", "48", "s"].reduce(function(p, c) { return p + c; }). It added all elements to a string. I have to change their type first with ~~
 
@AwalGarg I find it very readable
 
please...
 
11:58 AM
and elegant
@Marc-AntoineJacob we won't be able to help you if you don't tell us the problem
 
the problem is that my JS file are not working
 
@FlorianMargaine I find the plentitude of sigils kinda confusing but that might be due to lack of practice
 
I save it and they are not updated
 
Clear cache
 
@RichardHousham Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
11:59 AM
when I run it with Visual Studio
 
@JanDvorak yeah, #' and ' are common in lisp
 
I also found the core lisp kinda low-level
 
Hi is anyone round here familiar with ckeditor to a javascipt level?
 
@JanDvorak 'foo is a shortcut for (quote foo), and #'foo is a shortcut for (function foo)
since both are used quite often
@JanDvorak ?
i.e. disassemble?
 
How come you know so many languages?
 
12:02 PM
I know JS and Lisp
 
Can't quite remember what I was trying to do. A map with string keys, IIRC
 
how is that so many?
@JanDvorak ah, hash table?
 
@FlorianMargaine and C and php and haskell and others...?
 
@AwalGarg Probably used them for something in the past
 
12:03 PM
@AwalGarg not so much for haskell, I've mostly gone through the getting started and read a bit
 
@FlorianMargaine I think so. IIRC it used object identity rather than equivalence (which isn't useful for numbers or strings
 
I know like a dozen languages, but only fluent in like 2 at any given time
 
Is that a no then?
 
@JanDvorak yeah, tests for keys in hash tables uses eq by default
 
@Cereal he is a php-src internal, so I am sure he is pretty fluent in C and PHP.
 
12:04 PM
Lisp is the only language I know that has object identity for numbers
 
does it?
 
@FlorianMargaine OK FINE NOOB
:D
 
@JanDvorak are you sure about that?
 
@FlorianMargaine I think so. I think I was fighting with numbers being tested for identity when I wanted to test for value
 
@JanDvorak ftr, when creating hash maps, you can define the identity function. I usually create my hash table using (make-hash-table :test #'equal), which means it works with string keys
 
12:05 PM
Is it good practice to write true as !0?
 
@Charly no
 
@Charly no
 
@JanDvorak I think it was for strings... it's not the case with numbers afaik
 
thats what js minify did...
 
useful for golfing, however
 
12:06 PM
@Charly yes
if you want to minify the code
 
@Charly well, it's a minifier.
 
@Charly you are not a minifier.
 
ok
 
@Charly minification isn't about best practices
 
@Charly you are Charly
minification is about cost efficiency $$$
 
12:07 PM
@neoares i dont think i am
 
impostor
 
@Charly then why do you claim to be?
 
Houston we have problem.
 
also is it ok to put if/else statements in ternary?
 
@Charly depends.
 
12:08 PM
Guys, which is the recommended hosting service provider for M.E.A.N. stack (angular + node) websites?
 
depends on what?
 
wait, did you just say, "if/else" statements in ternary?
Or you mean instead of ternary?
 
yeah instead of ternary
sry for my bad english
 
I think you actually mean ternary instead of if/else?
 
like which is better to use, if/else statements or ternary
 
12:10 PM
depends. Nested ternaries are almost always unreadable
 
wont be nested
 
._.
 
for stuff like: if (foo) bar(); else baz();, you can do foo ? bar() : baz().
 
then they might be fine
 
for anything more complicated, don't.
 
12:10 PM
In case of doubt, a if is always fine.
 
thanks...
 
@Charly Whatever is more readable. If it's not more readable, don't do it.
 
But sometimes, there are better solutions than those
 
nested ternaries are sometimes ok when written with precision, but they are rare.
 
12:11 PM
I'd even say - ternaries are fine for flow of data, for flow of code use if/else
 
I only use ternary operators for return statements or variable assignment
 
most of the times, short-circuit evaluation is enough and more readable.
 
I had a double nested ternary operator in a HAML file the other day. Choked when I saw it
 
@AwalGarg you'd love jquery
 
@FlorianMargaine yeah, jquery source code is horrible.
 
12:13 PM
yes, ternaries, along with parameters whose naming only matches one of the possible calls, are a source of the jQuery source uglyness
 
I'd say, use ternaries / short-circuiting only if you use the resulting value afterwards
 
short-circuit should only be used in conditions, not for control flow
 
I think in jquery there is a function that uses a,b,c,...A,B,C,...aa,ab,ac
 
foo && bar(); is OK as well as if (foo) bar(); @Charly
 
lots and lots of variables
 
12:14 PM
@AwalGarg yeah, I don't like that
 
@Charly that's jquery.min
 
@FlorianMargaine yeah it is subjective. I don't like it much either specially after learning python.
 
if foo: bar()
 
but atleast it is more commonly readable :/
 
12:15 PM
yes
 
bar() if foo
 
tis great about python that conditions in if don't need parens :D
@JanDvorak ruby! ruby so nice
wait that is in python too
i think
 
foo or die()
 
yeah, in python 2.5 and more
 
@JanDvorak isn't that php? :P
 
12:17 PM
print a if foo else bar
^ python :D
 
originates in perl, I think
 
@JanDvorak I prefer exit. die sounds brutal :P
 
@AwalGarg ruby would be bar if foo. Parenthesis are optional
 
ahh right
 
@Cereal right. I hate that.
 
12:19 PM
@Cereal oh. right
 
I had to work on some ruby code this week
 
@FlorianMargaine you get used to it...
 
I like it, but only on functions with no parameters.
 
() less functions are in JS too :P
 
You can do like foo :a, :b, and I think it looks horrible. Much better with foo(:a, :b)
 
12:20 PM
get :rich or die "trying"
 
This question is asked every two minutes but high rep users still don't understand why this in a callback isn't always the external this ^^
2
A: jquery losing value of $(this) on ajax request

AmmarCSEYou need to preserve $(this) in a variable for the callback like var that = $(this); $.ajax({ type : "POST", cache : false, url : $(this).attr('href'), data : $(this).serialize(), success : function(data) { $('.loading-ico...

 
@Cereal disagreed
 
Please don't spare your downvotes
 
Yeah? One parameter is okay too
 
@DenysSéguret lol
 
12:21 PM
I was wondering where the value was returned to
 
@rlemon rebeccaaaaa <3
I now send this link every friday morning on my company's chat
 
@FlorianMargaine ew
 
@FlorianMargaine that code feels like it is suffering from malnutrition.
 
thisismy.horse uhh, nsfw
 
12:24 PM
@JanDvorak which part?
@AwalGarg ?
 
@FlorianMargaine metadata - function is used for side effects without having a name that indicates a side effect
 
      end
    end
  end
end
 
metadata and userdata are terrible function names
 
^ every time I see this in ruby/python/es6+ ...
 
yea
 
12:25 PM
^
 
metaData and userData are better
 
@AwalGarg in lisp it's )))), much better
 
@rlemon not really
 
}}}}
 
@Loktar As if anybody uses polymer
 
12:26 PM
})})})})
 
@JanDvorak notReally*) and, yes_really
 
@FlorianMargaine same thing
 
I use asd_asd for variables, asdAsd for functions, and AsdAsd for classes
 
In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure. This article largely addresses the free-form languages, such as C programming language and its descendants, but can be (and frequently is) applied to most other programming languages (especially those in the curly bracket family), where whitespace is otherwise insignificant. Indent style is just one aspect of programming style. Indentation is not a requirement of most programming languages, where it is used as secondary notation. Rather, programmers indent to better...
 
Although PyCharm keeps insulting me
 
12:30 PM
^ relevant
 
about PEP8 convention
 
@AwalGarg ;}
 
@AwalGarg Who programs like that?!
 
@Neil python developer, when he writes java
 
user2620028
arguing and complaining about coding conventions == internet discussions about programming
 
12:31 PM
@AwalGarg Ah, that explains a bit actually ;}
 
:D
 
Do we know when ES6 is going to be implemented? Or is it already?
 
implemented in what?
 
user2620028
i believe the rumored implementation date is rumored to be delayed :P
 
12:33 PM
Major javascript engines
 
spidermonkey has implemented large parts of ES6 like rest and default params, destructuring, classes, arrow functions, shorthand functions in objects, etc.
 
> At first I was like o.O then I saw the right edge and was like O.O
 
user2620028
Hahaha same
 
@rlemon lol at some pictures
 
@rlemon can you upvote that comment on my behalf? I don't have a reddit account :P
 
user2620028
Is that some sort of condom character?
 
that is me
 
user2620028
Guess who got a job teaching English. It is the same guy with no teaching experience and no background check.
 
I am thinking of answering a java question on SO with that kind of formatting :P would be fun
 
12:38 PM
@AwalGarg I'm sure that would go over very well
 
XD
 
@AwalGarg ask a question like that
 
@JanDvorak Well what do ya know.. learn something new everyday
 
@JanDvorak I don't do java so I don't know what to ask. But I can answer a help vamp by googling for him.
 
Why does chrome have 14 processes for 8 open tabs..
 
12:39 PM
@AwalGarg but shouldn't
@Cereal press shift+esc
 
@Cereal extensions?
@JanDvorak but... fun!?
 
Apparently I have extensions running I didn't know I had installed
 
such as?
 
Chrome also allows extensions to declare themselves as un-removable.
 
tampermonkey and stylish
Didn't think I had them on this computer
 
12:42 PM
@Cereal sync
 
Does anybody here uses a linter for node code ?
(not to tame colleagues, for somebody knowing js and wanting to check for possible errors)
 
@DenysSéguret yeah, jshint
 
jshint for life!
 
I don't code for node, but I like jshint
 
@rlemon Ugh, people re-posting tweets for reddit karma :P
I finally figured out how to get those pesky semicolons and curly braces out of my Java code http://t.co/Ns96HdCuKO
 
12:50 PM
I think I've seen this picture in many tweets in the recent months...
 
@OliverSalzburg It is a link sharing website.
 
@Cereal There's a difference between sharing a link and copy a picture from someone and putting a new title on it
 
@OliverSalzburg No there isn't
 
@Cereal Oh, okay, that completely changed my mind. Thanks for pointing it out
 
No problem
 
12:55 PM
I agree with me
 
hello guys
 
@Cereal can you also completely change my mind. I want to like libraries and frameworks :(
 
@DenysSéguret I used both JSHint and JSCS before I went down the TS route.
 
@AwalGarg Everyone's a better programmer than you, better to use their shit than yours.
 
Wow my mind completely changed, thank you.
!!doge argument, shit, code
 
12:57 PM
@Cereal make me friends.
 
    wow
            very argument
                            such  shit
so  code
 
I hate when people say that development is all about standing on the shoulders of giants, because it makes it seem like you can never do anything great, only use other people's work to make shit apps
 
i use this lightbox js library to display images
it is working as expected but what if i have many images
i need to create paging for those img tags
so instead of displaying all images at once in page , i need to only display 10 for example with Next-Prev or 1 2 3 4 paging ,
does that library have something like that ?
if no , is there any idea to add paging to this js
http://lokeshdhakar.com/projects/lightbox2/
 
Isn't programming literally using tools to build something? Why would I create a hammer to hammer a nail, when I can just buy one from a store
 
!!tell Bassem examplepls
 
12:59 PM
@Bassem Could you please give us an example of on jsbin.com or jsfiddle.net, with the minimal amount of code necessary to reproduce the problem?
 
@Cereal because maybe you need to design new hammers and need to figure out how they're made.
 
sure
 
@AwalGarg Shitty developers lost their time making boring easy libraries. Don't waste your superior mind writing such boilerplate code, use your mind at better tasks
 
@rlemon Well yeah, if you want to know how a hammer is made, make a hammer. Or if you need a hammer that unscrews screws, make a hammer
 
@DenysSéguret thank you, much more realistic argument.
 
12:59 PM
@Cereal It depends. Using tools is great and all, and makes life easier, but when you try to adapt a Car to fly you're going to have a bad time. Better design that flying machine from scratch.
 
or if it's trivial to make a hammer, make a hammer
 

« first day (1686 days earlier)      last day (3266 days later) »