« first day (1540 days earlier)      last day (3424 days later) » 

8:19 PM
if (condition >= 0) { var a = 'value';alert('All is good')} else {alert ('it broke');} <----- If the value of CONDITION is 0, is there any way/reason that the script would respond first with the TRUE condition and then follow it with the FALSE condition??
 
@DMSJax 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.
 
code run twice with the value of condition changing inbetween?
 
its wrapped in a FOR statement, but I tried adding BREAK at the end of the TRUE condition and it ignored it..
 
jsfiddle?
 
jsfiddle.net/hmmuymv3/1 give it a valid address to test against
 
8:24 PM
@DMSJax perhaps it's failing for a different address component?
also, learn to use var component = results[0]['address_components'][componentKey]
 
i don't use javascript very often, I kinda have to relearn it each time i use it, but for this i had to, so im sure the whole thing could be done better/more efficient. If I can get it functional, I'll go back and rewrite it to be more correct
 
look at .some and .every
 
I\ll try to comment out the other components and see if it still fails same way
 
putting a breakpoint there might help, too
 
commenting out line 30 through 66 on the JSfiddle results in the same failover, if a valid address is provided it returns the alert from the TRUE condition followed by the alert from the FALSE condition.
 
8:33 PM
I mean, you have one loop inside another. A break only terminates the inner one.
 
In jQuery, I could do something like this $(el).live(function(){ this; // reference to the el})
 
@Catgocat no, you couldn't.
 
Now, this is deprecated. So I do $(par).on('click', 'el', function(){ // how to get a reference to the el?})
 
@Catgocat this
 
8:35 PM
Because the the element el, is not unique in the page and only the one which is clicked needs to be modified.
Wouldn't this make a reference to the par?
 
nope
 
Oh
Are you sure
 
look at the docs...
 
ok thx
 
Jan - is there a way i can use JS label to come out of the loop? I mean i do need the loop to continue over the other IF statements, just need it to stop looping through the current if statement if condition is TRUE, thats what I THOUGHT that 'break' would do.
 
8:37 PM
You can use a labeled break, but look for a cleaner way
 
@BenjaminGruenbaum when you get a sec, question about the disposer pattern and multiple DB calls.
 
sigh... ok, off to the drawing board again, thanks for looking at it, i'll look over your suggestions.
 
@SomeKittens shoot
 
@BenjaminGruenbaum This may reveal a misunderstanding of how I think db calls work, but here goes: before the disposer pattern, I could make multiple queries with one "Get DB"
 
@SomeKittens you still can
getDb(function(db){
    var firstCall = db.query("SELECT * FROM ...");
    var secondCall = db.query("SELECT * FROM ...");
    return Promise.all([firstCall, secondAll]);
}).spread(function(firstResult, secondResult){
     // do stuff
});
Your app generally shouldn't make multiple DB queries if it's per-request, one db request per user request is where you want to be- if any.
 
8:42 PM
heh - whoops.
Turns out I getDb in that section but never actually use it.
 
I wouldn't fret over that.. You just want the requests to be fast and efficient, regardless fo the number of reuest to the db.
Instead,work on removing from the request the things you have to do all the time. Like i you find yourself with the same db query every request to get common data, look into caching it.
 
Alright, if I come up with an actual example, I'll get back to you. In the meantime, is there a pattern for then-ing where the previous function might return a promise?
 
@Luggage websites generally want to hit the cache whenever possible, simple stores tend to be faster than DBs but I guess it's on a per-case basis.
Yeah.
 
@Luggage Session data is cached in Redis
 
@SomeKittens Promise.resolve, but you can return anything from then, I just had an answer about that yesterday.
 
8:44 PM
Right.. but it's not about one query being better than two.
 
especially if it means some ugly query or ugly code to get it into one
 
  if (result) {
    return done(null, result);
  } else {
    return user.createFacebookUser(profile, accessToken);
  }
Something like this (where creatFacebookUser returns a promise, and done doesn't)
ooh, wait
misunderstood my own code again
this is what I get for picking up a project six months later
 
yea, that's pretty confusing. returning the value of a node-style callback from a promise valued expressiob.
 
@SomeKittens everything you return from a then gets Promise.resolve called on it.
Oh wait, don't do done callbacks there to begin with
 
8:46 PM
@Luggage it's Passport
 
You can always .nodeify which produces a callback automatically.
 
@BenjaminGruenbaum how would I do that in the above code?
 
Any good tools for writing readable html/css and generating ugly inline css for emails?
(yes, i've searched, looking for recommenations of things people have used and like)
 
Ink
 
8:50 PM
Right.. i know there are lots out there.. looksing for a "I like this one" not a "google said this when i copied and pasted your question" :)
or you mean you found for you own use?
 
ink looks pretty good so far.
 
Sorry, was commenting - reading now
Wait, why do you call getDb if it doesn't give you anything?
What does it actually do?
 
@BenjaminGruenbaum In a previous world, it bound this.client = client
 
Right, but it definitely shouldn't
 
8:56 PM
return getDb().then(function() {
    return this.client.queryAsync('INSERT INTO customers blah, blah
@BenjaminGruenbaum right, moving to the disposer pattern now
 
ink seems to have exmaples and documentation but no code.. is it an online only service?
 
Correct, or at least that's all I've used
 
function(accessToken, refreshToken, profile, done) {
  getDb(function(db) {
    return db.queryAsync('SELECT * FROM profiles WHERE profileId=$1', [profile.id])
    .get('rows').get(0)
    .then(function(result) {
      if (result) return result;
      // First time login, we need to create a profile
      return this.client.queryAsync('INSERT INTO profiles (profileId, username, email) VALUES ($1, $2, $3) RETURNING id',
          [profile.id, profile.displayName, profile.emails[0].value]);
    }).then(function(id) {
 
hm..
 
@SomeKittens
 
9:00 PM
Looks sound.
Passport's done has a third parameter - options I can pass if the login failed, but there wasn't an actual error.
done(null, false, { message: "B.O. too funky to login" } for instance
 
That's awful.
That's the problem with nodebacks, they don't enforce uniformity and people disregard how code normally flows. Functions either return or throw.
 
I don't wanna hear you say anything bad about node.js
 
It's badass rockstar tech
 
:)
 
With rocket unicorns
 
9:04 PM
It's both sad and uplifting that it must not have taken long to find that image.
 
Literally the first result
 
That rocket as a stem.
 
We call it an antenna in the business
 
Such abstractions, very wow
 
It may well be the Biting Pear of Salamanca, we just can't see its face
 
9:14 PM
woo!
it's a thing!
 
Hardcore
 
fanservice to him imho
 
9:33 PM
@BenjaminGruenbaum codereview pls: gist.github.com/SomeKittens/5a8c40400b13a4a56858
 
Why the exit?
Also why the .catch(console.log)
 
@BenjaminGruenbaum I have a few scripts (Seeding test data for instance) that are run as one-off things.
 
That doesn't explain why it's an option of the function though.
process.exit is a huge decision and a db connector shouldn't make it you can always useDb(..).tap(process.exit) or something like that
 
Wouldn't the tap be executed before the db is closed?
 
after the promise resolves
Also, you don't need to console.log bluebird will log unhandled rejections for you anyway.
 
9:38 PM
ok, so nix the log
@BenjaminGruenbaum ah, misread that.
 
would that even work without console.log.bind(console)
 
most likely no
 
@Mosho it does, I think
 
Wait, no reason it wouldn't work
It's node, node console.log doesn't use this if I recall the code correctly
 
I use the Bob Ross school of programming - all my code is happy accidents (at least until Benji catches wind of what I'm doing)
 
9:41 PM
@BenjaminGruenbaum thought that might be the case
 
@SomeKittens Really though, why would you .catch with console.log?
 
@BenjaminGruenbaum I just tested it - Node is fine with a naked call to console.log (Chrome isn't)
 
If anything, catch with a function that logs and then throws in the global namespace.
 
@BenjaminGruenbaum I'm not quite sure.
 
s/call/reference/
 
9:42 PM
@Alnitak For what it's worth someone should make a feature request for Chrome to allow it.
 
perhaps. It's never bothered me that it generates an illegal invocation error
 
It's just more to write
 
9:56 PM
    throw new Error('Could not find friend');
just found that error. Heh
Obama authorized North Korea sanctions over cyber hacking. Solution there, it seems to me, is to create unhackable systems.
Stick to astrophysics.
 
10:31 PM
@SomeKittens I wonder what "common" people think when they hear such stories, if an educated man like him says such things.
 
@Zirak "Computers are magic and can do anything"
Cross that with "Anything I don't understand is easy" and you've got trouble.
 
That's his obvious intention though. I wonder if he meant something different.
Nah
 
What he could have said was "More secure systems"
 
Most places don't take security seriously for a good reason though - security is a hassle
The cost of getting hacked for most services isn't a big deal - not everyone is Google
It's just not very code-effective to pay for penetration testing and good security practices.
 
s/security/design/ and I just had this discussion in #startups
(though security was brought up)
 
10:39 PM
They're right though, you know. Never underestimate how important delivery is.
That's why the way to go with security is safe defaults and to make writing secure software easier than insecure software.
 
Design/delivery is important, just as security is important. But everything's a tradeoff.
Design/Security for a seed-stage startup is along the lines of Bootstrap/OAuth because that's "good enough" for the amount of time they can spend.
Both of which made doing it the "right way" (subjectively) easier than the wrong way.
 
@BenjaminGruenbaum code-effective? Or cost?
 
cost
@SomeKittens security is not nearly as important as sales that requires delivery.
 
Yeah. We get penetrated annually (lol) and they don't find anything major that often. We also hack ourselves occasionally which is fun and good for learning.
 
I'm sorry, it's painful as a developer to say it but a working product is the most important thing and if we can cut edges and do that in half the time with bad security we should.
 
10:43 PM
@BenjaminGruenbaum lots of products don't work with bad security.
 
@phenomnomnominal paying for external penetration testing works, our CTO worked at a place that does security.
 
E-commerce? Bad security, bye bye custmoers
 
@phenomnomnominal You know how many mildly successful websites there are with trivial vulnerabilities?
 
@BenjaminGruenbaum oh yeah, when they do find stuff it's definitely worth it
 
And then a 14 year old sprays your front page with gotace
 
10:43 PM
@BenjaminGruenbaum was a report the other day that said something in the area of 80%?
 
Yeah, ircmaxell's
 
@BenjaminGruenbaum Dunno, what's WordPress' market penetration?
 
The worst ones are the one's you can't control.
 
@SomeKittens WordPress is an insanely successful platform that powers ~20% of the internet - it also auto-updates on vulnerabilities.
 
Someone hacked an ad server, suddenly we have naked russian women on our home page
 
10:45 PM
That happened to @SecondRikudo once (his company does ADs) :D
 
@BenjaminGruenbaum Yeah, we got the Syrian Electronic Army though
 
@phenomnomnominal that's why I always compile my ads from source in a deterministic environment.
 
Happened to us too. Not as funny as when one of them forgot to pay for their domain name and then someone bought it out from under them and started pushing penis pills
 
@SecondRikudo So naked Syrian soldiers?
 
10:46 PM
It was on routers too (as in, the Syrian Electronic Army was on Routers)
 
Reuters?
 
@BenjaminGruenbaum no, actual routers
 
Yeah, that's what I thought.
 
Also, you shouldn't present it like I caused it. They exploited attack vectors put in place by lazyasses who were no longer in the company by the time I arrived.
 
10:47 PM
Well - my point is often security is really hard and isn't worth it. If you're building a service people pay a lot of money to use it's worth it but most of the time that's not really the case.
 
@SecondRikudo Why didn't you fix them?!?!?
 
@SomeKittens Who do you think got tasked with fixing them after-fact? :P
 
Just to be clear: the exploit was caused single handedly by @SecondRikudo using the mysql_ php module.
 
@BenjaminGruenbaum Information secuirty is always a relative term.
 
He had a mysql_query("SELECT * from table WHERE ".$_GET['search'])
 
10:49 PM
A piece of information is secure if it costs less than the resources you spend on getting it.
 
That's actually a pretty healthy perspective.
It's not really true, but it's still interesting.
 
Well don't act so surprised about it
 
Also, I for once welcome our naked russian overlords
 
@BenjaminGruenbaum If it took me 3 years to crack your facebook password just to get to your Shadow running for PM page, it's probably not worth it
If it took me 1 month to hack into my company's bank account and take everything that's there, it's most probably worth it
 
10:51 PM
@SecondRikudo if you ask nicely I can make you admin :P
 
(Of course, assuming I also have an exit strategy :P)
 
Social engineering will win every time
 
@phenomnomnominal That's true.
 
I'm surprised we haven't started hearing about attacks on data centers
 
@phenomnomnominal you know how "the west" alledgedly infected Iran's nuclear centrifuges with malware?
 
10:53 PM
physical attacks
@BenjaminGruenbaum yeah?
Oh, do you mean do I know how they did it?
 
Threw usb sticks over the fence of the perimeter, people connected said sticks to computers to look for pictures to see if they can find out who to return it to :D
 
In that case no
Hahahaha that's wonderful
 
Then it exploited a 0-day in the way windows used to read autorun.inf files but that's less interesting. The social engineering part was cool.
 
"Find out who to return to"/"find naked pics."
I bet the USBs said top secret, with an american flag on them
 
I once did that with a stick I found (Ubuntu). Turned out the guy had a dossier on all the girls he'd met, rating them. Never bothered to return it.
 
10:56 PM
nude pix?
 
Well, better get some sleep
Good night
!!afk
 
night!
Not even I think you’re beautiful.
 
Hey guys, may you check out my first git project? github.com/afonsomatos/memopad
It's just an old website.. never did anything with git.. so xD
 
Neat
1 message moved to Trash can
 
why
 
Because my car was a piece of shit, and this one isnt
 
Nice
Does anyone know about good resources for starting HTML5 Game development?
 
@Catgocat First, define HTML5 Game development.
 
Working with canvas and applying fisic mechanics.
 
11:53 PM
did you mean Physics?
 
yes sorry my english is not that good
xD
in portugal it's Física
 
Physics can be applied within game development, but it has nothing to do with it
 
I know, but along with canvas
animation..
 
box2d
 
I don't feel like to go to a library.
 
11:55 PM
Just start writing some stuff.
 
Wouldn't it be nicer to do it from scrach?
 
anybody have time to answer a question or 2 about json/jsonp ?
 
@Anonym.. 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.
 
I did already some very primitive html5 games.
I wanted to go in-depth...
 
writing your own physics engine is a huge task...
 
11:55 PM
Alright, write some more
 
Another question for you guys.
 
If you're running short on ideas, just make the basics: pong, brickbreaker, etc
 
Alright
Do you guys recommend pushing every little project to GitHub? I mean I think it's great but that might be a kind of silly. Altough I've seen people doing it.
What are your thoughts?
 
I have a very low bar for my GitHub
 
same. I put whatever there. Why not? It's not gonna hurt anyone
 
11:59 PM
true true
 
unless your code is bad, then it hurts you
 

« first day (1540 days earlier)      last day (3424 days later) »