« first day (186 days earlier)      last day (21 days later) » 

8:00 AM
2
Q: Finding N partitions of number M with min and max partitions sizes

user3192576This code was created for a game project in which 10 houses need to be populated with 16 people. I wanted the distribution to be random, with no more than 3 and no less than 1 person per house and no remaining people or houses. JSbin link function getRandomPartitionsFromNumber(number, parts, mi...

 
 
2 hours later…
10:18 AM
0
Q: Improving Promise.all

user94607Is there a way to write the following code in a better way? var p1 = new Promise(function (resolve) { ControllerStore.activate(actualMapping.controller, urlParam, resolve); }); var p2 = new Promise(function (resolve) { route.render(actualMapping.template, resolve); }); Promise.all([p1,...

 
Discovered an interesting library/tool, @Quill, called flowtype
 
10:46 AM
@Quill I've heard that microsoft only awnt to support the most recent version of IE now? That is Edge 13
 
Yeah
 
And nothing of value was lost.
 
I'm a bit sore that they still used a blue e as their logo
like people are going to call it Internet Explorer forever
 
But that kinda foobars everyone who is stuck on windows 7
Yeah, it's not easy to kill a brand
honestly tho it's better to keep the E
 
If the logo wasn't an e...
 
10:47 AM
otherwise nontechncial users will be like "where has IE gone?"
and its just not worth the hassle to educate stupid people
 
nontech people != stupid people
 
pretty much
@DanPantry wait what? interfaces in JavaScript?
 
@Quill this is flowtype
It's 'something on-top' of javascript that enables type inference and checking
Essentially giving you a type system.
See TypeScript
 
right, because people can't assimilate to JavaScript's non-type checking
 
10:50 AM
Well, no, type checking can be very useful in larger projects.
Especially as I'm noticing ni the project I'm working on now where there are assumptions about types that just simply aren't true.
flowtype (and other type systems like it for js) are structurally typed (rather than nominally typed)
 
if (param instanceof String) return false
 
No..........
Runtime checking won't help you until you run your program &t here's no static analysis of it.
Structural typing actually makes javascript more fun instead of less fun
it's basiscally bringing haskell/go-like type systems toj avascript
 
I haven't written TypeScript before... maybe I ought to
 
typescript is garbage
I'm assuming you're on mac?
 
we're supposed to start using it at work
 
10:52 AM
If you're on mac/nix, use Flowtype
 
and yes, mac
 
Typescript requires everything to be typed ahead of time to use it
Flowtype doesn't - type checking in flowtype is opt in rather than opt out.
(see /* @flow */)
 
I suppose I can always write TypeScript code at work in plain JS/ES6
Does TypeScript compile down ES6?
 
TypeScript is a replacement for Babel
It compiles down to ES6, ES5 or ES3.
Flowtype supplements Babel
 
Right, well unfortunately:
1 min ago, by Quill
we're supposed to start using it at work
 
10:54 AM
I would really really recommend flowtype over typescript just because of how typescript requires anything you import to be typed using a .d.ts otherwise it will pretend the file doesn't exist.
You could use a VM?
docker or vagrant
 
Huh? what do you mean by use a VM
 
If you're not using Mac or Linux at work
Ie you're using crapdows (like me)
Use a VM to get a Linux environment
 
I don't think my superiors would like that
 
well, yeah, they would have to use a VM too, which would be The Very Bad THing.
 
anyway it wouldn't be the first time I write using crap systems at work, I just hold my personal code in better respect
We still and probably will in the new system use jQuery
also I'm totally going to share that interfaces photo in 2nd to freak them out
one of my colleagues wrote an angular system for a personal project, and offered to share it to get the basic frontend structure started without needing to make the whole angular system
it uses TypeScript
 
10:59 AM
Angular 2 actually is pushing to use TypeScript
Flowtype is more for the React crowd
@Quill There's nothing inherently wrong with jQuery... as long as you're careful
 
$(this).val()
 
Yeah, that's pretty fucking bad.
Could you check out the CR help desk? I need to brb
there's someone in there
 
sure
 
11:17 AM
I officially do not like MutationObservers
that's probably a sign I am using them wrong
 
@Quill it's honestly a bit of a weird solution from an edge case problem.
You shoudl be using them to detect changes in DOM and not really much else
 
that's what I am using them for
detecting new messages in chat
 
I thought chat used websockets?
wait, nvm, this is for your badge thing.
What don't you like about them?
 
sometimes it works, sometimes it doesn't
 
lol
That's usually a sign of user error
 
11:21 AM
3 mins ago, by Quill
that's probably a sign I am using them wrong
 
Ouch. what's not working there, though?
 
I've got the console.log to monitor incoming data
and it doesn't log anything sometimes
 
Hm
It seems to work fo me
Ah! nope.
It works perfectly when dom nodes are added.
It doesn't work when a user sends more than one message once
try sending a message?
 
Oh right, text is merely added to a box when the same user adds a post
 
11:23 AM
the dom nodes aren't updated
it's one box
 
not.. quite
 
it's a per user box
 
hence why my twelve message spam showed nothing
 
Yes, but each message still has its own element
set subtree to true.
that appears to work
oh lord
don't do that
It also counts the characters you type into the chat box
 
11:25 AM
LOL
 
Basically, enable subtree, and ignore everything except for .user-container
 
omg I just got like a billion mutation records
 
The MutationRecord is the powerhouse of the cell.
I don't think he appreciated my joke.
 
> Cheers, smartass
LOL
[badge:fanatic]
so it doesn't even get it lol
 
11:55 AM
[badge:fanatic]
[badge:illuminist]
 
 
2 hours later…
2:14 PM
0
Q: Get a nested property for a complex object at any level of depth - Performance tuning

GibboKGiven a complex object (with nested objects at any depth) I need to be able to quickly retrieve a value for a given property name. I have designed the following code, I would like to know: How to tune my code for maximum performance considering passing a big object? Am I missing some case in d...

 
room topic changed to JavaScript Masterrace: Everything JavaScript [ajax] [angular.js] [eval-is-evil] [javascript] [json]
 
but jquery is evil too
 
jQuery isn't evil, it's just evil when you're being stupid
 
jQuery is obese is better, then
 
I'd rather not put controversial stuff in the title
 
2:19 PM
lol
 
And I'm sure the SO mods would rather us not do that too :P
 
3:18 PM
0
Q: How do i refactor the time complexity of this algorithm?

Ayoola SolomonImproving the time complexity var input = [4, 900, 500, 498, 4]; function walrusWeight(input) { var target = 1000; var optimum = 0; var sums = []; sums.push(optimum); for(var i=0; i < input.length; i++) { var newSums = []; for(var j=0; j < sums.length; j++) { var newSum ...

 
 
1 hour later…
4:29 PM
0
Q: Refactoring jQuery Code

Chris H.Hey so I have written some code out in jQuery, but it seems to violate DRY. I'm not too familiar with JavaScript or jQuery, so I was just asking for some advice on how to optimize this code: $("#twitter").rotate({ bind: { mouseover : function() { $(this).rotate({animateTo:360}); ...

 
4:47 PM
0
Q: Reading transactions from a file and writing them to a database table

SBelI am learning Node.js and I would like to see if I'm using it correctly: var mysql = require('mysql'); var fs = require('fs'); var connectionProps = JSON.parse(fs.readFileSync('connection.json', 'utf8')); var connection = mysql.createConnection({ host: connectionProps.host, user: connectio...

 
 
2 hours later…
6:25 PM
0
Q: Permutations-based function in JS

thatguy Take a string and an array of words, and return all indexes in string for which a concatenation of all words in the array, in any order (so out of ["hi", "john", "doe"], any of the six concatenations are valid) can be matched. All words (unlike in my example) will be the same length. ...

 
 
5 hours later…
11:06 PM
0
Q: Check if sum can be found in array

HousemanGiven an array a, check to see if z numbers inside a total up to n So if a = [1,2,3], n=3 and z=2, then this function should return true, since z numbers in that array combine to equal n. I recently took a test for a job to fill out this function, and this was my answer. It was presumably rejec...

 

« first day (186 days earlier)      last day (21 days later) »