« first day (1334 days earlier)      last day (3600 days later) » 

@carlosvini 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've dropped the "out of scope" thing a few times.
 
so who wants too hold my hand while I find my way out of the corner I just coded myself into
bad design (no design) is really biting me in the ass at this stage in the game
 
What happened?
 
you know my basic 'structure' ? one device tunneled to a server
 
6:09 PM
?
 
fuck it is hard to explain without getting long winded.
 
user1596138
Draw a picture
 
user1596138
While I make a cup of coffee
 
@rlemon This is a bad sign.
 
I have a device (call it the BBB) which ssh tunnels to my server so I can proxy the websockets. the server serves all static content and handles user login, which also determines which BBB they get their websockets from. the BBB emits 'alarm states' back to the client. I'm trying to implement a system where after N minutes the *server* emails you that you are in Alarm. however the server doesn't really know this information.
and if I try to put it all on the BBB, the BBB doesn't know how many minutes to wait before emailing (or even if it should)
follow?
 
6:14 PM
0
Q: Javascript eval in function

user3722860I want to make a function with eval in it, it have to generate a random number between 2 numbers and you can save it in a variable. I use this code: function rand(ran1, ran2, randVar) { var randomNumb = Math.floor(Math.random()*(ran2 - ran1)) + ran1; eval("var " +randVar+ " = "+randomNum...

 
@rlemon hmm
 
@rlemon shouldn't you base yourself on the client times?
Server could be in America, and I could be in Japan
Did I say something completely off the wall?
 
@rlemon so, let's say we have an alarm flow
Wait, how many components are there, 3?
 
@Jhawins yes there is! digitalocean.com/?refcode=8138b19e1aac there is mine
 
user1596138
@RUJordan Exactly. Although I guess I just made a triple payment and overdrafted somehow :). So nothing for me
 
user1596138
6:17 PM
Next week lol
 
I hate it when that happens
 
user1596138
lol I guess I reloaded the page twice
 
@BenjaminGruenbaum if you don't include the end browser
 
user1596138
Saweeet
 
6:18 PM
@rlemon can you draw a gliffy diagram?
 
[embedded control system] -> BBB -> server -> browser
 
user1596138
No truck payment for 2 more months lmao
 
Ok, that's better
So [embedded control system] -> BBB -> server -> browser, and only components adjacent to each other talk. Right?
 
yes
well yes and no
BBB is tunneled to the server. so on the server it is localhost:port
so no direct access, but kinda. if that makes sense.
 
ok
Now, what is the problematic flow ?
 
6:21 PM
the server contains the information about whether to email, how long until you should email. the BBB contains the information to that would trigger the email (check if you want one, then see if that time is elapsed)
 
@SomeKittensUx2666 Did you apply to Fogcreek?
 
@Jhawins Screw payments, I've never made a car payment in my life.
 
@Jhawins you mean you're done in 2 months?
 
user1596138
@KendallFrey I didn't want to. But I had just moved out a month after 18 and my car blew.
 
user1596138
No I mean I paid 2 months ahead on accident somehow
 
6:22 PM
@BadgerGirl Nope. They're in NYC
 
@Jhawins ah well
 
user1596138
I'm done in like 13 months. Was supposed to be a 36 month loan and that'll be 25 months so. I hate loans and want to have no debt again
 
the BBB emits alarms only if they change. so I can pick them up on the server through a number of ways. but then there gets the nightmare about sessions.
because the BBB has no concept of the session created on the server after login
 
inb4 "things should be stateless"
 
and there is no easy way (atm) for me to pass information from the server down to the BBB outside of the websocket stuff
 
6:24 PM
Meh, why inb4 it?
So, here is the thing.
 
thing should be designed before you start programming by the seat of your pants
^ my bad
 
Hmm, I'm still not sure I understand your architecture.
 
it is a mess. i'm not surprised.
 
If your authentication state is the only problem, and everything is under an ssh tunnerl anyway.
 
half the time I am dumbfounded it even works.
 
6:24 PM
Just reauthenticate on every request you make.
 
if you are interested we can pop into another room and I can try to explain it better
don't want to take over the JS room
 
user1596138
@KendallFrey Bet you can't beat an 18 year old with no co-signer's interest rate! 19% hehe. Higher is better right? ;P
 
@rlemon sure
 
ouch
 
@BenjaminGruenbaum is there anything you don't know? Good lord
 
user1596138
6:26 PM
Fuck the way that works lol
 
@RUJordan most things
 
;)
 
I wish I got 19% interest on my savings
 
user1596138
Haha. Yeah it's sorta like that for the bank that loaned me. Dang that's a pretty sweet deal for them
 
user1596138
Never really thought about the fact that that's exactly what it is for them haha
 
6:27 PM
@Filipe 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.
 
Except there's more risk for them
Because, you know, 18 with no cosigner
 
user1596138
Yeah...
 
Is there a shorthand for q === 'right' ? 'left' : q
 
user1596138
I make payments 2 months in advance though lol
 
user1596138
Apparently
 
6:28 PM
q = (q === 'right' ? 'left' : q)
 
@Cereal that is the shorthand
 
@Cereal Is that what you meant?
 
@SomeKittensUx2666 shorter hand >.>
 
user1596138
Is your hand long enough to slap yourself for me?
 
@Cereal Do if (q === "right") ... it's easier to read
 
6:29 PM
I always found ternary operators easy to read
 
Is there anything inherently wrong with declaring controller's $scope properties like this? gist.github.com/martin-wiseweb/d00051a3e4fb22272680
 
@Martin NO YOU FOOL!
 
Ok so what's up
 
Nah, looks good to me. I'd stick with the typical way because that's what others would expect.
I just like saying "NO YOU FOOL!"
 
lol ok
 
6:31 PM
@Cereal You're lucky, but your coworkers are not
 
My co-workers are all 60+ working in cobol who don't know javascript.

And ternary operators should be common knowledge -_-
 
Don't rely on common knowledge
 
@KendallFrey Seriously? You hate ternary operators that bad..?
 
It took me about 10 seconds to read your code. If it had been an if statement, it would have been 2 seconds
 
I bet if you used them more it would take less than 10 seconds to read them
 
6:33 PM
I've never had trouble with ternary.
 
Most devs can understand a ternary operator pretty easily I would imagine
 
ternary operators are great, but often there's something even greater
 
user1596138
Oops don't make fun of the slow kid
 
I understand perfectly how a ternary operator works
What you're doing is not best described by a ternary operator
It's not about "Is it readable?" it's about "Can it be more readable?"
 
It actually took me a while to understand ternary operators
 
user1596138
6:37 PM
I prefer them for smallish simple stuff
 
user1596138
But that doesn't mean I use them..
 
they're mostly useful for code golf and obfuscation
 
user1596138
They honestly aren't hard to read.
 
lol
Obfuscation
 
No, but they are hard to read compared with a logical section of code
 
user1596138
6:39 PM
That'd be like obfuscating your junk with saran wrap
2
 
LOL
 
lol
 
q = (q === 'right' ? 'left' : q);

if (q === 'right')
{
    q = left;
}
 
Anyway I just noticed that if you use ng-repeat with ng-include, the included ng-template doesn't give you the data you're looping through with ng-repeat
 
The second one (IMO) is much more obvious
code should be obvious
 
6:40 PM
!!balls.min
 
Mar 4 at 18:05, by rlemon
@Jhawins I minified my balls to leave more room for the shaft.
 
user1596138
@KendallFrey Usually there would need to be an else too.
 
user1596138
This is the useful case
 
@Jhawins I didn't say that's the only way to obfuscate something
 
@Jhawins Nah not in this example
 
6:40 PM
@Jhawins If there is an else, a ternary makes much more sense
 
user1596138
@Martin Which is why in this example it's stupid
 
user1596138
Oh. Cool we're all on the same page
 
lol
 
@Martin Yeah, it creates its own scope
 
user1596138
6:41 PM
Yeah that's just lame if you don't have an else. That'd be like using an else statement that does nothing
 
user1596138
@KendallFrey Huh
 
exactly
 
user1596138
if (q === 'right') {
  q = 'left';
} else {
// for fun
}
 
@Jonathan 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.
 
user1596138
Yeah use that
 
user1596138
6:42 PM
That's what you're doing. That's what it looks like to me
 
Also, if you doubt my ability to obfuscate code: gist.github.com/kendfrey/5461964
 
user1596138
Like, oh look that's so pointless
 
There's an else because if q is 'left', it needs to return 'right'
 
else {
    q = q
}
 
just.. putting that out there
 
6:43 PM
^^
 
@SomeKittensUx2666 It does? When I use it with ng-template or when I use ng-repeat?
 
user1596138
@Cereal You're not using code that does that.
 
@Cereal What? What are you talking about? Did you get that backwards?
 
function something(eye) {
    opposite_eye = eye == 'left' ? 'right' : 'left'
}
uhh
 
that's a different case entirely
 
6:44 PM
My original snippet shouldn't have q
oops
 
a ternary is fairly appropriate there
 
user1596138
You want something like a lookup table with xor-equals if you want to be really badass
 
^ What?
 
best use of xor: a ^= b ^= a ^= b;
 
What is xor
 
6:46 PM
exclusive or
 
!!wiki xor
 
Returns true if one or the other is true, but not both
 
Life tip: It's MUCH easier to point out something wrong than to fix it.
 
Woah cool
 
6:48 PM
@SomeKittensUx2666 ...phrasing?
 
user1596138
var leftRight = {0:'left', 1:'right'};
q = leftRight[true^q]; // q = true|false
 
@rlemon Probably shouldn't have been unoneboxed.
 
hrmm
 
mmrh
 
I'll fix that
 
6:48 PM
@RUJordan me venting frustrations.
 
mhmr
 
@SomeKittensUx2666 :there there: Wheatly?
 
@RUJordan yup
!!wheatly
 
@Jhawins I feel like ['right', 'left'][true^eye] might confuse people a bit
but that's really clever
 
6:50 PM
no, that's not clever, that's stupid
 
clever is bad
 
that's what kids who just discovered xor do
 
I never said I'd use it -_-
 
true^eye what about !eye?
 
6:50 PM
you said it's clever. No, it's not.
 
user1596138
@Cereal The whole point is to be more 1337
 
user1596138
lmao
 
user1596138
Yeah if you don't know about XOR go ahead and look it up now. Comes in handy eventually.
 
@FlorianMargaine That's a matter of opinion
or would you prefer is use the term 'neat'
 
user1596138
@kendallFrey ^= is good because it actually flops the value instead of just returning the opposite value
 
6:51 PM
whut
What do you mean
'flops'?
 
user1596138
Changes from 0 -> 1 or true -> false
 
user1596138
'flops'
 
user1596138
Flips.
 
user1596138
Changes
 
user1596138
wutevar
 
6:53 PM
I have no idea why you called it 'good'
what are you comparing it to?
 
@JanDvorak Despite many attempts, I still don't understand ruby's "flip flop" operator or whatever it was called. Got anything decent to explain it?
 
user1596138
@KendallFrey What would you like to compare it to?
 
You're not making sense
> it actually flops the value instead of just returning the opposite value
 
user1596138
!!> !true
 
@Jhawins false
 
6:55 PM
Are those random words, or were you referring to something?
Are you referring to ^= vs ^?
 
@Zirak Isn't it something like... true when the left hand condition is met until the right hand condition is met?
 
@SomeKittensUx2666 why the heck hasn't this man been fired yet?
 
user1596138
...
 
user1596138
!!afk work
 
@RUJordan nepotism
 
6:56 PM
He seems like a man that makes me look like a genius
And I'm borederline retarded man
 
borederline huh
 
@RUJordan He's a cofounder
 
@KendallFrey it sadly fits the statement :(
@SomeKittensUx2666 oh god.. burn him with fire D:
 
burn him without fire
just try it
 
user1596138
I'm back
 
6:58 PM
Lye gives a nice chemical burn. I agree.
 
@RUJordan It won't be long.
 
@Jhawins Nice to meet you, Back. I'm Kendall.
 
@KendallFrey Jhawins is afk: work
 
@Cereal That sounds like an and
 
user1596138
Gotcha
 
6:59 PM
until a and b # forgot this was ruby for a second
 
user1596138
That was so worth it lmao
 
@SomeKittensUx2666 find out his sudo password and sudo rm -rf / his computer
 
Glad someone finds humour in it, because I'm just bored
 
user1596138
// me pretending I did that funny thing on purpose
 
That should save you some time
 
6:59 PM
@RUJordan you forgot the slash
 

« first day (1334 days earlier)      last day (3600 days later) »