« first day (2127 days earlier)      last day (3046 days later) » 

19:00
look, you were wrong / made a mistake. own it, don't try to make excuses.
@rlemon Why would it be an excuse ?
nvm. no bother. just take luggages advice and don't do that in here
please and thankyou
@Victor fencing is correct
Our objections aren't just because we didn't like the style or anything. You had variables that weren't defined, it was not clear what was supposed to happen. You calll a "functionA", but only define (and never decare) an "A". Your code, at best, leaves it to the reader to correct variable names to get it working. Even then, if that worked, you show a promise constructor. The one thing you are supposed to avoid.
None of these are opinions.
Couldn't agree more.
19:04
ok then. We can move on. :)
this post has been deleted and undeleted at least twice lol stackoverflow.com/questions/38924330/…
guys, sorry to bother! I have this start of an HTTP API for my web app. This is not a structure to keep because it is not maintanable and I have to rewrite basically every piece of code for things like requiring a user to be logged in to use a certain API module.
Were we stuck ?
How should I structure this side of my app so it is scalable and maintainable. If I were in PHP, I would write a class something like abstract class ApiModule and extend it for every API module I have, then centralize the modules in an ApiEntry to compute urls and stuff. But Node confuses me from this point of view
@Victor one app.use('/api/secure', (req, res, next) => {}) that does the auth, then the rest of the /api/secure after it
19:08
@Luggage I was going to say that, but still, it does not seem maintainable for like ~150 API modules
How is it not maintainable? A single entry to say "all of /api/secure/*" needs to go through this authentication.
but I don't want templated URLs
I don't follow.
Explain what you'd like, please. I can't pinpoint, yet, what is missing.
I want POST /api/blog/write to require authentication, and I want GET /api/blog/read not to require any certain state. Your approach would ask me to do something like GET /api/blog/read and POST /api/secure/blog/read
Ohh, I assumed /api/secure because that is what your code said.
19:13
@Luggage that was for testing only
that repo is still under heavy development
In my PHP app, I had the following configuration for my API modules
so you want to auth based on request type on a given route?
app.use('/api', (req, res, next) => {
  if( req.type === blah ) return next();
  // handle the other case
});
a /bin/api/modules directory, which contains files like ApiRegisterUser.php which has class ApiRregisterUser extends ApiModule and every class can require anything it wants that's covered in ApiModule
there is nothing stopping you from whipping up an "ApiModule". If you have a lot of repeating code, just put that in a function. app.use() can take an array of middleware, so you can have a function that decides to include or not include the authentication middleware besed on your preferences.
//not from real code
makeApiCall(requireLogin, apiMiddleware) {
    if (requireLogin) {
        return [ authMiddleware, apiMiddleware ];
    }
    else {
        return [ apiMiddleware ];
    }
}

app.post('/api/foo', makeApiCall(true, (req, res) => {}); //this one requires auth
app.get('/api/foo', makeApiCall(false, (req, res) => {});
I think app.get and app.post also take an array like app.use does, but I don't know off the top of my head.
The point is, you have the power to remove any duplicate code.
@Luggage I see
I told you about something I did in PHP
19:20
I use something different, lemme see if it's something i can paste or not
@Victor I forgive you
this is the file tree I had.
yyea, you can do that, too.
I see this as a very structured approach
but in php, I had autoloader for my classes, here in node, I have to manually include all of them. well I could do some trick to include an entire directory recursively, but I am not sure whether this would be a good JS pattern
19:23
on node, yes, you can do that. There might be a simpler way, but you could always just use the 'fs' module to list files and require(filename) them.
at server startup
@Luggage so can you paste it or not? :D
see this for loading all files. the answer looks good: stackoverflow.com/questions/5364928/…
mine is very different. I have a single "RestResource" class, that I create an instance of for each object in my model in one file
export default function include(file_) {
    with (global) {
        eval(require('fs').readFileSync(file_) + '');
    };
};
;) just toss everything into the global scope :D
(don't do this ^ )
nah, why global?
ohh, ok
@Luggage friday fun
showing purposely bad code as a joke is fine, if you call it out as bad and a joke. (in case anyone is seeing irony here)
19:29
thank you very much guys
I'll try implementing something and I'll give you links to github if you wanna see
@rlemon that might be one of the few things worse then importing all modules by default
@William ^
How are you supposed to handle errors in redux? Just persist them to the state...?
if you come from a PHP background, it will feel natural. :D like a good old import call :D
(really, don't use that code ever)
I'm not pushing this is 'the way', but 'a way'.
19:32
@rlemon Remember when he died?
lol
@rlemon I am not going to use that, no.
Oh, do we want to start a pool on how long it takes @SterlingArcher to actually man up and make things official with this girl of his?
and that RestResource defers many decisions to the model. Like then you call model.getById(id, { currentUser: req.user }); it'll throw if that user can't see the record.
@Trasiva after he fucks it up of course.
19:33
anyone here got experience with webpack?
has it been long enough for anything to be official? did he knock her up or something?
@Luggage I am curious of one thing. are you using plain node js in that code? I cannot use es6 import in node v6.3.1
and yeah, your way is pretty interesting
i use babel.
babel to transpile server-side code?
I don't remember what node supports natively and not.
yea
that way i use all of es6.
19:35
I didn't bother to do that
seemed overwhelming, but you're right, using all of es6 is pretty fine
your loss. it's fast and easy. gulp and babel.
@Luggage I might switch to that sometime :))
@rlemon You think he'll fuck it up before he finds his balls and actually labels it a real relationship?
Yes
the gulp-babel github page has a fully working config for that. it's not a big deal to set up.
19:36
What happens If I get a prepaid sim and then I leave the country ? And forget paying about it....
@Luggage @Jhawins (other americans)
I dunno man, he seems to be finally getting it.
in the US?
your US pre-paid sim probably won't work outside.
yes in the US
@Victor there is like a million ways to use es6 fully with node. Pick whatever is easiest for you
no I know it won't work outside
19:37
I get a sim in the country I am traveling to.
i'm wondering if I want to take another sim
@rlemon enumerate the first 100k of them, please?
I misunderstood the question
will I have to pay the due for the older one?
but.. it's pre-paid. there is nothing due, right?
that's what pre-paid means
19:38
right!
k then :D
@Victor babel in Gulp, babel alone, babel register, harmony flags, <insert 900 other build tools>
so I shouldn't be bothered right?
cause over here in India you simply just don't pay and your number is reallotted 3 months later.
I don't see how. Your only concern is that your phone in on US bands and unlocked to use any carrier's sim card.
then you just pay, stick card in, call.
19:39
so, t-mobile and at&t are your only options, really. they use GSM phones
as long as your phone isn't stolen, they don't care about previous sims. You can change back and forth if you have to
@SterlingArcher @ndugger Yeah, try not to do that please
Don't take the bait
US carriers will prevent stolen ESNs from working
Leave a constructive comment, downvote and move on
@Luggage so consider this

I got a number in December, Paid for december and Jan
used it in December and January
@MadaraUchiha @ndugger's a master baiter though.
19:44
then I came to India :D
and forgot I had that number
Now its August
@Trasiva Yeah, but he was baited into it too this time
ohh, i see, you have an old sim card from the US. I don't recall how long until it's invalid.
am wondering will they simply just cancel my number
or will I have to pay my older dues? if I want to get a new sim card
they will cancel it after some time, but I forget how long that is
@MadaraUchiha Oh I know, I saw what was going down. Left my comment, downvoted, walked away.
19:45
if it was truly pre-paid, there won't be old dues.
It was T-Mobile's simply pre-paid
my girlfriend wanted to preserve her number
I'm not familiar with the plan, specifically.
so she suspended her account, now they have reported her
to a collection agency
thats why am wondering about mine D:
and I guess this will affect her credit?
it could. I've seen some plans that are called 'pre-paid', but they are monthly plans. A true pre-paid is, you buy the minutes/data and then when you run out, you just run out. There is never anything due
so.. I don't know what that deal was..
yea, t-mobile "simply prepaid" doesn't look like a real pre-paid. you pay monthly for 'unlimited'.
The only difference with a real pre-paid is that you might need to cancel a plan.
@Abhishrek when are you going to be here and for how long? east coast again or somewhere else?
@Loktar cheap? (re: tweet)
19:51
@Luggage 27th Aug. - 23rd Sept.
it isn't reviewing well
:( $66
I think we need to make this a Cap command for RTFM:
Listen here you little shit, the answer is right there in the manual. Quit vamping
this is how we should ride the bike in parks here in romania
20:19
you mean you want horns that loud in romania. I loved how you need like a backpack sized equipment to get the horn to work
@William we have horns in Romania wtf
but such a loud one is good for bike because people are generally idiots who walk on the bike trail
@Victor I think you misunderstood me. I don't think it is common to have horns that loud though
@William oh, yeah, ofc :))
but I told you why such ones would be nice on bikes
have you ever come to romania?
@Victor Generally here in the US, bike trails are also open to runners/joggers and not bikes exclusively.
@Trasiva yeah, here as well, of course, but if an alley in the park is 3 meters wide, you will certainly find a family of at least 4 people taking the entire width of the alley
20:25
That's what long range tasers are for.
if you ask them to make you some room, you can't believe how rude they can be
@Trasiva LOL :)))
@Trasiva do you use express js?
They actually make darts now that have their own built in capacitors, so once you fire them they automatically pulse for...five or seconds if I recall correctly.
;Nope.
@Trasiva I will buy one :)))
are they legal?
Not sure for Romania.
I will check that out tomorrow
20:28
I should mention it's a shotgun round however.
good to know
20:39
If I wanted to pass an object method as a parameter to a function, how do I prevent that method from being removed?
It's in the Olympics vOv
That's a good example.
Test outputs {hi: 1} but doesn't show the guesswhat function.
@KendallFrey Google must be having a field day over the searches going on right now.
Crap never mind I'm just dumb. It's there but when output to console.log it's removed.
It's not removed, it's going to output object[object]
20:43
turns out a lot of the events get suggested to "is not a sport"
@Trasiva, so the reason it doesn't show up is because it's evaluated as undefined?
Where are you doing this? Because it shows up fine in my console and jsfiddle.
If you expand the object, your guesswhat function is in there.
You'd need to actually -call- it in order to get it to fire the alert.
I was doing it in my console. The result of running my code in the above gist in Chrome yielded me with {hi: 1}
in my console.
And you didn't expand it.
Click the arrow pointing right, and guesswhat is right below it.
Ugh I'm retarded. Thanks Trasiva.
But I do have a legitimate gripe (I think). Here is how I'm actually using it.
dialog_btn.addEventListener("click", opts && opts.btnClick || this.close);
20:47
...
This is inside a class, and it doesn't work like I want it to. What I'm trying to do is say:
If user has included opts, and there is a btnClick func, use it. If not then default to close "this"
A dialog class, if it makes more sense.
Why would you ever think that would work?
Have you even read the MDN on addEventListener?
It works for values, but I guess since this isn't quite assignment it doesn't work.
dialog_title.innerHTML = opts && opts.title || "";
That works, and no. Not in depth, BRB
Ok so it says I have to use an EventListnener AKA JS function there. I guess my confusion is mainly behind how a function is represented in JS. Most times I can use a function just like any other variable.
But not here.
What do you mean? There's two examples in there showing how to call an existing function, and using an anonymous function.
Are there any short-circuit ways of doing this like I did with innerHTML above?
20:52
Let's try and make some sense out of this hot mess.
What's your end goal here?
it's a dialog. This particular part is assigning a function to the "SUBMIT" button. The goal is to use a user supplied function, provided in the class' "opts" variable, or default to this.close()
I can figure out how to do this long form with if statements.
But I am looking for short form like this:
dialog_title.innerHTML = opts && opts.title || "";
my class func looks like this: function Dialog(elem, opts)
....you know what's going to happen if you set the innerHTML like that?
The only thing I can see is a local XSS issue, but I could be missing something else.
innerHTML literally changes the html within the element.
In the case of a button, you're going to change the text.
Well I have that too.
This one takes care of the title of the Dialog:
dialog_title.innerHTML = opts && opts.title || "";
20:57
Where's this opts variable come from?
Let me say this again. That will not work. It will only give a boolean output.
What??? But it works.
It shouldn't work like that.
@Trasiva I don't understand that as well...
You should actually be getting an error.
is it the same as global.appName || opts.appName? I think that && doesn't make any difference, right?
21:00
@Victor, well it does because what if opts isn't defined?
You SHOULD be doing something more like dialog_title.innerHTML = opts ? opts.title : '';
So pretty much it's just tacking onto the short circuit evaluation
Well I guess that works too, is there anything wrong with the way I'm doing it other than the obvious confusion?
That's called using a turnary.
this thing is everywhere
and I don't understand why it works
Well it uses short-circuit evaluation.
21:01
Right, THAT will.
I'm not a dummy guys (I PROMISE!) I just have poor classical education.
opts && opts.title || "DEFAULT"
Notice there's no AND comparison though.
@Trasiva yeah, true.
pretty much says if opts doesn't exist, don't bother checking opts.title and just default to the other value (which in my case is a default)
I wonder if there is a JS Perf...
101
Q: What does the construct x = x || y mean?

opHASnoNAMEI am debugging some JavaScript, and can't explain what this || does? function (title, msg) { var title = title || 'Error'; var msg = msg || 'Error on Request'; } Can someone give me an hint, why this guy is using var title = title || 'ERROR'? I sometimes see it without a var declaration ...

21:02
@Forty3 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.
@Vap0r braces
At any rate, I could use ternary evaluation for my issue with addEventListener I'd assume.
@rlemon braces?
I figured out why my stuff wasn't working, it makes sense that it works that way, but yea....
@Vap0r I know what it does, but I find it stupid. Other languages have operators like ?: or ??
Anyways, time to pop smoke.
21:04
@Vap0r nvm, just sat down. mis understood
this just seems messed up. if a = true; b = false; c = a || b why return a instead of true?
use a ternary
!!afk Time to pop out.
Alright thanks guys happy to confuse everyone for a second by non-standard use of the language
short circuit evaluation isn't non-standard
just avoided in many cases.
21:05
@rlemon do you know why it evaluates incorrectly for addEventListener but works for the other cases? I'm guessing because the function is evaluated for a value instead of staying how it is?
because it results in a boolean
ternary lets you return values
dialog_btn.innerHTML = opts && opts.btnText || "SUBMIT";
(opts && opts.title) evaluates to true if opts.title exists
results in text though, not booleans
anyone know how to save a js variable to a mysql database ?
21:07
@Vap0r my guess is that it says (true) || "submit"
@Shago AJAX to server-side language to MySql would be my guess
@rlemon, not really though because if I supply the opts variable as {title: "blah"} the title will be "Blah"
eh, then it is just how it breaks down the statement
look at what the operator precedence is
I think it's because it's not judging for true/false but rather falsey/non-falsey values
naming convention question - myObj.DebugEnabled or myObj.EnableDebug ?
So if the response is non-falsey it returns the actual value.
@Forty3 first would be a status, the other would be a command?
21:09
it still would be more clear in a ternary or using if statements
readability > saving a line, or a few chars
@Vap0r - kinda what I thought. Thanks.
ajax results in another js variable with my experiance
@Shago ajax is a technique for sending asynchronous http requests to the server
@rlemon completely agree, just funny when there are some confused looks and people tell me it doesn't work. I mean, I know it works just don't know why!
which may or may not result in a return
21:10
Bye guys!
later @Vap0r
@Vap0r because the js interpreter adds () braces where appropriate (operator precedence)
so you're looking at true && blah || blarg, or true || blarg
from what you're saying, the former
I have to go guys
good night!
or whatever it is for you :D
21:29
safari 9 doesn't support arrow functions
bah
@SterlingArcher Did you hatch it?
this is really broad question but what is the best way to emulate google search locally?
with indexing supported
21:47
scrape the entire web
or do you just want to add search capabilities to your own site?
@rlemon just let's just say for html web page documents for now
local doesn't matter if scrapes the entire web
well that doesn't really answer anything
do you want to create a local search engine?
yes basically add search to my site
so node.js is fine I guess
you might want to use a spider / crawler to index the key terms for your pages
npmjs.com/package/node-spider comes up in a search
interesting although I can't tell if that scavenges the pages for me or not
nevermind appear handlerequest loops through links
it doesn't appear to be a recursive spider
@rlemon how narrow of question would i have to make if i wanted to create a spider for my own site?
22:00
WAY back in the day I used this sphider.eu
yes i should know rules like this but i want to make sure
once
you can use it, or reverse engineer it
php bahahahahhaaha!!!
it worked pretty well as far as I can remember
your joking maybe I'll try it
22:01
working software is working software
I'm giving you a decent example
i'm actually thankful if you can't tell
it is downloading
basically you want to (afaik) crawl your pages and get the keys/terms in a db, then have a search algo look at that db to give you weighted links on a search
it was years ago, but I recall sphider doing that with fairly good accuracy
it bewilders me how complex search is to this day. Even windows search doesn't adequately do a lot that would make sense. Yes I want my epubs and mobis indexed!!
1 message moved to Trash can
@ElieSaad Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
$.each(JSON.parse(obj.y), function (index, value) {
         console.log(value);
         series.obj.push({ y: value.y })
});
Guys i have an error passing obj.y: Cannot use 'in' operator to search for 'length' in 1.
my obj.y is the y attribute of my json which is an integer.
22:09
nope, it's not referring to obj.y
it's referring to $.each
obj.y = integer, right?
$.each( a, fn );fn(b){...} is basically same as for( var b in a ){ ... }
a has to be an array, object, or be object-like
in your case, a is an integer
for( var i in 423412 ){ ... } is not a thing
I see, thank you for your feedback.
actually, in your case it's for( var i in 1 ){ ... }
np
Hello !
22:19
@manonthemoon 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.
Is there any experts of Facebook JS SDK please ? I have an issue with the logout method. When I logout the user from my app, the login status returns me unknown instead of not_connected. I couldn't find any solutions, work around etc. Anyone ever experienced that problem ?
@SterlingArcher yeah, that's awesome, it was posted here before a few months ago iirc
Apr 14 at 17:52, by ndugger
http://classicprogrammerpaintings.tumblr.com/
@Luggage are we meeting
Hi. What is the difference between "import foo from X" vs. "import {bar} from Y" ?
@Peter I started writing an answer and wanted to link to mdn only to see mdn explains that as an example.
22:32
Thanks, I'll look at it.
Sure
By the way, now that I'm here - Chicago is really creepy.
Everyone is super nice, even more than the typical American discussion excessive "let's make everyone feel welcome". I was sure they were being sarcastic until I saw they were doing it to each other.
22:46
@BenjaminGruenbaum Wait till you come to Canada
@towc As I mentioned earlier, that's way too many people
some are just too damn cute
23:03
@BenjaminGruenbaum don't come to NZ, you'll explode
wohho
@sg28 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.
stack Chat
@BenjaminGruenbaum lol
never thought one can chat without the drama,pure knowledge ..let me sink in!
Can anyOne tell me what is the best technology using JavaScript to get into BigData
23:27
@sg28 you were right ;)
@sg28 try vanilla-js
not quite sure what you're asking

« first day (2127 days earlier)      last day (3046 days later) »