« first day (2062 days earlier)      last day (2904 days later) » 

8:00 AM
what? seems to be a neat way to create lots of objects
 
@JimmPratt maybe in java
 
Often it's an overkill
 
like what I am trying to do with stackoverflow.com/questions/37066665/…
menu system is full of stuff that needs refactoring into something that creates the menu objects for me.
 
Guys, any ideas how to reference an array from another file and get that arrays length?
 
@RowanHarley require. Worst case, global scope
 
8:03 AM
@FlorianMargaine I'll have to try some out
 
:31026355 seems legit, but is that the factory pattern?
 
is what the factory pattern?
in my SO above? no, no, that's the problem that I think can be solved with a Factory
my* problem
 
!!wiki factory pattern
 
In object-oriented programming (OOP), a factory is an object for creating other objects – formally a factory is a function or method that returns objects of a varying prototype or class from some method call, which is assumed to be "new". More broadly, a subroutine that returns a "new" object may be referred to as a "factory", as in factory method or factory function. This is a basic concept in OOP, and forms the basis for a number of related software design patterns. == Motivation == In class-based programming, a factory is an abstraction of a constructor of a class, while in prototype-b...
 
right
 
8:06 AM
Yours doesn't create different types, just different objects of the same type
 
@SomeGuy github.com/ctfs/write-ups-2015 oh no, oh no, oh no
is this what I think it is?
 
Is there any way to reference it though within a function? E.g: function GetArrayLen(array){ var len = array.length }
 
i'm finding like... 3-4 different ways to make a 'factory' object, so documentation appears less consistent.. @JanDvorak well, yeah I guess that is true... I do need to pass a few parameters that change some behavior.
 
@RowanHarley Why wouldn't it?
 
Well it gives me errors when I try it
 
8:08 AM
I guess you're not passing it an array then
Or rather, you do get the array len, but does the caller expect you to actually return it?
 
I'm passing it as an object, then getting the length of the array inside that object
 
this method won't do that
 
@GNi33 what do you think it is? wink wink
 
Well it seems to work when I get the length of the first array, but when I move on to the second, It gives me an error that length is undefined
 
Don't wink at me bro
 
8:11 AM
oh god, it is what I think it is
 
@RowanHarley ... I'll just wat that statement
 
hello, anyone want to fix a post for me
0
A: How to make ng-transclude behave like ng-include (in terms of scope)?

ExpertSystemWhat you need, is a template function that will extract the content of your template element (the element as it appears in your HTML, before Angular compiles it) and embed it into the directive's template. As described in the docs, the template property of the DDO can be a function, in which ca...

this answer has two links
but the second link is also using [1]
and it should be [2] instead
but I can't make that suggestion because 1-character edits are not allowed below 2k rep
 
Here's my 2 files. Paste 1: pastebin.com/fFzNqrX8
 
@GNi33 information security competitions - good stuff
 
8:13 AM
@RowanHarley Oooh I remember now. You're the vamp from yesterday.
 
yep, I know. And it's not only the writeups but the actual "levels" too
 
which is very bad for my freetime
 
maybe... I couldn't fix this bug so I came here
 
@Pimgd you could have asked it in the comment. But fixed for ya
 
8:14 AM
@JimmPratt Perhaps the factory object you read is not the same as the factory design pattern we were thinking. You want a function that creates, customize, and return one type of object, that's all. Which is good and common in JS. Not sure how you can call it to make it more clear, to be honest :p
 
because I'd love to try out some of these advanced ones without the stress of the competition itself
 
@KarelG sorry 'bout that, you're right
thanks though
 
Makes sense, @Sheepy
 
AbstractProxySingletonFactory
 
Soon... you can drop the "script" part of "javascript"
3
 
8:16 AM
^
 
so true :|
 
The ship of Theseus of JS
 
There is not a single method in ECMAScript capable of simplifying a proper copy between two objects.
 
there is no one at other languages
all implements shallow copy. Deep copies have to be written by the dev
 
Ok, so I've fixed the problem with getting the array length by changing the first file from function Test(){} to Test = new function(){} but now I'm getting errors when getting the length of strings
 
8:24 AM
@cswl If you want to structural clone an object, I think you can save it to IndexDB and read it. postMessage also works but async.
 
Haskell solves that by only having immutable objects
 
In these days more than ever, where functional programming and immutable objects are essential parts of complex applications, every framework or library is implementing its own boilerplate in order to properly copy properties between composed objects or prototypes.
 
@Sheepy how does it deal with circular references?
 
JSON.parse(JSON.stringify(x))
 
@littlepootis It'll be preserved. It's almost magical. Until you start passing function into it, which it won't accept...
 
8:29 AM
@JanDvorak hmm ... i've never copied an instance of a type in haskell. Maybe you're right
 
@KarelG nice. I expected something a bit more cheesy
 
Can someone help me please?
 
@KarelG One does not copy objects in Haskell. One tries to reuse them as much as possible
 
that's why i'm surprised by what you said :)
@RowanHarley you didn't specify which errors, what your problem is and ect...
 
@RowanHarley can you help me please sir
 
8:32 AM
lol @littlepootis
 
actually using myString.length should give you the length of myString without errors
 
I get the error that length is undefined
 
@Paran0a The new type of ES6 is Symbol. Map is just normal object. And Set. And WeakMap. And WeakSet. And Promise. And Reflect. And perhaps Proxy, depending on your definition of normal. Hope that's enough 1337 ninja arsenal for you.
 
@Sheepy Weak* and Proxy are not implementable in ES5
 
s/implementable/shimmable/
 
8:34 AM
@Sheepy You can't use structured clones for composition over classes and their prototypes. Looks like it's just for storing values..
 
if I change Test = new function() to function Test() I can get the string length without errors but I get errors with array lengths
 
@littlepootis what is your query?
 
@RowanHarley more context please ...
 
@GNi33 so i was trying to parse html with irregular expressions
 
@cswl Given that the Array prototype in two different context are different - you can shim one without affecting the other - it is only safe to leave out the prototype chain.
 
8:36 AM
Here's the latest code. Paste 1: pastebin.com/qVy5KAWR
 
@RowanHarley go home, vamp
 
@Sheepy Thanks , what would you say will have the most use? If something like that can even be said.
 
@JanDvorak That's one of the first thing I was corrected in this room. You can actually implement WeakMap in ES5. (And, I assume, WeakSet too)
 
you guys wouldnt know how to change a components x & y positions when one of my if statments are activated?
 
@TaylorStyles Welcome to the JavaScript chat! Please review the room 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.
 
8:38 AM
@Sheepy how?
 
@JanDvorak I quote from the rules: "Do you get more code from Stack Overflow than you write on your own?". I have written a lot more code than I've been given so I'm not really a vamp
 
anyone using firefox-aurora here?
 
@Paran0a Eloquent JavaScript. Beyond the basic, I think a good next step is read code, read many code, and make sure you understand them.
 
I am seeing a strange issue here: it seems that on the latest version the Web Console API has been disable (at least for me)
 
8:39 AM
@tereško I'm only on Beta.
 
@tereško unlikely, at least it's unlikely to be intentional
 
@Sheepy sure , bookmarked , after I'm done with You-Dont-Know-JS
 
@JanDvorak google es5 weakmap github :)
 
!!google es5 weakmap github :)
 
Cap hasn't been responding to my google request for over a week now :(
 
8:41 AM
How will google show you ads.. if you can just google from here..
 
> As ES5 Javascript does not have the ability to use weak references, the key-value association must be held strongly somwhere.
 
@cswl I am sure that they'll manage one way or the other ;)
 
everytime you google here, an add pop-up appears.
 
@Paran0a you should devirus your computer
 
They don't even allow bots/scripts to scrape google search results.. it's in their TOS
 
8:44 AM
@Paran0a yeah, I don't see any ads
 
@Paran0a I used to get that. It comes from an extension that claims to be an ad blocker
 
@JanDvorak You may also want to check how people shim Proxy (partially). :)
 
partially
 
What do you call an ad blocker that sneaks in ads?
 
@Neil Adblock Plus?
 
8:46 AM
InADequate apparently
 
@Sheepy wait, they do?
 
any idea if I can use jQueryUI draggable for collision detection even when no dragging is going on?
 
@littlepootis No. Not technically. They just let ads sneak through...
 
8:47 AM
(by default)
 
I just reinstalled chrome.
 
WeakPun
 
Isn't that a bit like asking a door salesman to stand in front of your door to prevent door salesmen from reaching your house?
 
AdBlock has a whitelist for non-intrusive ads
 
Except "non-intrusive ads" is defined by money
 
8:50 AM
Which are allowed, by default. But that option can be disabled.
 
To be fair, AdBlock Plus does block most ads by default. (But not trackers, mind you.) And does defend our adblocking right on the court when they get sued.
 
They got sued?
 
Yes. Multiple times.
 
@Sheepy whoa wtf
 
Actually, not very surprising, but who'd even think they could win that?
 
8:51 AM
Some Ad malware hides in your pc. You need to get rid of it in 'Uninstall Programs'
 
It's called bloatware
 
@RowanHarley those things are borderline viruses
 
@RowanHarley where is Uninstall Programs?
 
8:53 AM
In control panel
 
The only thing that they don't do is directly harm your computer. Very dangerous
 
under programs and features
 
This discussion is making me wonder how long can GitHub last...
 
@Sheepy agree completely. Just trying to refactor jsfiddle.net/digitalmouse/hjyb4suk in such a way so that I don't end up with 2000 JS lines of code (yes it is not working due to some sort of raphael.js library conflict in the fiddle, but it works fine locally) A factory method seemed to be the answer, hence why I was going on about it earlier. :(
 
@Sheepy Why?
 
8:55 AM
Hmmm... I thought this chat was for javascript, not how to fix a laptop
 
@Sheepy I thought that crisis was over.
 
@RowanHarley I don't have a Control Panel
 
Or, no, I am thinking of npm
 
@JimmPratt I checked your code before I went to lunch. You definitely need a factory method. It's not hard, do your best :)
 
@littlepootis are you on windows?
 
8:56 AM
@RowanHarley on I'm on my sofa
 
oh, well that makes sense
 
Or couch
 
@Sheepy i imagine so. just brain not working today for some reason >.<
 
You start by lifting the couch up
 
@Cerbrus I was thinking how sourceforge (and cnet before it) sneaked "helpful installers" into their downloads. Or how Google Code closed.
 
8:57 AM
Then you stick your head under it
Drop down the couch and you've got your control panel
 
@RowanHarley sounds legit
 
You djxnsjsk
 
..or at least head pain
 
Try it out! I did and it worked perfectly
Just in hospital for a few more hours
 
makes you totally forget about other pain, right?
 
8:59 AM
@Sheepy Those suck... If I want to download something, they shouldn't make me download an download tool (which changes my search engines, default browser, all that crap)
 
bangs head against the wall, trying to grok Factory methods in Javascript
why are there three ways to do it??? cries
 
Or when you visit sourceforge and see DOWNLOAD , {DOWNLOAD NOW} , [PROGRAM FREE DOWNLOAD] ... download
 
I hate when you are trying to download something on a page with loads of ads
They all say 'Download now!'
 
or when they complain that you are using AdBlock, and prevent you from downloading until you disable AdBlock >:(
 
@RowanHarley AdBlock
 
9:03 AM
And then you disable it , and click on something , POOF POP UPS EVERYWHERE
 
I usually block those "you're using adblock" popups.
 
You cant get that on android though
 
@RowanHarley click the unimpressive looking "download" button
 
usually just a anchor not even a button
 
They just want you to buy their overpriced premium account..
 
9:04 AM
It will work until marketers catch on
 
they even gave cnet example , perfect
 
adblockplus.org/blog/… block popups in only a handful of steps! \o/
Hehe, iOS > Android, there.
 
Adblock plus sucks. I use uBlock origin
 
ublock.org needs to update their ssl certificate.
 
9:07 AM
That's.. not their website.
 
Hm, figures
 
Adblock in the streets, ublock in the sheets. Read adblock on work , ublock at home
 
watches Cerbrus suddenly get flooded with malware
 
@littlepootis Good one. I may try that for my phone.
 
9:10 AM
@Sheepy only available for FF Android though
 
So can anyone tell me how to fix the error: "Cannot read property 'length' of undefined"
 
@RowanHarley: Don't try to get the length of an undefined var.
 
It seems to work fine in coffeescript but why not in js
Should I be giving the array a value first before calling it's length?
 
Yea.
var myArray; console.log(myArray.length); will not work.
 
ok, I'll have to look at the coffeescript code and see if there is something I can use to declare it
Thanks!
 
9:14 AM
@littlepootis Not a problem. That's my main. :)
Well, mobile main.
 
Why are you reading a val of an empty var?
 
@RowanHarley What is your coffeescript?
 
This is the coffeescript: pastebin.com/1FxNHmaJ
 
Where are you reading the length?
 
he's actually working on js generated by the coffeescript compiler
 
9:18 AM
Ya but I've edited it a bit so that it would compile
@littlepootis do you want the js or coffeescript code?
 
@RowanHarley both
 
Pastebin...
 
give me a minute. I'll put it up on pastebin.com
 
and CoffeeScript
 
What's the purpose of @head = @body and @X = @D?
 
9:19 AM
Coffeescript: pastebin.com/bAphWDKd
 
even the metric system got discussed in Archer: i.imgur.com/sxUsbAI.jpg
 
@Cerbrus "By prefixing argument's with @, CoffeeScript will automatically set the arguments as instance properties in the constructor."
 
@Cerbrus I'm not sure. I'll talk to the developer about that
 
@bitten Not the @. The fact he's copying variables
@RowanHarley: Is it crashing on nameLength = snake.name.length;?
 
You're going to talk to Ashkenas about this?
 
9:22 AM
no after changing the code back to function Snake() it crashes at the array
 
On what line.
 
line 6 of the 2nd file
 
@Cerbrus you asked what @ meant in coffeescript, that's what it means? :p
 
@RowanHarley Just tell us the contents of the line.
 
@Cerbrus Warning: Rowan Harley is a help vampire
 
9:23 AM
@bitten That's not what I asked.
 
shut up @JanDvorak
 
I just read the rules. The game?
 
Triggered
 
Oi, be nice.
 
@Cerbrus ohh i see what you asked now
 
9:24 AM
var part = snake.parts.length;
 
my bad
 
@RowanHarley There we go. And the error was: "Cannot read property 'length' of undefined"
 
So, With that error on var part = snake.parts.length;, you should see what the problem is, right?
 
@Cerbrus You're speaking in riddles!!!
 
9:25 AM
@OliverSalzburg I know.
 
the array is undefined but what value should I give it
 
Learning > giving an answer
 
@RowanHarley []
 
new Array()?
 
old Array()!
 
9:26 AM
@Cerbrus in which case go ahead
@Paran0a don't do that
 
I've tryed both they both give error
 
user3119231
It's smart to let him find the mistake. otherwise he wouldn't remember next time. wat?
 
@JanDvorak Serious question ,why?
 
@JanDvorak Thanks for the heads up, by the way
 
@Paran0a exactly the same as []
except slower and mildly error-prone
 
9:27 AM
@RowanHarley What exactly did you try?
 
user3119231
He means: did you try?
 
Oh, at first I was like "So what" , but the other reasons is good enough :) TIL
 
and uglier
 
I tryed changing [] to new Array, I tryed changing function Snake() to Snake = new function()
 
Right
 
9:28 AM
new function is almost never what you want
 
user3119231
^
 
user3119231
but why meme
 
That "Cannot read property 'length' of undefined" error message you got, is saying snake.parts is undefined.
You need to make snake.parts not undefined.
How would you do that?
 
It has no value, yes but I dont know what value to assign it
 
9:29 AM
Why would you even write a function like that if you have no idea what input you would have to give it?
 
user3119231
@Cerbrus learn php?
 
Why would you write such code, if you don't even understand what it means to define a variable?
 
In coffeescript it wasn't given a value
 
@RowanHarley What is it supposed to be?
 
Thats why I asked why is he reading a length of an empty var
 
9:30 AM
@Cerbrus new function(){...} creates a blank object with a prototype set to a blank object, then calls the function with that object as its context, then if returns that object if the function doesn't return an object
 
Either trolling or messing with code he shouldn't be messing with
 
The code as a whole is supposed to create a private server for slither.io (I love that game!)
 
@RowanHarley The coffeescript would fail as well.
 
@OliverSalzburg maybe it's his first time programming and he just wants to play around and learn?
his profile says he's only 14
 
It doesn't. It works fine
 
9:31 AM
nothing personal to you Oliver, i mean it for the whole room too :P
 
@Loktar dat woman What she did is horrible. wtf
 
@RowanHarley If the coffeescript works, the JS it translates too should work as well.
 
If youre new to coding I highly doubt re creating slither is a good idea.
 
@Paran0a but he's just playing around, fiddling
this should be encouraged
 
user3119231
@Paran0a nodeJS + websockets?
 
9:33 AM
@RowanHarley How are you translating the coffeescript to JS?
 
I amn't new to coding, I'm new to JS. But I wanted to convert the code so that I could edit it and improve it
 
@KarelG inb4 breakup
 
I use js2.coffee
 
@Cerbrus inbefore he just renames the files
 
@RowanHarley Don't improve compiled code
 
9:34 AM
^
 
why not? If I can't use coffeescript, I might as well use js
 
@RowanHarley Then where did you get var part = snake.parts.length;?
 
@bitten Yeah but when you learn things you have to optimize your learning. Jumping into too hard stuff will just result in frustration.
 
Neither of the 2 files you linked have a line that translates to that.
 
@Cerbrus that translates to partsLength = snake.parts.length * 2 in coffeescript
I put that apart to make it a bit easier to read, thats all
 
9:37 AM
@Paran0a hehe that's not what my relationship to math is like
 
Don't. If I ask you what line got you the error, don't change the line.
 
ok, sorry
 
but i appreciate and agree with the point though, don't jump in by yourself, you should be coached, and so on ^^
 
So, apparently the object passed to that function isn't complete. Some properties are missing.
The coffeescript function can not work if the JavaScript version does not work.
And vice versa
 
I'll convert it again and see if I get the same code
 
9:39 AM
Better yet, what are you passing to the function?
 
The snake's id, name, skin, and body length (I think the last one is right)
 
That's not what I asked.
 
What do you mean then?
 
What exactly are you passing to the function?
 
oh...
 
9:43 AM
github.com/iiegor/slither Did you read the warning there ? ._.
 
Lol
 
I've downloaded the project and it runs fine
 
If you're not comfortable writing JS, don't edit thr compiled code
 
that might be smart
 
9:45 AM
Even if you are, think twice befire you do
 
No harm in trying it though
 
5 mins ago, by Cerbrus
What exactly are you passing to the function?
So?
 
@RowanHarley maybe try transpiling with this github.com/decaffeinate/decaffeinate
 
The transpiler isn't the issue
 
9:48 AM
Wish I could use that on myself.
 
Wait I just fixed it!!!!!! By adding 2 brackets at the end, I managed to get the code running
Thanks for the help though!
 
rofl
WE DID IT !
 
> 2 brackets
 
OMFG!!!!!!
 
9:50 AM
Hi all
 
Eh, what exactly did you change @RowanHarley?
 
In this fiddle, jsfiddle.net/newn1p38 user can delete everything but should not be able to delete minimum one list item.
 
I changed }); to })();
 
@Mr_Green That's just an ul with 3 items
 
9:52 AM
yes we can edit it since it is contenteditable
User can remove all content but at least one bullet point (without content) should be always there
If I do like this
 
@RowanHarley So you're invoking a function somewhere... That seems like a hack that'll break elsewhere.
 
ul::before{
  display: list-item;
  content: "";
}
^ it works but doesn't work when pressed enter
I think I should ask on SO
 
@cswl you can also use js2.coffee
put coffeescript in the right window, javascript comes out in the left
 
@Mr_Green Then you probably need to add one back when the user deletes the last one
 
I was thinking there might be way using just HTML5
If I need to handle it with JavaScript then I need to cover all cases which are many I pressume
 

« first day (2062 days earlier)      last day (2904 days later) »