« first day (1684 days earlier)      last day (3271 days later) » 

12:09 AM
0
A: JS closure not updating null when passing an object

Qingbecause the param of func you defined is null

 
12:26 AM
@phenomnomnominal i.imgur.com/K8ZkxTB.gifv
 
-1
Q: javascript: go to the default from one case in switch statement

shenkwenHow do I do this in Javascript? switch(c){ case 'a': //do something, condition does not match so go to default case //don't break in here, and don't allow fall through to other cases. case 'b': //.. case 'c': ...

interesting
Can JS labels with continue be somehow exploited to do this?
 
12:42 AM
Hmmm
 
12:54 AM
0
A: Sum Array push values, before a 0 javascript

Arun P JohnyYou can do to var global = []; function funsuma(valor) { var suma = 0; //need to make sure valor is a number global.push(+valor); if (valor == 0) { for (i = 0; i < global.length; i++) { suma += global[i]; } alert("Es 0, tu suma es: " + suma); //...

203k user ._.
 
window.localStorage.appID = window.localStorage.appID || uuid.v4(); // wow this one line !
@AwalGarg obv he copy pasted
 
@Abhishrek He shouldn't be answering it in the first place.
 
lol
 
Look at the answer below it by a 105 rep user.
 
@AwalGarg .... on the side i built it from scratch
now it looks like social network of payment
using stripe, facebook, azure, imgur, google places, google maps(and some more api's)
 
1:04 AM
yay!
 
it even callls the shop from plivo
 
only shit is i wanted to have scout but meh :P
 
@Abhishrek too good for a college thingy :P
lol
 
Don't use "rape" so casually, come on, we want everyone to feel safe here.
 
1:06 AM
@phenomnomnominal -_- argh
you really don't understand my frustration....
 
@Abhishrek you rape things when you get frustrated?
 
COMON i edited it to mentally-rape
@phenomnomnominal alright... i will search a dictionary word
 
hahaha
 
technically i merely want to obliterate his/her mind so that they just give up --- and blame me for downloading this from internet .... once they do that --- game on !
 
@Abhishrek ask them something from es6
 
1:19 AM
Why do most people do:
<div class="foo foo-bar"></div>
//css
.foo {}
.foo-bar {}

instead of
<div class="foo bar"></div>
//css
.foo {}
.foo.bar {}
 
@phenomnomnominal Yeah, saw that. That's some fucked up shit right there.
 
@AwalGarg Different approached
I use a difference approach
 
@monners so what is the benefit of the former (if any)?
 
@AwalGarg Organisation/maintenance. Just read some articles about the different approaches
 
1:22 AM
@monners the best reply I saw to that was something along the lines of, "so... about Abbott's citizenship..."
 
ok.
 
1:32 AM
Is there any way to shrink this or pull out from the constructor definition?
 
@phenomnomnominal It's not like it'll go anywhere though. It's just a very stupid thing for the PM to say
 
Stupid formatting.
 
@monners good thing he's not known for saying stupid things
 
function Rect() {
    Object.defineProperty(this, 'left', {
        get: function() { return this.x; },
        set: function(left) { this.x = left },
        enumerable: true
    });

    Object.defineProperty(this, 'top', {
        get: function() { return this.y; },
        set: function(top) { this.y = top; },
        enumerable: true
    });

    Object.defineProperty(this, 'right', {
        get: function() { return this.x + this.w },
        set: function(right) { this.x = right - this.w },
Alright, now it worked.
 
@Jovito why are you using defineProperty for all of those?
i mean a), there's defineProperties, but b) the ones where you're just setting one thing don't really need them.
 
1:46 AM
Science!
 
@phenomnomnominal b) simply for consitency reasons
but you're right about a)
Is there any way to defineProperties on this outside the constructor?
 
Object.defineProperties(Rect.prototype, { })
also, are you sure you need them to be enumerable?
 
@phenomnomnominal What I want to do is give an options object to Rect and set the properties with the values passed in.
Will every instance of Rect have its copy of the properties if I define them in the prototype?
 
2:04 AM
yes
so you would have something like this:
 
@Neoares Sheepy was preparing a visit to / grazing at South Korea.
 
@Jovito:
function Rect (options) {
    this.x = options ? options.x : null;
    this.y = options ? options.y : null;
    this.w = options ? options.w : null;
    this.h = options ? options.h : null;
}

Object.defineProperties(Rect.prototype, {
    top: {
        get: function () {
            return this.y;
        },
        set: function (top) {
            this.y = top;
        }
    },
    right: {
        get: function () {
           return this.x + this.w;
        },
        set: function (right) {
But personally, i'd just have named getCenter setCenter etc functions on the prototype.
also, shouldn't set center update the x and y?
oh yeah it does, duh, sorry
 
2:20 AM
"@phenomnomnominal why getCenter/setCenter instead of properties? And shouldn't it be:
this.x = options.x ? options.x : null;
 
if options doesn't exist, that will error.
 
Also, wouldn't it be better to initialize x and y to 0 and w, h to 1 instead of null? Or yet require that you enter those 4 values and throw an error if not.
 
you could do options && options.x
yep those are options
and re: getCenter, I just find defineProperty to be pretty bloaty.
And it kinda hides potential side effects from consumers of the api.
 
Can you give an example?
 
of which bit?
 
2:25 AM
Also, wouldn't it be better to just iterate through options properties and set each one if Rect has it?
2 mins ago, by phenomnomnominal
and re: getCenter, I just find defineProperty to be pretty bloaty.
2 mins ago, by phenomnomnominal
And it kinda hides potential side effects from consumers of the api.
That bit.
 
@Jovito That's weird, you want the Rectangle to know what properties expects, not just take anything you give it.
 
yeah, so you could do this inside the loop
if (this.hasOwnProperty(property)
    // do stuff
x, y, w and h would be fine since they're set with this
 
// this just looks nicer to me.
Rect.prototype.getCenterX = function () {
    return this.x + this.w / 2
};
Rect.prototype.setCenterX = function (centerx) {
    this.x = centerx - this.w / 2;
};
and yep, you could do that, it's just kinda weird
 
but left, top, bottom, right, centerx, centery and center woudn't pass hasOwnProperty()
that's how I got here
 
Like I say, you can totally do that. I just would find it weird to come across that, and i don't see any real benefit
and for the side effects bit, it just seems weird to me that by doing rect.center = {}; I'm actually setting rect.x and rect.y to NaN?
 
2:31 AM
Well, as I add more properties the constructor would get bigger and bigger, while with a loop the code would remain the same despite de number of properties.
 
What other properties does a rectangle need?
 
I get your point, but generally speaking, you agree that would be better?
 
I think it's less explicit
and I think being more explicit is generally better
 
except on TV
 
@phenomnomnominal It depends on your rectangle's responsibility. Which is the first thing you should decide when doing an OO design.
 
2:33 AM
or in @KendallFrey's bedroom.
 
@Sheepy A rectangle has very little responsibility. That's my point.
And if it has more responsible than being a rectangle, then it's not a rectangle.
 
A rectangle has no responsibility. It just is.
We call that a value type in .NET land.
 
@phenomnomnominal It depends. For example, .Net has a drawing rectangle and a shape rectangle. The first only has 10 properties and 20 methods. The second has too many for me to count.
And the Java rectangle, also for drawing, has even more.
 
I have a problem truefriends
 
2:36 AM
@Mathemats 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.
 
Yep, but I bet the constructor for all of them is simple as hell
 
I am assigning a value to a global variable in a function, and then in another function I am trying to use that value but the variable is undefined.
 
Also, .NET and Java are hardly where I'd look to find great API design
 
@Mathemats Well you're apparently not assigning it before you access it.
 
@KendallFrey @Mathemats or it's not really global.
 
2:38 AM
ended up rebuilding the fucking template with HTML
 
@phenomnomnominal They are not Java Date. The constructors are simple. And their API are easy to understand and practical. You do not need a library to check whether two rectangle intersects.
 
@KendallFrey In the method, I can output the value to the console and it is correct.
 
what a horrible horrible waste of an hour
 
@Mathemats You said it was undefined
 
inline tweaking and two off classes EVERYWHERE
 
2:39 AM
It is undefined when it is being used by the other function
 
@Sheepy yeah and we were talking about the constructor or a rectangle. So...
 
You're being extremely vague, and I can't give you any helpful information
 
@Mathemats turn it off and on again
 
@phenomnomnominal I see. Sorry I only see properties and properties and properties.
 
now all I wanna do is spend time tomorrow figuring out how to alter pdf's with node
because fuck. that sucked.
 
2:42 AM
@rlemon You may have better chance calling other languages for PDF manipulation at the moment.
 
Let me try again brehs... I have 2 functions and 1 global variable. 1 function sets the gVariable and writes its value to the console (so I know it's not undef). The other function then uses the gVariable but at this point I get a undef error.
 
If that is true, then something must be erasing the value
you're not giving us much to work with here
protip: fiddle
 
It doesn't run lads, but hopefully it makes sense to you. jsfiddle.net/jk0gtp9y
 
0
Q: Keep session alive after a page refresh in AngularJS

FrondorFirst of all, sorry. This might sound like a silly question but it's the first time I try to develop a login system, so please, patience! :) I'll try to explain myself as much as I can, and give my best english ^^ Basically, I want to learn a good practice for this implementation in my angularjs...

 
2:48 AM
@Mathemats mainClientID.d won't be set when you make the second call because the first one hasn't returned yet.
 
@Mathemats Er, I think you got your code boxes mixed up. There's nothing in the JS.
 
@Mathemats you can pass one fn to another and call it on success. jsfiddle.net/rlemon/jk0gtp9y/4
but I would use promises
 
window&&null!==window?window
 
I just don't know jQuery promises
 
I've just done that rlemon and it works, what is promises?
 
2:51 AM
google it
jQuery + promises
 
Thanks for your time truefriends
 
they make the code much cleaner and easier to maintain in the end
 
what is drugs?
 
I suggest looking into them
 
I am druggers
@rlemon Thanks, I will
 
2:52 AM
@rlemon Concur.
 
3:10 AM
I like this "truefriends" thing
 
0
Q: nodejs: Identify file clone

mido22how to identify if two files are same in javascript(nodejs), one is just a renamed copy of other? Use case: I am trying to write a script for syncing a HDD( hdd1) and it's clone( hdd2). 95% only video files( size:1 GB (approx), count: 4000(approx)). Sometimes I rename the files in hdd1 and move ...

 
@phenomnomnominal what if the user passes in both left and right, or both top and bottom? how do you think the constructor should proceed?
 
@mido22 just read that—I doubt there's an easy way to do that
and if you do find a way, it's going to be really slow
Why don't you have a version control system or something, i.e., git?
 
but still, it should be faster than copying a 1 GB file right?
 
how to begin with javascript?
 
3:23 AM
@royhowie, not sure how vcs would help here.
 
@user4275686 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.
 
You have to read and compare each file to every other file (well, on average n/2 files), so it's O(n^2)
 
@mido22 hashing would be, yes
 
Hash files, put hashes into set
Calculate set0 & set1
 
@copy the files are 1GB
 
3:24 AM
@royhowie first round, i ll just compare the location of files and eliminate the common ones
 
In the optimal case you read all files exactly once
 
@Jovito I don't think the user should be able to set those
 
@copy even I was thinking of hashes, but like royhowie said, it might take long time.
 
@phenomnomnominal ?
 
@mido22 less long than comparing the contents of all files
 
3:26 AM
@Jovito setting bottoms depends on h being set right?
 
@mido22 You have to read all files at least once anyway
 
@phenomnomnominal yep
 
no, in first loop, it just compare the location of files in both hdds
and remove the common files from both list
even in the first loop, i would read the location of the files
 
@mido22 about what % of the files will be eliminated by doing this?
 
@Jovito so to set top, bottom, left and right, you need to have initialised the x, y, w and h first right?
 
3:28 AM
@phenomnomnominal yep
 
about 80% - 85%
 
One way to compare files is to read the length.
 
so I'd just check that that's true before setting the others
 
It's like a hash but with more collisions, and faster
 
otherwise you're gonna get NaNs
 
3:30 AM
heh just ordered a custom set of keycaps for my keyboards
turning into an addiction very fast
 
@KendallFrey that sounds like good idea, first take file size, if file size are not matching, delete / copy, then check hash just for the files whose size match
 
@phenomnomnominal that's fine, but you didn't answered the question I asked you
 
thanks guys
 
Well, if you want to find the match in the other set, you still have to hash all files in the other set
You might be able to do that lazily though and only hash those files which files sizes match
 
@mido22 If the hashes match, you still probably want to check the contents.
 
3:33 AM
@KendallFrey No, why?
 
@Jovito I can't remember the question.
 
@copy think multiple hashes, where the file size is the first pass
 
16 mins ago, by Jovito
@phenomnomnominal what if the user passes in both left and right, or both top and bottom? how do you think the constructor should proceed?
 
@copy in case of collisions
 
@KendallFrey If you do the Math for the probability of that case, you'll end up somewhere at "if all computers hash all possible files, it'll take a billion years to find a single collision"
 
3:36 AM
depends on the hash
 
Even in the case of md5, you wouldn't find the collision randomly
 
@Jovito I did answer that.
 
@phenomnomnominal Wait. You do understand that what I want to be able to do is something like:
var rect = new Rect({left: value, centery: value})
 
I'd prefer helper methods
 
!!s/method/penguin/
 
3:48 AM
@rlemon I'd prefer helper penguins (source)
 
@KendallFrey what?
 
4:10 AM
@rlemon which keyboard do you have?
you have a cm right?
 
What's a cm keyboard?
 
@Jovito and what would be the height of the rectangle in that situation?
 
ahh ok for some reason I thought you had a cm storm, must be yutt
just ordered these keys for my new work keyboard coming in
 
Das Keyboard 4 lyfe
 
4:12 AM
dem c64 keys.
 
for the price, it isn't a bad keyboard
I was surprised.
 
@monners I looked at those as well, I wanted a smaller kb
going blank keys like a bauce
 
@Loktar Did you see their compact series? They're pretty new
 
I wanna order a wasdkeyboards mech
 
ah nope, nice
 
4:13 AM
just need to get around to it
 
@rlemon yeah thats where i ordered my layout from
today I ordered a poker 3, and a cm storm quick fire
cherry blues for the work one, gonna be clacking hard lol
cant wait to get it in the mail tomorrow lol
 
4:29 AM
@Loktar That's pretty sexy
I already have three mechanicals, can't really justify buying another one :(
 
@phenomnomnominal 1, which is the default value if no height is passed in.
 
The next device I buy will probably be a new iMac
Just waiting for the next generation to come out
 
@Loktar BT?
 
4:48 AM
WHY DON'T YOU COME HANG OUT INSIDE MY HOUSE. WE CAN COOK BREAD AND CHAT ABOUT OUR INTERNAL SKELETONS.
4
 
5:03 AM
@KendallFrey though I do not know much about hashes, I tend to agree with copy, the odds of having two different files, same size and same hash is quite low.
 
5:33 AM
@Shmiddty no wired
detachable though which is nice
 
5:50 AM
No research, no effort question
 
6:38 AM
@GNi33 Happy birthday! :D
4
 
6:48 AM
@monners We just talk about the books we're reading occasionally :P
@GNi33 Join Goodreads, I'll just make a group on there
@monners Damn, that book looks awesome!
 
I tried to upgrade my PC from Ubuntu 14.10 to Ubuntu 15.04. It doesn't even boot now...
 
Hahaha
That's unfortunate
If you want to join the book club, make an account on Goodreads and join this group goodreads.com/group/show/163932-stackoverflow
4
 
Guys, mate in my company told me it would be a financially disadvantage to implement cache DB for your website unless your website is "pretty big". How "pretty big" should your website be in order for it to be an advantage to implement cache DB to speed things up?
 
7:12 AM
I can't even access the GRUB menu :(
 
if(check=="false")
{
return false;
}
else
{
return true;
}
var check ;
can i write the code like this
or is there any error
?
 
@Cool 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.
@Cool 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.
 
7:28 AM
@Cool You can. It's not logical, but you can.
 
Friends = Try out your latest app and like it on Facebook
Best Friends = Attempt to Brute Force or DDoS your server, and if it works, make a deal with him to stop what you are doing for $200.
 
7:42 AM
@Cool return (check=="true")? true:false;
@DenysSéguret BootRepair
 
@Neoares Checking a string is a bit meh, too.
 
7:54 AM
what was the nifty js thing
which allowed to take input inside an alert like thing ?
#age old tech
 
prompt
 
8:24 AM
@SomeGuy Hey man, thanks a lot :)
 
@copy ping
 
@EnglishMaster DDoS is illegal by law in most countries. It's the equivalent of breaking into your best friends house as a joke. If you do that, you're just an asshole.
 
@RoelvanUden you can DDoS your own app
 
yeah
that's not illegal
 
@Neoares your own server* sure. Not a friends server.
 
8:31 AM
@EnglishMaster breaking into your best friends house is a joke? you bet that's illegal :D
 
I mean, FBI/CIA/NSA/MI6 won't be monitoring you while you are DDoSing your friend's web server unless he actually reports you.
 
^ "If I kill a man and they don't catch me, it's not illegal"
You must realize how wrong you sound, right?
 
yeah, it's still illegal
 
Ok I'll just silently kill "DDoS" from the epic quote I've posted here
would it be acceptable then?
@RoelvanUden Come on, don't compare it with killing a man. It's like you are coupling Gimp and Photoshop as same quality tools.
 
it is acceptable as it is. It's just a fact that it's still illegal :D
If your friend doesn't report you while DDoSing his server or breaking into his house, nothing will happen
unless someone else notices and reports you
 
8:37 AM
@EnglishMaster I know a girl who massively favours Gimp over PS
 
@RoelvanUden haha, that page is ep.... uhm, briliant! it's brilliant...
 
That is so epic
 
Hi every one
 
9:22 AM
@Neoares yes, it worked
 
@DenysSéguret profit
When all your hope is lost, BootRepair
 
Hey guys. does anynone know if Socket cdn down?
socket.io*
 
when i go to that site it says Your connection is not private

Attackers might be trying to steal your information from cdn.socket.io (for example, passwords, messages, or credit cards).
 
@MarcRasmussen Their cert ran out today
 
9:36 AM
@BenFortune what does that mean?
 
It means their SSL certificate has run out.
 
@BenFortune is there anything i can do or should i just wait?
 
They probably already know, but open an issue in their Github or fire them an email
 
use http:// instead
 
my timer function not working anyone guide me my code is here => jsfiddle.net/8nxz3nkg
 
9:40 AM
how the hell do you forget to renew your certificate as a CDN?
 
it's not the CDN, it's the socket.io who forgot
 
what?
oh wait, are they only hosting their own library?
 
I mean, when you use a CDN, you have to "integrate" your SSL certificate with your CDN provider
so, it's not "coudflare" or "akamai" fault
 
yeah, it's not that bad then
 
@Neoares AWS :p
They don't use a hosted CDN, it's their own
 
9:45 AM
they use cloudfront
 
how can I check what they use? I was thinking they host it themselves too, that's why your statement confused me a bit
 
AWS :d
 
ah, interesting
 
@GNi33 use that web :D
 
Ah, so they do.
I just saw AWS in the NS
 
9:49 AM
How to convince my manager that using window object to store the state is bad!
 
@BenFortune I also favours Gimp.
 
@SheepyShaun Hi!!! :)
 
I have a Chrome extension filtering out some questions from SO. Now I use this to recognize the painful questions:
var badQuestionPatterns = [
	/document\.write/,
	/beginner/, /newbie/
];
Do you see other patterns ? (don't suggest /jquery/)
 

« first day (1684 days earlier)      last day (3271 days later) »