« first day (1281 days earlier)      last day (3666 days later) » 

2:06 PM
back
@OneKitten you mean that I should add something?
 
@t1wc: well your code isn't really crypto stuff
I don't think it matters that much
but what is this seed value
 
@OneKitten just a number
@OneKitten it matters becouse if I'm getting a random item from an array for example the middle items have a really low chance of getting summoned, meaning that it's not really random
 
ah, that would make sense
BTW what's lacking from Math.random that you'd like changed
 
0
Q: Seed-based world generation using sin

t1wcI'm tried to make some world generation mechanism using Math.random() whenever I needed something random, but then decided that I wanted it seed-based, so, given a seed, I changed all of the Math.random() to Math.sin(seed++)/2+0.5, hoping it would do the same thing, but would be the same if the s...

@OneKitten the fact that I want it to generate randomly, but from a seed
 
@t1wc: I just tested it, definitely not even
 
2:13 PM
@OneKitten yeah
 
var a = [0,0,0,0,0,0,0,0,0,0];
for (var i = 0; i < 99999; ++i) ++a[Math.floor((Math.sin(i)/2+0.5)*10)];
result: [20479, 9034, 7387, 6687, 6412, 6412, 6688, 7385, 9035, 20480]
 
!!>var a = [0,0,0,0,0,0,0,0,0,0]; for (var i = 0; i < 99999; ++i) ++a[Math.floor(Math.random()*10)]; console.log(a)
 
@t1wc That didn't make much sense. Use the !!/help command to learn more.
 
@t1wc: one line
 
@t1wc "undefined" Logged: [10058,10094,10106,9908,9860,10107,10101,9829,10032,9904]
 
2:15 PM
and this one is even
 
!!>var a = Array(101).join('0').split(''); for (var i = 0; i < 99999; ++i) ++a[Math.floor((Math.sin(i)/2+0.5)*100)]; a
 
@OneKitten That didn't make much sense. Use the !!/help command to learn more.
@OneKitten [6371,2664,2052,1732,1536,1398,1292,1208,1140,1086,1046,993,968,923,908,881,858‌​,836,817,804,786,784,759,747,748,724,726,711,702,700,695,679,685,669,674,669,652,‌​662,660,642,652,649,635,645,643,642,632,641,640,633,634,639,641,629,643,645,645,6‌​34,649,653,645,658,661,653,669,673,667,685,680,697,700,701,712,724,728,747,745,75‌​7,784,787,802,819,838,857,882,907,924,966,991,1049,1085,1142,1208,1291,1398,15 (snip)
 
anyway, any idea for a fix?
 
var random = +('.'+window.crypto.getRandomValues(new Uint32Array(1))[0]);
 
I know cos is the inverse
so if you add Math.cos(i)/2+0.5 does that make it even?
 
2:19 PM
@rlemon: you'd get an inverse thing I'd guess
 
!!>var a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; for (var i = 0; i < 99999; ++i) ++a[Math.floor((Math.sin(i)/2+0.5)+(Math.cos(i)/2+0.5))*10]; a
 
@t1wc [49998,50001,0,0,0,0,0,0]
 
uhh...
 
@t1wc [49998,0,0,0,0,0,0,0,0,0,"NaN"]
 
!!>crypto.getRandomValues(new Uint32Array(6))
 
2:20 PM
@adeneo "ReferenceError: window is not defined"
@adeneo "ReferenceError: crypto is not defined"
 
Actually, it's the same, my brain's dead
!!> var a = Array(101).join('0').split('');for (var i = 0; i < 99999; ++i) ++a[Math.ceil((Math.cos(i)/2+0.5)*100)-1];a
 
@OneKitten [6378,2650,2052,1739,1541,1399,1288,1211,1142,1085,1036,1004,954,936,908,875,85‌​2,840,827,803,787,771,758,758,735,738,717,711,706,698,691,690,674,679,662,669,665‌​,650,658,655,641,649,647,645,631,644,642,638,630,639,640,630,639,642,642,632,645,‌​647,649,641,655,659,649,665,669,661,680,673,692,689,697,708,711,717,738,735,759,7‌​58,772,787,802,828,840,851,876,907,935,955,1004,1036,1085,1141,1212,1289,1398, (snip)
 
@OneKitten huh?
 
@rlemon: I was showing the distribution of cosine function for @t1wc
He thought it would be a good PRNG
 
2:30 PM
@BenjaminGruenbaum just... why?
 
@Mosho: doge
 
@OneKitten apparently if I take it from the second digit I get a truly random number
it's the irrationalness the randomness
 
"truly random" isn't going to happen this way
 
(((Math.sin(seed++)/2+0.5)*10000)%10000)/10000
 
you want truly random, use this random.org/clients/http
 
2:36 PM
@rlemon truly seed-based random
 
56
Q: Seedable JavaScript random number generator

scunliffeThe JavaScript Math.random() function returns a random value between 0 and 1, automatically seeded based on the current time (similar to Java I believe). However, I don't think there's any way to set you own seed for it. How can I make a random number generator that I can provide my own seed va...

 
Why isn't this working... Loading all elements of a class in an array though jquery's toArray() and setting their innerHTML...
 
:(
so much wrong with that
!!resources
 

Javascript Resources.

Sep 4 '12 at 13:36, 2 minutes total – 8 messages, 1 user, 1 star

Bookmarked Sep 4 '12 at 13:40 by rlemon

 
hello guys!
 
2:39 PM
@rlemon seen it
 
@CapricaSix is this meant for me?
 
@laggingreflex yes it is
 
jshint suggests assignment in while-loop in this answer is not a good idea..
 
@laggingreflex: and if you didn't know
 
@laggingreflex I'm @rlemon's slave.
 
2:41 PM
what would be the correct way of writing the same?
 
/*jshint ignore:start*/
 
lol
 
:)
is there a way to iterate over regex pattern without assignment in loop condition?
 
excitement! excitement!
(((Math.sin(seed.value++)/2+0.5)*10000)%100)/100
sends out random
 
posted on April 19, 2014

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); try { var pageTracker = _gat._getTracker("UA-3727700-1"); pageTracker._trackPageview(); } catch(err) {}

 
2:48 PM
@t1wc Use LCG
 
@copy hey!
 
Hi bro
 
helloo
 
@KissKoppány 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.
 
@copy this works really well, also much less complicated than what I've seen before... I guess that LCG is an overcomplication aswell
 
2:51 PM
is anyone there who's good at js? :)
 
Ha
 
LCG is really simple and a very basic concept everybody should have heard about. It's fast and well-tested
The most simple method of random number genration, and likely good enough for your case
 
@copy I'll check it out
@KissKoppány most of us
 
cool :)
can you give me some tips to start js oop?
I have some experiences in c# oop and some in php as well so I know the basics of the oop
but in js it looks quiet different
quite*
 
!!installjavascript
 
2:58 PM
May 20 '13 at 23:53, by copy
<noscript>

<h1><font color="black">If you would like to see the slideshow <br><br>please <a href="http://www.java.com/getjava/"> <i>Install JavaScript</i></a></h1></font>
</noscript>
 
user3071008
 
thanks
but I'm familiar with the syntax and the very basics but I cant understand when and why should I use it?
 
I can make a simple function and call it, why is it better to use fake classes?
 
It's not. OOP is used when it makes life simpler not harder.
 
3:04 PM
finally :D
 
@arslan 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.
 
for example I had a task to solve, it was an address book with php and js (jquery ajax)
and the main task was to complete it without page reloading, so had an index file and js
and I had to complete it with JS OOP, that was the most important
and I was like what? how? why?
couldnt understand what they want
 
They want to encapsulate behavior and state in an object, probably.
 
probably
 
The task itself sounds reasonable for an interview basic question though. Although perhaps a bit long to do both the frontend and the backend.
 
3:08 PM
Everything in javascript is an object, so just write whatever you like and call it "object oriented", works everytime.
2
 
all I did was I created a member object with its properties (name, phone number, email etc) and used it
 
@adeneo * null, undefined, boolean, string and number not included, batteries sold separately, additional charges may apply.
 
user3071008
isn't null an object?
 
No, it is not. typeof null is an historic mistake. They tried to correct it once but it broke the web too bad.
 
user3071008
oh ok
 
3:10 PM
var person = new Person();
person.first_name = $('#first_name').val().trim();
person.last_name = $('#last_name').val().trim();
person.birth_date = $('#birth_date').val().trim();
person.home_phone = $('#home_phone').val().trim();
person.work_phone = $('#work_phone').val().trim();
person.email = $('#email').val().trim();
person.email_again = $('#email_again').val().trim();
person.country = $('#country').val().trim();
person.city = $('#city').val().trim();
person.address = $('#address').val().trim();
this is how I tried
 
That looks horrible. Also, format code you post here (control + k or indent 4 spaces manually)
 
!!format
 
@OneKitten Format your code - hit Ctrl+K before sending and see the faq
 
do you think is it good?
 
No, I do not.
Why do you have all these selectors there, selecting by ID and all?
 
3:12 PM
getting the values of the fields when adding a new member
 
Also, javascript variables are commonly camelCased, but that's not a big issue.
 
Jeez, it's not "object oriented", but
$('form').serialize()
sure comes to mind
 
That doesn't serialize as JSON though :P
 
doesnt?
ah I thought I did it right
 
@adeneo's
You can select the form, get all its named members (by dot access, or reflective foreach, and then just map that to an object.
Although, I'd do something that data binds better, probably.
 
3:13 PM
Nope, but wasn't the goal to write an adressbook with ajax, why would you send JSON
 
I had to do it by using json
sorry I forgot to tell you about this
 
I would just refuse and use application/x-www-form-urlencoded anyway
 
@Gopi 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.
 
what is the best way in jQuery to go to a page and send a value along with it? No address bar stuff, cookies?
 
@adeneo the you would not pass, probably.
@rodling sessionStorage, or drop classical navigation and use the history API.
 
3:17 PM
@BenjaminGruenbaum same as localStorage?
 
@BenjaminGruenbaum - If it was a job interview with such a stupid question, as in

"You can use jQuery, but you have to send data as JSON to PHP, a language that has built in methods up the Yahoo for accepting x-form encoded data"

I would tell them to go f*ck themselves and use x-form encoded data, and they could keep their job.
 
@rodling yes, only it invalidates when the user closes and opens the browser.
@adeneo seriously?
You'd drop an interview on that?
 
@tehAnswer 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.
 
@BenjaminGruenbaum - I probably wouldn't tell them to go f*uck themselves, but I would argue strongly for using x-form data for sending data to the server, but JSON for returned data, anything else doesn't really make sense, it just creates more work, doesn't fallback to the regular form submit, and there's no benefits from using JSON when sending data to the server like that. That isn't to say that I haven't written code that sends JSON to the server, I have, but there has to be a good reason
 
3:24 PM
I don't think it matters all that much, it's just the data exchange format. For example, highly nested objects are a lot more readable in JSON, so sending data to the server when that data is a complex entity might make sense, as it is easier to write tests for and debug.
OTOH, using url encoded is good when you want to still support posting without AJAX.
 
so with this serialize I dont have to care about the input values? sounds good :)
 
@KissKoppány see jsfiddle.net/yR9kW
This is a very trivial version of 'serializing a form as a JS object'
@adeneo also , this is not something I'd refuse to answer because of, I'd voice my opinion but would complete the assignment. Also, wouldn't take the job because of PHP but that's another story.
@KissKoppány trivial as in 'naive'
Also, no jQuery, because using jQuery for that is kind of pointless, but you can add it in if you really want to include an 80KB library for no reason :P
 
thanks for the example
had to use it because of the ajax
they wanted me to use it like that
 
@KissKoppány here, now it's a live form that data binds and fires events when the form is updated and keeps the object updated too jsfiddle.net/Y2PZ5
Although, it needs a slight modification
 
@BenjaminGruenbaum - I guess it depends, I love JSON and use it for almost everyting, and if it was a job interview at Google I would probably tell them it's a great idea and create some elaborate "serializeToJSON" method etc. It's just too often you see people creating lots of inputs with a horrible solution for creating complex JSON structures, and the the same horrible decoding solution in PHP, when all they had to do was wrap it in a form tag and use $.serialize and it works
even without javasrcipt ...
 
3:35 PM
PHP can consume JSON with json_decode though, can't it?
 
Sure, and with json_decode(json, true) you'd even get a handy assoc. array
 
yeah
@BenjaminGruenbaum tbh I dont really understand it
what keydown does there?
 
@KissKoppány now it JSON stringifies properly too :)
 
wow, you just wrote it?
 
@adeneo people do horrible stuff in all languages.
 
3:39 PM
thanks for it
 
@KissKoppány it's kind of ugly, also, it's like... 28 lines of code, it's really not impressive :P
@KissKoppány sure I guess, understand it.
 
I'll analyze it, I have a lot to learn :)
 
It can be a lot better, for example, if I defined getters/setters instead of defining properties directly, I'd get real 2 way data binding
 
@Nitish 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.
 
3:47 PM
@BenjaminGruenbaum - That's neat, with the object and all, I made a version with jQuery without all the fancy bindings -> jsfiddle.net/sPZj2/2
 
cool :)
Here
 
@adeneo nice one
 
@KissKoppány two way data binding, now if you change the object, the form changes too jsfiddle.net/Epzzs
 
hey guys
 
hello
@BenjaminGruenbaum nice :D works well, but can understand it :S can you explain a little please?
 
3:53 PM
Sure. Two way data binding means that not only will my object always reflect the current values of the form, if I change the object, the form will change too.
They are 'bound' to one another.
The "keyup" (or keydown) event listener updates the object properties to the form value. The setter (a JavaScript computed property) sets the form value to the object's value when I assign something to it.
 
I'm working on searches with jQuery and ajax: after update a view, javascript seems to be stopped and jQuery stop listening events
anyone knows why?
 
google 'event delegation'
 
I search lol'd.
 
sounds good, thanks for the explanation
 
3:56 PM
@BenjaminGruenbaum btw, I can show you what I have done if you'd like to see it
 
Unless it's interesting, not really :P
 
not the code but the result :) if you are interested you can check it :)
 
@BenjaminGruenbaum -
Oooh, can i butcher that and make it editable ?

http://jsfiddle.net/Epzzs/1/
 
so
I've barely started, but wondering if people would be interested in this kind of thing: github.com/Ralt/sal
 
@adeneo haha, awesome
 
4:01 PM
@FlorianMargaine Seems like an interesting idea
 
@FlorianMargaine what does it do?
 
@BenjaminGruenbaum authenticate someone on your web app through their gpg keys
 
@adeneo the problem is that it updates which causes the caret to 'jump'
 
no password stored
only the public key
 
Interesting, use case?
 
4:03 PM
some "secure" company or something
not sure about that :D
 
@BenjaminGruenbaum - I noticed, but it was just for fun, writing something that keeps the caret position and resets it is too much work.
 
but it sounded like an interesting improvement over openID
there is also a client, on the computer, to manage public/private keys and eventually the list of websites/usernames
so it's "password-less authentication", although still secure
and painless, if the client is well done
 
@Thomas-B 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.
 
client = some app in the background processes, like an icon in system tray
 
@FlorianMargaine Don't invent cryptographic protocols
 
4:06 PM
What about Persona?
 
@copy I don't
 
@copy logging in with a PGP challenge is hardly inventing a protocol.
 
I'm not going to invent the public/private key crypto
@BenjaminGruenbaum you're trusting an external service with a password. The same as openID
 
Of course you're not inventing the crypto, everybody knows that. Just saying that you should not invent the protocol either
 
takes a while to create a world... but I'm proud of it
 
4:08 PM
Congrats
 
I'm not sure it's a "protocol" when it's only 3 back-and-forth to authenticate someone using a well-known authentication
 
That's a protocol
 
there are also ore veins and other stuff going underground, but now the shadows are covering them
 
@t1wc Seems like certain seeds fail consistently
Try 43
 
4:10 PM
how can you authenticate someone over http using password-less authentication though?
 
SSL client certificates
 
@SomeGuy there needs to be something wrong with the server... on my local machine it worked
 
it exists?
 
Certainly
 
4:10 PM
Of course
 
Probably
 
googling that
 
Diffie-Hellman ?
 
@adeneo No no no no no no no no. No.
 
now they should work... lemme upload some files again
 
4:13 PM
@copy - yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes
 
yay, deleting my repo then
 
yep, working
 
@adeneo If that is the first that comes to your mind, don't do crypto ever
 
@user2191332 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.
 
warggg.
 
4:15 PM
@copy I don't see the problem with doing your own crypto, it's actually a lot of fun.
The problem isn't rolling your own crypto, it's using it in production code.
 
I can't get working the event delegation.
 
btw guys, plantuml is awesome, in case I didn't say it before
 
one of the best seeds I've found is 64237582305723954254623472319
or any number of that magnitude or more
 
@FlorianMargaine I hate UML :P
 
@copy - I don't, but I do use it quite a lot, and don't see the problem with DH ? When is the last time you visited a site with SSL client certificates ?
 
4:17 PM
Because textbook DH is inherently insecure
 
can I discuss with some of you what the logics for a player in this world should be?
 
@BenjaminGruenbaum why?
 
@copy why?
 
@FlorianMargaine rarely justifies the cruft. Flowcharts and charting is a good mind tool, but spending too much time on it is bad, and UML software encourages that.
 
@BenjaminGruenbaum plantuml doesn't encourage that actually
 
4:19 PM
@adeneo You look that up yourself
 
Developing software is long and hard, and sitting around making fancy charts isn't helpful.
 
thinking is hard, using fancy charts is helpful w.r.t that
I'm not saying to go crazy with huge charts, just that simple sequence diagrams or "package" (classes with the big picture) diagrams can be very useful
 
Draw them on paper. Takes a lot less time and often done in groups which is useful.
 
that works when you do it with the group
otherwise nobody understands your piece of paper
maybe it's just me, but my handwriting is horrible.
 
You should do it in a group.
 
4:22 PM
@copy - I have, and everything tells me DH is pretty good when implented the right way.
 
even when you're alone on the project?
 
You don't know all the problems you're solving when you start coding, so building a 'grand scheme' design is usually not beneficial.
 
no of course
 
If you know all the problems you'll face in the process, you don't need charts to begin with.
If you don't, UML does very little to help you.
 
UML helps me communicate how the architecture is done
 
4:23 PM
Hand drawing a small chart is useful, even when alone, but you can't possibly draw out the whole program.
 
I didn't say that
 
@FlorianMargaine The architecture of a piece of software is inherently ever changing. If it's not you either overengineered it or have design problems.
 
I'm specifically saying that it should not be for the grand scheme of things :P
 
Code -> Refactor -> Test.
 
that it's for simple diagrams, or a specific bit of complex code for example
@BenjaminGruenbaum uh?
MVC stays MVC, if you refactor so much that you're changing that, you need to change every technical documentation anyway
(MVC as an example.)
 
4:25 PM
The architecture of your program is never 'MVC', MVC is just an architectural design pattern your can apply to your code base.
Also, you don't change the APIs anyway.
 
@adeneo Well, you need an authenticated channel, so either you run your DH on top of SSL or similiar, which is probably pointless. Or you invent that part, in which case we're back at "don't invent your own crypto protocols"
 
I get UML for illustrating design or architectural patterns (minus the fact you're making people learn 8 types of useless chart for 2 useful ones, and missing out on useful types of charts you don't use), I don't get using UML as part of the development process.
@copy maybe I'm remembering something wrong, but isn't the whole point of DH not having a secure channel to begin with?
Oh wait, nevermind, I get what you mean now.
 
Right, you need authenticated, you get secure
 
@Ben sorry I have to go, but you got my point anyway
 
@copy - I'm not really into security other than what I need to create web stuff, but as far as i know SSL/TLS uses Diffie-Hellman internally
 
4:29 PM
It can be made to work if both sides have public keys. If I remember my professor correctly. But I never got why not just use SSL in practice.
@adeneo which is another point for @copy , pointing out you shouldn't reinvent the wheel?
@FlorianMargaine not really, but ok :P
 
@BenjaminGruenbaum - but why scream "no no no no no no , never use Diffie-Hellman", when it's obviously good enough for SSL ?
 
Because I'm not talking to an OpenSSL developer, am I?
 
@copy - how is that relevant? You're claiming DH is insecure, prove it! I know there are issues, but if I remember correctly those are mostly bad implementations ?
 
DH over an unauthenticated channel is insecure. If you, as a developer, implement DH, you will either 1) implement it on top off SSL or similiar, which is probably pointless or 2) need to reinvent the authentication part, which is not a good idea
 
@Ben (back on mobile) just saying that uml is useful when used on small concepts
To communicate with other developers that might not be there with you right now
 
4:37 PM
@copy - I'm not really that into this security stuff, but it is interesting. I was under the impression DH was created specifially to protect against "man in the middle", network sniffing etc. Why would you need an authenticated channel, isn't that what DH does with the key exchange, making sure the user is who he says he is.
 
(i.e. you in 6 months for example)
A piece of paper works well on the spot, but it's not durable
 
@FlorianMargaine I disagree.
 
@adeneo There's a relatively simple Man in the Middle attack on DH, you should check it out
 
Anyway, plantuml is nice because you write your relations in plain text and it generates uml from that
 
@Swad 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.
 
4:41 PM
@copy - why don't you post a link to it then ?
 
@adeneo It's all over the internet.
 
@BadgerGirl - does that mean I have to actually search for it ?
 
1
Q: How does the man in the middle attack work in Diffie–Hellman?

ChanikagI'm having doubts about the mechanics of a man in the middle attack during a Diffie–Hellman key exchange. I have heard that it can happen during the key agreement communication. But in the presence of CA (Certificate Authority) the receiver can authenticate the sender as he received the sender's ...

There you go
 
@CapricaSix Sure ..
 
@BenjaminGruenbaum back to the addressbook, can I have a question about the content generating?
 
4:49 PM
Ok
 
addressbook.uphero.com/addressbook/js/content.js here you can see how I generate the content but I really dont like this meghotd.. I mean when I just write the whole html code to a js function
is there any better solution I could use?
 
@copy - There you go, but wasn't this solved by Diffie in 1992 ? And I know the solution was to authenticate, just asking ?
 
Right
 
and the Diffie-Hellman key exchange principle is used in just about every secure protocol there is, isn't it ?
 
No
 

« first day (1281 days earlier)      last day (3666 days later) »