« first day (1645 days earlier)      last day (3307 days later) » 

1:05 PM
Do any of you know how to implement Array#reduce using Array#reduceRight?
 
@AaditMShah What do you mean?
Just use a .reverse() ?
 
No, without using .reverse how would you implement .reduce using .reduceRight?
 
You would make your own version of reverse.
 
* rolls eyes *
No, you can't reverse the array before reducing it.
You can only use higher-order functions.
Even then, you can't reverse the list before reducing it.
 
Don't be assy and "roll your eyes" in here.
 
1:12 PM
Any clue on how to implement reduce using reduceRight?
 
Are you just curious about how to do this sort of thing?
 
[3,2,1].reduceRight(function(prev, curr, i, arr) {
	curr = arr[ arr.length - i - 1];
	console.log(curr);
	return curr + prev;
}, 0);
It will print 3, 2, 1, and then 6
Instead of 1, 2, 3
 
@Catgocat That's cheating.
 
I have a huge headache right now.
 
@AaditMShah So don't ask stupid things, if you don't want to implement the solution for it.
 
1:14 PM
@Qantas94Heavy I already know the answer. Just wanted to see how many people could get it.
 
Wow, I've finally found a book that is about English or literature in general that does not say "say it out loud" in order to become fluent.
 
So we're just talking about the various Array methods (except reverse)?
 
@Catgocat It's not a stupid thing. It's actually quite interesting.
 
@AaditMShah Well I gave you my solution happy now
 
@Qantas94Heavy No, just one array method .reduceRight.
 
1:18 PM
So passing along the values to the next call would be cheating?
 
@Catgocat Not really. Your solution makes use of extra arguments i and arr. You don't need those extra arguments.
 
!! mdn Array.reduceRight
 
What do you mean by passing along the values to the next call?
 
the mdn has even an example of it ...
just check that
 
1:20 PM
No, it doesn't.
Okay, the answer is:
function id(x) {
    return x;
}

function reduce(array, callback, value) {
    return array.reduceRight(function (continuation, current) {
        return function (previous) {
            return continuation(callback(previous, current));
        };
    }, id)(value);
}
 
Of course because that's much for efficient than mine.
 
It's not about efficiency. It's about the concept of continuations and endofunctions.
BTW, endofunctions are used in transducers to make map, filter, etc. faster.
The optimization is called deforestation and it is used to combine multiple loops (e.g. array.map(f).filter(g)) into a single loop.
 
If you had mentioned that.
 
Yes, you just thought that I was a stupid noob didn't you?
 
Hi
 
1:29 PM
If you are interested in the theory behind endofunctions and left to right compositions then you should read this answer:
1
A: define Foldleft by using Foldright in OCaml

Aadit M ShahLet's dissect the Haskell implementation of myFoldl and then take a look at the ocaml SML code. First, we'll look at some type signatures: foldr :: (a -> b -> b) -- the step function -> b -- the initial value of the accumulator -> [a] -- the list to fold ->...

@darkyen00 Hi Abhishek (if I am not mistaken).
 
No you are not.
@Loktar I am going to go with my choice of doing something else.
after this year :D (college year)
 
Which one would you hire to build a commercial website for your shopping mall:
1) Knows how to gather requirements to build something. He cannot code better than the other example person so he is going to choose automated, already built or some cheats to get the project done.
2) Has 10 years experience in working at a company as a coder. He never had practical experience in planning or managing projects but he has pretty solid skill in coding. He is fluent in every major programming languages and has neat portfolio and a quite large-scale personal blog about coding.
 
1
 
Because I would do the 2) job
 
1:39 PM
ah haskell, with its syntastic sugar
 
you cannot hire both because you are poor, choose 1 carefully
 
@EnglishMaster 2)
Well
2. if you'll need to maintain it in the future
 
1. if you code and move on to other projects.
 
1. because I could do what the second example person would do
:p
 
1:40 PM
well, maintenance is automated too nowadays
 
@EnglishMaster Bugfixes are not yet automated.
Otherwise most of us would be out of a job.
 
you just need to hop on some software and click some buttons and maintenance is done
well, "already-built" means you pretty much have no bugs
 
Link please.
@EnglishMaster There's a program out there that can fix my bugs for me?!?!
@EnglishMaster That's bullshit.
 
Yes, it's called a debugger. Thank me later :D
 
@Meraj99 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.
 
1:42 PM
@EnglishMaster What is this magical software?
 
well, guy 1) can always outsource his work to India if he encounters some bug, but it will rarely happen because he's going to use Wordpress
 
1. For long term, not wise, since platforms changes and libraries needs updates if the dev is relying on it. On short term, it works. If you aim for 2-year updates of your site design, then yes

2. In the start, it may lead to problems, because you are paying for "learning money" (don't know what's it's name in english). But when the time goes, he can develop skills in project management, which is a great use for next (future) projects

So i take 2.
 
@EnglishMaster You think WordPress is bug free? Express? NodeJS?
There is exactly 0.00 amount of nontrivial software that's bug free.
 
^--
or QA shit wouldn't exist
 
Go to any semi-major project on GitHub, anyone at all
And you're guaranteed to find at least 10 open bug tickets.
If you're building something for a client, they don't care whether it's your code or "MallExpress™" pre-built solution you've used for the job
The moment you've used it, it's you're code
And when it fails due to a bug or a security fault, it's your job to fix it.
 
1:45 PM
function calculateSumOfTwoNumbers(number1, number2) {
	var result = number1 + number2;
	return result;
}
calculateSumOfTwoNumbers(1, 1)
 
The client won't accept "but it's a bug in MallExpress"
 
@SecondRikudo then you can advise your client "you must contact MallExpress directly in order to resolve this issue"
like Microsoft does
 
@EnglishMaster No, mate. I hired you
I hired you to build my website, not MailExpress
 
Just murder your clients
with cookies
 
Yeah but you can then tell your client "sorry mate, I already have all your money. Peace."
 
1:48 PM
Uhh, not if you ever want a client again
 
you can always switch your company name
 
@EnglishMaster now you're just trolling.
 
You can also rob old ladies
 
it's simple as buying a new domain-name nowadays brah.
 
@Zirak ^
@Zirak has experience.
 
1:49 PM
Some people are just stupid
 
I would never do it @Zirak
 
Are you advocating robbing old ladies?
I didn't think so
 
I would never do it, personally, but other people can rob old ladies; that's fine with me
kick
 
1:50 PM
Why are you robbing imaginary people
 
Zirak has a boyfriend, everyone knows this
 
They're defenceless, they only took imaginary Kung-Fu lessons
 
@Zirak Why, to get imaginary number, obviously.
 
Is she a girl?
 
1:54 PM
@Zirak Your challenge on your website is pretty cool, although the sum of digits part, could include negative numbers, so -14 -> 3 instead of 5
 
@Catgocat Thanks. I had some tricky cases like that before, but removed them because I didn't want a complete, resilient solution; I want to encourage people to do dirty, dirty things, which are usually not resilient.
 
Guys, I'm actually an ex-Fortran guy with 6 figure salary, hot wife, daughters and a mansion. But I was laid off from the job then got divorced and diagnosed with brain-cancer. One day @Zirak pinged me and said "hey, do you want to code in Javascipt?" then I saw her beautiful face and automatically replied "Yes" to it.
Then I became so humble and started coding in Javascript for 10 dollars an hour
I thank Javascript for saving my life
 
2:14 PM
@EnglishMaster that's because MS isn't responsible for the bug
 
2:28 PM
box.square = function square (x) {
    //return x squared

    return Math.pow(x, 2)
};

box.invertCase = function invertCase (x) {
    // x is a string. turn lowercase letters to uppercase and vice versa.

    return x.split('').map(function(val) {
        if (val == val.toUpperCase()) {
            return val.toLowerCase();
        }

        return val.toUpperCase();
    }).join('');
};

box.sumDigits = function sumDigits (x) {
    //sum the digits of the number x

    return (x+'').match(/(\d)/g).reduce(function(prev, curr) {
that was dirty
 
2:46 PM
@Catgocat return foo ? true : false; can be rewritten as return foo; , and learn about every and some
 
I was under pressure (there was a timer) :(
Blame me
 
Also: learn about Array.isArray
 
isArray? Is that es6?
 
... es5
 
lol never used it thanks for the tip @FlorianMargaine
and look that return x.length ? false : true; isnt foo ? true : false
I could just !x.length though
 
2:52 PM
does anyone know a good use case for the Hamming heuristic ? It's worst heuristic imo
 
In what sense?
 
so was curious if it has some use
 
Look at the Hamming code
 
according to this article‌​, for "mispelling" related problems
 
Ops misread your question lol
 
2:55 PM
@KarelG It's great if you don't have deletions or insertions, only alterations
 
@FlorianMargaine Soon … github.com/copy/v86/issues/52
 
@KarelG You can't just forget that a wire is there, onlp get its value wrong
 
@AaditMShah Very nice
 
ok, tgx
 
HI All, I am so happy I found stackoverflow chat this is great.
Two days already working on something on wordpress and trying make this running. I think now my problem is related to JavaScript. I have created Custom Post Types in worpress and added Custom Meta Boxes to add map Long and Lat. Then i used wp_query and I have endup with some arrays.I am using google map API and jQUery UI map.
Map is showing up and markers as well, I can add new post with Longitude and Latitude and this will be added to the map. Problem I have is with the for loop. When I whant to use Index to display title for
 
3:04 PM
@Patrycjusz 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.
 
@Patrycjusz This is the javascript room, not the PHP room. Sorry.
 
jQuery + PHP
 
Hmm, my question is related to JavaScript
 
Could I ask someone something about a problem that should be in NP and NP-complete?
 
3:10 PM
@evinda No
Because you already asked 10000 times in the last days
 
there are better places for CS stuff i think
did he ?
 
@JanDvorak Thanks, I found this today earlier but have no clue hot to use this with my code
 
                        self.addMarker({'position': ofs_map[i], 'bounds': true}).click(function() {
                                self.openInfoWindow({'content': ofs_title[i] }, this);
                        });

						(function(index) {
                        self.addMarker({'position': ofs_map[index], 'bounds': true}).click(function() {
                                self.openInfoWindow({'content': ofs_title[index] }, this);
                        });
						})(i)
@Patrycjusz Replace the first block with the second one I gave
 
posted on April 18, 2015 by admin

Hovertext: The Art Reconnaissance Team is listening. And recording. And transcribing into spoken word poetry. New comic! Today's News:

 
@Catgocat Unfortunately this doesn't work. Inside same for loop i will have few arrays i need to use. I thought i can use same Index for each but inside .click this doesn't work. When i use your snippet ofs_title is not displayed.
 
3:22 PM
@AaditMShah Array.prototype.reduce = function() { return Array.prototype.reduceRight.apply(this.reverse(), arguments) }
 
@Patrycjusz Well in the example code you gave, I don't see any arrays besides what's in the for loop. But I bet you can use a reference to them for use later ?
 
@Patrycjusz I always hate "thanks but doesn't work". Code with your attempt?
 
@Mosho he asked to use it without .reverse() ... (like if i would care)
 
hi teresko, welcome in PHP JS chatroom
dat comment
I already figure out the answer, but was willing hire a developer from stackoverflow.com. It took less than 2 min to answer above question for me. — user3367928 1 hour ago
 
3:29 PM
@JanDvorak you are right. I will have fun with a bit more doing google search and if I can't do this I'll get a developer ;)
 
3:49 PM
Good morning
 
morning
 
Why is my console.log statement on line 45 of this code ( repl.it/j0C ) giving me undefined?
 
Learning to code is also a solution @Patrycjusz
 
@Azar_Javed From: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… "forEach() executes the callback function once for each array element; unlike every() and some(), it always returns the value undefined."
 
@Azar_Javed Use every or some depending on your needs.
 
3:52 PM
@Azar_Javed put the console.log IN the forEach loop
ancestry.forEach(function(person){
    console.log( person.born >1900 && person.born <1925);
});
should work
 
I see. Thanks
 
@Azar_Javed You were thinking of filter, not forEach
 
Yes, in eloquentjavascript example, he actually used a filter function with a for loop
 
FML. Express install (recommended): add a browser toolbar / Custom install (advanced): option to not install a browser toolbar (and no other selection), default setting to install
 
I wanted to see if i could to it with forEach. Though I am still somewhat unclear on array and objects since the example (the weresquirrel) he used in that chapter was VERY confusing for me.
 
3:56 PM
With Linux, that wouldn't have happened
 
FML#2: The same with a different product (same installer), this time the advanced option is greyed out (but still selectable)
 
@JanDvorak this is why you should always pick "advanced". The question that install wizard is asking you is "are you afraid of computers and have no idea what you are doing"
the "advanced" stands for "no, I have a clue"
 
Somehow I think I should blacklist CNET in Google. Thoughts?
With most products the default settings are actually reasonable
FML#3: now it's installing the VS2008 runtime environment
 
you shouldnt be downloading shit from CNET to begin with
 
Where from, then?
 
4:00 PM
major geek OR file hippo (if you have those options)
 
Thanks
 
It's a bit outdated, but point still stands. They're pretty shit. I can 2nd filehippo
 
Am I safe if I just decline the bundleware?
 
hmm .. I will have to go with "sometimes"
 
god @free download hosts
i try to recommend people to not do that, but they end up with crapware. After that they are complaining that "the computer goes slow" ...
 
4:11 PM
@Zirak you know you've hit a new level of crap when your computer communicates with you through the speakers rather than the screen. lol
 
that Pro Cleaner even says that there are errors, while the OS is new and fresh
when people asks me which AV is a good one, i always reply with " common sense "
 
@KarelG I thought common sense was actually the name of an AV
:(
 
@Catgocat didn't want to do everything for you
@copy nice
 
4:30 PM
@KarelG that's not the best options, TBH
you need SOME antivirus to protect you against browser vulns
 
Do actual exploit-using viruses still exist? I thought it was just social engineering nowadays.
 
there are some in the wild
 
I am running array.forEach(test). How can I pass the current element in the forEach to a new array based on if the test is true or false? The code: repl.it/j0C/1
 
!!tell Azar_Javed mdn Array.filter
 
4:36 PM
@Zirak I know that a filter method already exists mate. I am just trying to create it myself in an attempt to better understand the current chapter of the book I am learning from
 
Then implement it
 
@Azar_Javed line 45. you are passing your 'test' into foreach, whic is wrong.
 
anyone using immutable.js?
 
@Mosho Used it for ~10 minutes
 
u no likey?
 
4:41 PM
@Mosho I have
 
u likey?
 
Yeah
 
Haven't formed an opinion yet, just realised it didn't fit what I wanted to do.
So I'm useless to you. Shouldn't have said anything. Have a good day.
 
as an exercise or as a practical tool for work?
 
In a game to get rid of GC pauses
 
4:42 PM
@Zirak you are never useless to me
not while I have those pictures
 
...yes Master Mosho the Fine-Nosed
 
@copy you don't see it as a tool for general development?
 
@Mosho Sure
 
@Luggage Aren't you supposed to provide the function to be ran on every element of the array?
 
Yup. And you aren't.
You had that part right in the previous one: repl.it/j0C with person
your "if(test(currentValue))" line is indented, but it's not reall inside anything.
 
4:49 PM
Would this be correct ? http://repl.it/j0C/2
How would I pass the current element to the new passed array?
 
via magic
 
Close. currentValue needs to be an argument to that function
just like function (person) {} in the first version.
 
@Luggage Thank you very much. Now it runs. Though somehow it shows completely different result than the original example. Still, threw my brain at it for an hour, should still count :)
 
@SterlingArcher of course I am the best at JS. Ignoring the fact that I don't use it almost at all
 
5:22 PM
Has anyone read eloquentjavascript?
 
I have read it, yep.
 
I am on chapter 5 Higher-Order Functions. He is running this code repl.it/j0d How does the program know in the function(person) that person corresponds to an element in the array?
 
@Azar_Javed That's the job of filter
 
But we don't mention person anywhere in filter?
 
That's the point of higher-order functions
L4 is the call to test
 
5:31 PM
@Azar_Javed test is the function that is passed into filter. The filter function calls into the test function for each value in the array, and the function returns true or false. Based on that return value, the filter function adds items to a new array which it later returns. This is a classical case of using a function as a higher order func
Imagine it written down more explicitly:
function filter(array, test) {
  var passed = [];
  for (var i = 0; i < array.length; i++) {
    if (test(array[i])) passed.push(array[i]);
  }
  return passed;
}

function filterTest(person) {
  return person.born > 1900 && person.born < 1925;
}

var result = filter(ancestry, filterTest);

console.log(result);
It may make more sense once you see it written down like this.
 
I see, in the filter function, it calls the filterTest with the parameter = current element of the function which makes filterTest work as intended, correct?
Thank you everyone. I'm trying so hard to understand everything that I read that I keep confusing myself up completely on some points. Sometimes I don't know if I should just keep going and I guess the concept will become understandable later on, or if I should bash my head against it until it's clear
 
5:48 PM
head trauma may slow down the process, but we all learn differently.
 
@Azar_Javed Correct. :-)
 
Anyone heard of hackreactor? I could never afford it, but my boss offered to finance me if I show that I can learn the basics on my own
 
Never heard of it. But geez, "Nearly all of our graduates receive at least one full-time job offer within 3 months of graduating.", no shit? There is a severe lack of developers all around the world; you would be hard pressed not to find a job afaik
 
I'm doing technical support for his software and he plans to move it online so he decided on javascript + node.
 
@Azar_Javed If you get it for free, sure why not
 
6:03 PM
can I ask a Grunt question?
 
I sure hope you're capable of that.
 
I'll have to pay it back but with no interest. The company itself shows promise since it's in a big industry with only a few competitors and with javascript I would be in charge of people re-doing it in js
@RoelvanUden me too mate, me too
 
@RoelvanUden The sad thing is how few dev jobs are actually interesting
 
gist.github.com/argentum47/2f009027f86bc61fca20 I have this grunt file .. I have a rails server running at localhost 3000, and my grunt's connect is running at port 9000 . I used the grunt-connect proxy, so according to it, when my 9000 fails to responsd then it should forward that request to 3000, but it doesn't and fails with say localhost:9000/#/api/v1/articles.json .. what am I doing wrong
 
@Zirak I want to get to a point where I have skills to make this my career, then I can worry about interesting stuff :)
 
6:07 PM
@Azar_Javed I'll be brutally honest with you for a moment; I hope you don't mind. It feels like you've just stepped into the wondrous world of programming and you're currently all excited about it and wanting to learn quite a lot; this is great, and if you keep that enthusiasm, you'll become great as well. However, experience teaches that more than half of beginning software development students enrolling wash out in the first year. Are you sure you're ready to make a big financial commitment?
 
hmm ... I really like HardwareCanucks hardware review channel
both for the review content and production values
 
@RoelvanUden I truly appreciate your input. To be honest, I don't have much choice mate, I've only came to USA 3 years ago, from a third world country so I don't have much future (at least not one that I could be happy about). It's either this, or be stuck doing something that I hate for 25k a year
 
In unrelated news: wtf privateislandsonline.com
 
@Zirak There is no way to search for volcano lair in "features"
 
@Zirak OMG you can buy an island starting from 22k! That is amazing!
 
6:12 PM
are you sure its not the EMI
 
@Azar_Javed I hope you'll like being a dev; it would be worse working as a dev hating the job and a big loan than doing something you hate but rather free of worries otherwise (finanianclly speaking that is)
 
@RoelvanUden wasn't that one in canada ?
 
was 5minfork taken down?
 
@tereško Yeah! :-D
 
@RoelvanUden I'll let you know in 8 months
 
6:14 PM
(Too bad you choose to go to the USA, Europe is always a better choice :P)
 
I came from Europe heh
USA is a bit easier to sneak into
 
help plz ... if possible ...
 
Morning
 
Night
 
ohai
!!tell argentum47 ugt
 
@argentum47 localhost:9000/#/api/v1/articles.json is an odd url for an api since everythign after the # shouldn't baepassed to the server
 
Hello :D
What is the difference between model instance methods vs class methods in ORM terms?
 
Neither are related to ORM, but rather to 'classes'.
instance methods are for a particular instance where class methods only have one for all.
Let's say you have a "Person" class with firstName, lastName, and an instance method getFullName()
var somePerson = new Person();
console.log( somePerson.getFullName() );
 
6:41 PM
@Luggage ow .. actually the front end is angular .. i umm was wrong bout the url sorry ,it was localhost:9000/api/v1/articles.json . i was sending ajaxrequest with $resource
 
@Luggage So when do you use class methods?
 
Other random 'utility' functiosn that relate to the Person class but aren't specific to one person
 
And do I need to instantiate a model (ex. "Person") to use that class method
 
(or whatever your class represents)
No. More like:
Person.someUtilityFunction()
 
how to debug the error ? I mean on the rails side there is nothing i can do, since no requestt is made ..
 
6:47 PM
No idea, I was just pointing out one oddity that may have been related. Turns out it wasn't.
 
I use sequelize. ( don't know If you've heard of It or used It ) I have a model called Computers. When I call a class method exists(domain), in which domain is a string, It says method is undefined. Unless I create ( build or instantiate ) that model.
 
@Luggage So It contradicts what you've said about class methods not requiring Its class to be instantiated.
 
No, "Person" was the class name.
 
Can you elaborate?
 
6:52 PM
note the capital letter. It's good practice to name a Type with a capital, but instances / vrriable with lowercase
var somePerson = new Person();
 
OK. In my case I said that Computers.exists(domain) is undefined because Computers isn't being instantiated, even through exists(domain) is a class method.
 
can I see how you are defining it?
 
Yes, one sec.
 
if it's on the prototype, it's an instance method.
 
It's a bit different in my case.. Using node.js
 
6:55 PM
That doesn't matter.
 
ok, exists is a class method, botu you are using it like an instance method.
 
How come?
 

« first day (1645 days earlier)      last day (3307 days later) »