« first day (1908 days earlier)      last day (3044 days later) » 

7:00 PM
you need to process a lot more on the server
 
@Abhishrek just don't jerk it around people
@ajaxGuru but you can cache it more effectively
 
@ssube lol
 
homepage takes 1.35s to load for me
 
@rlemon that's pretty good
 
7:00 PM
it can process less
 
yup
 
sup y'all
 
!!youtube russell peters beat your children
 
yeah, hard refresh + cache kill is < 1.5s
@ajaxGuru less of what?
 
7:02 PM
@ssube HA
empty cache and hard reload - 955ms
:D
 
using ajax is a lot less than that
 
my wifi is bad here :(
need to crawl under the desk and plug in one day
@ajaxGuru less of what?
 
@ajaxGuru ajax is a technique, facilitated with xhr, which is just a regular old http request.
 
less processing than loading the whole thing into cache
 
there is nothing magical or inherently better for server side
 
7:03 PM
true, and false
 
Is it a good idea to create a function where you add all your eventlisterens ? and then use window.onload ?
 
SO has data that is very similar for most users. It's a great scenario for heavy server-side caching.
 
you need to load less in when running around ajax
 
Same way Twitter tried SPA/AJAX and it was slower for them, trying to force things to load dynamically will probably be slower for SO.
 
what?
 
7:04 PM
@Poteito Why would it matter?
 
@Poteito No
 
If it's in a function on its own, or just in window.onload = () => { /* here */ }?
 
@ajaxGuru No
@ajaxGuru No
 
the normal httpreq is a lot of data, but it can be reduced
 
controller code could not read json
appRoot.controller('AccountsController', function($scope, $http){
    $http.get('result.json').
            then(function(data) {$scope.rows = data;} , function(data) {console.log("My error: " + data)} );  ...}
 
7:05 PM
@ajaxGuru how is ajax not a normal http request?
 
what if you have json disabled
 
@ajaxGuru you can't disable json
 
lol
 
you only need to load the data you want
 
but what about the style?
the page frame, the scripts?
 
7:06 PM
@ajaxGuru Creating an HTTP request is, in 99.999% of the cases, more expensive than doing anything purely client-side.
 
css works just fine
 
crl
hmm click event still fires even if I wait 30seconds between the mousedown and mouseup
 
@crl yep
 
@vaultah are you talking about larger sites
 
@ajaxGuru No
 
crl
7:07 PM
I expected it to be triggered on short delay only, Til
 
@ajaxGuru Why.. wouldn't it?
 
wouldn't what?
 
CSS is also data ...
 
Lol this conversation
 
css is a fad
 
7:08 PM
css is run on all
 
sometimes CSS works, and sometimes CSS doesn't work, and other times CSS does work, and occasionally CSS doesn't do the work, but then CSS does do work that it does, except CSS doesn't not do the work it can't do
3
 
@rlemon I couldnt find any article about the difference between splitText and split. If I use string.split(/\s+/) its the same thing
 
REKT
 
I think you are biased towards SPAs because you (think you) are an ajax guru.
 
actually string.split(/\b\s+(?!$)/)
 
7:09 PM
rekt?
 
What is @ajaxGuru claiming?
 
@ajaxGuru REKT apps are replacing SPAs
 
That SO would be much faster as an SPA
REKT is the future bro
 
would convert string into tokens, removing any empty items
 
@ajaxGuru It absolutely would not be.
 
7:09 PM
!!urban rekt
 
@ajaxGuru Rekt When someone gets completely destroyed.
 
Refresh-Export-Convert-Table
 
@ajaxGuru "wrecked"
 
@Demorus split is non standard and a webkit only thing. firefox doesn't even have it.
 
7:10 PM
do you mean react?
 
you pull in the data from the server which exported it and convert it to a table
 
@ajaxGuru They're trolling you, ignore them.
 
No we're joking
 
that's why the web was so fast in the 90s: everything was a table
@MadaraUchiha other way round
 
@ajaxGuru Stack Overflow would absolutely not be faster as an SPA.
 
7:10 PM
domainname/profile
what is the best way to achieve that
 
@rlemon ya thats my very old account
 
very old account?
it is newer than this one
 
Generally speaking, SPAs are not necessarily faster than MPAs.
 
and you are active on it
 
it would too as you only need to load what the user requests
 
7:11 PM
why would you have two active accounts unless ??
 
@rlemon weird. hang on. Need to relog into my asperger account
 
it's a temporal pair of sock puppets
 
@rlemon dont know
 
@ajaxGuru You already load only what you need.
The rest is cached.
 
i got rekt'ed by ssube's comment :/
 
7:11 PM
@ajaxGuru but you can do that with multiple pages too
 
It happened that I forgot my password from this account
 
you evil green bastard
 
at present I am using node js for the back end and I handle http requests directly via app.get('/requestname'
 
but today my brother helped me remember what it was
 
All of the scripts, all of the styles, you don't download everything each time you navigate.
 
7:12 PM
is there any way to handle profiles other than that
 
but does the cached stuff come down the pipeline?
 
@ajaxGuru No
 
How do I close accounts?
 
where is it cached?
 
I dont need this one
 
7:12 PM
@ajaxGuru up the pipe
 
@ajaxGuru On the user's computer.
 
Both browser and server can cache css/scripts/etc effectively...
 
it's cached locally in the browser
 
The client saves it.
 
the internet is a series of pipes
 
7:13 PM
check how the HTTP requests got resolved.
 
That's why I love the internet !
 
@ssube plumbers love it
 
hut swag really
 
7:13 PM
8/10
 
the scarf or
 
yea
 
should i read this: loadstorm.com/2012/02/…
 
Probably
 
try to read newer articles as well
 
7:14 PM
@ajaxGuru Please note that it's an article from 2012.
 
4 years is a long time
 
You can read it, but take everything with a grain of salt because it might be outdated.
 
@rlemon Ugh. I hate how Years get further back the longer I'm alive
 
All javascript articles are outdated as soon as they come out
 
what should i read up on then?
 
7:15 PM
Back
 
@ajaxGuru woodworking
 
IF you don't care about what's actually happening: siteground.com/kb/how-to-leverage-browser-caching
 
solid skill to know
 
@ajaxGuru Cache is fairly straightforward.
 
@rlemon LOL
 
7:15 PM
Woodworking can be a lot more complex than people think
 
There are about 3-4 HTTP headers that affect client-side cache.
 
Ok so textsplit is standard and split is nonstandard.
 
It's a lot of fun, though
 
i know it is in some stuff
 
That's pretty much all there is to it.
 
7:16 PM
just found the ultimate reason to code (and do a lot of other things): so, 99.92% of the global population apparently doesn't code. That means that 99.92% of the deaths in this world happen to non-devs :D
 
I didnt read this anywhere but good to know
 
I used to do woodworking: (gore) a1-images.myspacecdn.com/images01/7/…
 
@towc That's like the reason why blondes never have more than 3 kids, because they heard that every fourth child is Chinese.
 
@rlemon did you see the new star wars?
 
All I do is program, every day, and I'm losing my capacity to feel human emotion
 
7:17 PM
no
@Martin last weekish my table saw kicked back a piece of wood into my stomach
 
man you should already!
 
hit hard enough to break the skin under two layers of clothing
 
Oh shit
 
sucked.
 
Yeah I can imagine
 
7:18 PM
worst part was it destroyed the wood
had to recut the damn thing
 
That was my finger after someone turned on the jointer while I was taking the safety plate on (I was in high school)
 
@towc Did you know that 100% of the dev population suffers death?
 
I lost 3 fingers' fingernails
 
ouch
 
Yeah it was pretty bad
 
7:18 PM
could have been worse, could have lose 3 fingers
 
Somehow it didn't hurt, and my fingers are intact
 
so there is always that
 
Yeah big time
I'm grateful
Ok yo! I came with a question and got distracted by this marvelous conversation
 
@AwalGarg Incidentally, all of the reported devs who died were known to consume dihydrogen monoxide no more than a week before dying.
 
42
 
7:19 PM
why is it so bad to just innerhtml sections of the page, and not have the presentation layer cache the site?
 
@AwalGarg oh gosh, that's horrible D:
 
well I accidently cut my achilles tendon once with a saw
 
keh ...
being not careful ?
 
indeed
I stepped on it and well
 
7:20 PM
when i'm using the axe, i'm always careful. Didn't got accidents so far
 
JSON.stringify removes any properties that are functions (e.g. {'foo':'foo','bar':function(){}} becomes "{"foo":"foo"}" - is there a way I can "stringify" my objects and then re-parse them later while keeping my functions intact?
 
@MadaraUchiha destroy this world please, ASAP.
 
@Cereal I thought he died
 
json doesn't understand functions
 
@ajaxGuru 1. XSS
 
7:21 PM
and isn't going too
 
On a scale of 1 to insensitive prick, how bad i dick nugger right now
 
2. Reflows EVERYWHERE
 
@Cereal 11
 
@rlemon I don't care about it being JSON technically - I just want to serialize my objects to/from strings and keep the functions
 
@MadaraUchiha curl defeats xss
 
7:22 PM
why?
@Martin
 
@ajaxGuru Wait what?
 
@ajaxGuru no ...
 
@MadaraUchiha curl is the bridge
 
curl - grab html from x, and use it on my site
 
@Martin you can't do that... well, you kind of can, but no...
you shouldn't do that
 
7:23 PM
@ajaxGuru And if the HTML from x includes <script>steallAllTheCookiesAndSendThemBackToX();</script>?
 
A really annoying and particular use case. I have a very strict environment here. I have a Chartjs object whose defaults.global I want to be able to change with a GUI. I'm using github.com/jdorn/json-editor for the editing. Thing is that the editor is in an iframe that I gotta pass data to/from as a string (can't be an object from the Javascript directly)
 
Guys check out the avatar of the only contributor to this repo: github.com/ajax-proofs/proofs from the profile of @ajaxGuru. Anyone gets reminded of code penis better?
 
your server side can strip stuff out
 
then don't say "curl defeats XSS" because it does nothing with the content
 
@Martin Don't pass the functions, call the functions that return more json, and then just pass all of the json into your iframe, or whatever.
 
7:24 PM
 
@AwalGarg it was transparent already.
 
@KendallFrey @FlorianMargaine bcrypt. Better?
 
@SterlingArcher why is it ugly?
but also, great job!
 
@ajaxGuru Why would I want to steal content from other sites anyway?
 
@SterlingArcher that really is
 
7:25 PM
@ndugger he modelled it after ur mum
 
@ndugger Maybe I'm not explaining it well.. I suck at that. But the functions are inside of the objects that need to be passed
 
@SterlingArcher : haha @ "sourceundead has risen from the grave on port 8080"
 
@ndugger it's ugly because I didn't use blackbeard
 
She isn't black, you racist
 
@Martin No, you're explaining it right, you're just thinking about the issue wrong.
 
!!snap
 
Probably
 
@rlemon That didn't make much sense. Maybe you meant: slap
 
7:26 PM
!!slap ndugger
 
@rlemon slaps @ndugger around a bit with a large trout!
 
!!slap
 
!!no
 
@SterlingArcher slaps 0 around a bit with a large trout!
 
...
 
7:26 PM
Sandbox.
 
The other thing I thought about was to remove the functions from the object before passing to the editor, then re-add once the editor is done
 
spilled my glass on that :/
 
!!slap dat ass
 
@ndugger slaps @dat ass around a bit with a large trout!
 
It took me longer than I'm proud to admit to figure out that to hash a password it doesn't need to be async. hashSync is what I wanted
derp
 
7:27 PM
@SterlingArcher Where's your salt, and how long does that take to run
 
do it async, and use async/await
 
let password = bcrypt.hashSync(pass, 8);
 
@SterlingArcher Ew, sync
 
const password = await bcrypt.hash(pass, 8)
 
Also, 8 is quite low as far as costs go
 
7:28 PM
I like my password hashing to take about a second per hash
 
@ndugger the thing is that my functions don't return json
 
@MadaraUchiha Yeah, I thought so
 
@Martin Then make them return json. But I'm being really real here when I say, do not store functions in strings. Don't.
 
@SterlingArcher What @ndugger only with a cost of 11-12
I like it when password generation takes about 1/10th of a second
 
Fair. I didn't like the idea much myself anyway. But I can't make my functions return JSON...
 
7:29 PM
I don't think nodejs supports await
 
It's a good balance between "user can't tell the difference" and "takes a long time to brute"
 
I'll try to put a quick gist together
 
@SterlingArcher Babel?
 
@SterlingArcher babel
 
not using babel
 
7:29 PM
babel-node
BABEL-NODE!
 
@SterlingArcher Use babel :P
 
good lord, just use babel
 
just effing use it
 
USE IT
 
i hate you all
 
7:30 PM
USE ME
 
@SterlingArcher Also, even if you don't, and you use Bluebird
 
<3
 
er IT
 
Fuck, meeting. I'll be back
 
You can use
 
7:30 PM
why do they call SPW the slide up and down websites?
 
stick to the sync version, your cost level makes it unnecessary to switch to async anyways
 
@ajaxGuru lol
 
@AwalGarg That's a terrible excuse
 
@SterlingArcher babeljs.io/docs/usage/cli/#babel-node for dev, then just babel it for the dist
 
@ndugger what?
 
7:30 PM
He should be using a higher cost
 
const fn = Promise.coroutine(function*() {
  // ....
  const password = yield bcrypt.hashAsync(password, 11);
  // ....
})
Which is exactly the same result as
 
I'll always recommend gulp-babel, because gulp is a magnificent tool.
 
I use both
depending on the need ofc
 
async function fn() {
  // ...
  const password = await bcrypt.hashAsync(password, 11);
  // ...
}
 
So why should my password hashing be async?
What's wrong with sync
 
7:32 PM
In fact, you can even tell babel to transpile the latter into the former.
@SterlingArcher You're blocking the event loop
 
webpage will hang a while if you do it sync and thus blocking the event loop
 
Never use sync. The only time I use sync is for reading config files before the server even starts, and even then, I feel dirty about it.
 
sync, in a single threaded environment, affects far more than the one request you are handling.
 
Say you set your cost parameter to an extreme case of 10 seconds to calculate hash
Every time someone tries to calculate a hash, your server is unresponsive for 10 seconds
 
gulp and grunt, why are js build tools so dirty
 
7:33 PM
oh
 
!!oh
 
lol fuck you
 
@SterlingArcher Sync is OK in the first tick
In fact, require() is sync
 
that'd be a pretty easy way to make the server unresponsive for a long time
 
7:33 PM
because it's logical
 
But once you're past "bootstrapping", using sync is a great way of DDoSing yourself.
 
@KevinB Another way: pre-release Oculus Rift
 
you don't want to start with missing plugins
 
-1
Q: angularjs controller could not read json file

overexchangeIn the below code, /* app.js*/ var app = angular.module('Sample', []); /* Controller.js*/ app.controller('Controller', function($scope, $http){ $http.get('result.json'). then(function(data) {$scope.tabular_data = data;} , function(data) {console.log("My error: " + data)} ); ...

 
@MadaraUchiha You can't DDoS yourself
Did you mean DoS
 
7:34 PM
let password = bcrypt.hash(pass, 8, (err, string) => string);
So this should effectively return a promise, then?
 
@KendallFrey grunt && grunt && grunt && gulp && babel && sleep && clone
@SterlingArcher no
 
you can DDoS yourself kendal. Just use a 2nd pc to attack above your pc attacking himself.
 
@KendallFrey Sure you can DDoS yourself.
 
@KarelG but is that second PC really DDoSing itself?
 
rlemon@rlemon-laptop:~$ touch /this
touch: cannot touch ‘/this’: Permission denied
 
7:36 PM
oh, apparently I have two more positions open here if anyone is interested
 
ddos yourself means 1 process against another
 
should I redo my "come work for me" spiel, or has it been too soon?
 
By serving something that will make every user block your server
You get a distributed denial of service
 
@KarelG That certainly isn't a DDoS
 
@ajaxGuru no. The first D stands for Distributed
it is
2 pc's attacking 1 pc while one of them is attacking himself
 
crl
7:36 PM
DDrop the bass
 
DDoS implies a botnet
 
@Codeman No.
 
DoS can be executed by a single machine
 
i ddosed the school network when in college
 
DDoS implies an attack from a lot of machines at once.
 
7:37 PM
^--
 
if you have a server farm many servers against each other
 
Which is exactly the case when your server blocks on a certain URL that everyone use.
 
@MadaraUchiha no - DDoS is DEFINED as an attack from a lot of machines at once. It IMPLIES a botnet.
 
@ajaxGuru DDoS isn't "against each other"
 
@Codeman Again, not necessarily.
 
crl
7:37 PM
!!s/to/can't to/ 27962468
 
@crl rlemon@rlemon-laptop:~$ touch touch this
touch: cannot touch ‘/this’: Permission denied [\(source\)](http://chat.stackoverflow.com/transcript/message/27962468#27962468)
 
@ajaxGuru DDoS stands for Distributed Denial of Service
 
or just sending lots of TCP requests from lots of machines to a single machine, and not sending the FIN packet ever
 
you can attack a server with 3 persons using their laptop. there is no botnet involved
 
@Codeman no, you can accidentally be DDoSed
 
7:38 PM
function createAccount(user,pass,email) {
	let password = bcrypt.hash(pass, 8, (err, string) => string);
	let check = `SELECT COUNT(username) AS count FROM players WHERE username=${mysql.escape(user)}`;
		let sql = `INSERT INTO players (username,email,password) VALUES (${mysql.escape(user)}, ${mysql.escape(email)}, ${mysql.escape(password)})`;
		db.query(sql).then(data => {
			let moarSQL = `INSERT INTO player_data (id,x,y,hp,maxhp) VALUES (${mysql.escape(data.insertId)}, 1, 1, 100, 100)`;
			db.query(moarSQL);
 
It's when a lot of computers overwhelm a server to the point it can't answer to legitimate requests.
 
@SterlingArcher get in the habit of using "const"
 
there's no requirement for a botnet, it just takes a botnet's worth of traffic on a well-designed site
 
take 20 servers and send them against the gateway, then send the gateway at the 20 servers
 
@SterlingArcher No.
 
7:38 PM
you can easily spend too much time doing one thing (hashing) and ddos yourself by accident
 
Here's what I'm trying to do. I just want to hash that password, and use it in my query
 
@crl rlemon@rlemon-lapcan't top:~$ touch /this
touch: cannot touch ‘/this’: Permission denied [\(source\)](http://chat.stackoverflow.com/transcript/message/27962468#27962468)
 
let password = bcrypt.hash(pass, 8, (err, string) => string);
 
incoming traffic remains constant, work increases, things break
 
That will not work, you can't return shit from a callback.
 
7:38 PM
ddos yourself
 
I'm not saying all DDoS' are botnets, but most of the intentional ones are
 
I know that's wrong, I'm trying to figure out how to do it right
 
@Codeman yes, but I'd argue most DDoSes aren't intentional
 
then how does a ping work?
 
performance is tricky and easy to break
 
7:39 PM
@ssube reasonable assertion, as well
 
Do I have to wrap my entire function in the damn callback?
 
@SterlingArcher No, just use promises.
 
@ajaxGuru a DoS attack isn't done with ping anymore.
 
especially if you're near capacity already, it's super easy to lose 5% on a major function and bring your site down
 
Also, never use template strings with variables for SQL queries.
 
7:40 PM
for testing it isn't?
 
When you have parameters to the query, use a parameterised query.
 
ok, i'll get to that
 
(AKA a prepare statement)
Otherwise, you're just opening yourself to SQL injections
 
So how do I promise the hash?
bluebird is so confusing
(to me)
 
7:41 PM
Promise.promisifyAll(bcrypt);
Done
Then you have bcrypt.hashAsync
 
Shoot a random integer between 5000 and 15000
 
but hashAsync is already a function
 
@SterlingArcher Eh?
What package are you using?
 
i found this post-condition remarkable
post: result->forAll(elem | self->includes(elem))
post: self ->forAll(elem | result->includes(elem))
 
@MadaraUchiha RangeError
 
hash is already asynchronous
Do do I still need to promise it and make it hashAsync?
 
@SterlingArcher Right, but it's callback based.
 
promisifyAll takes an object, and augments that object with a Promise ready function, for each callback based one.
 
7:43 PM
@AwalGarg 5000
 
so bcrypt.hash() is the callback version, and bcrypt.hashAsync() will be the one that returns promises.
!!> ~~(Math.random() * 10000) + 5000
 
@MadaraUchiha 6548
 
@AwalGarg ^
 
And I just do something like let password = bcrypt.hashAsync(pass, 8).then(password => password);?
 
@SterlingArcher No
 
7:44 PM
I need to return the promise, don't i
 
@SterlingArcher Not necessarily, in your case it would be
 
Yes that's smart, flag the moderator
let password = return bcrypt.hashAsync(pass, 8);
password.then(...)?
 
bcrypt.hashAsync(pass, 11)
	.then(password => {
  		// use here
	});
Or that ^ yeah
 
But then I can only use password inside then, no?
 
So, it's exactly like a callback but longer
 
7:46 PM
@SterlingArcher Correct.
@copy Yes, but promises have distinct advantages over promises
For once, they're throw safe, which can't be said about callbacks...
 
So I will need to effectively wrap my query in the resolved promise
 
@SterlingArcher Yeah
Note that you shouldn't nest .then()s
When you return a Promise from inside a .then(), you continue the chain
 
use async/await and we'll love you
if you don't use babel, we'll shun you
jorjor binks
 
@ndugger This
 
bcrypt.hashAsync()
	.then(password => db.queryAsync(/* ... */)) // returned a promise!
	.then(resultOfQuery => ...
 
7:48 PM
bcrypt.hashAsync(pass, 11).then(password => {
	let sql = `INSERT INTO players (username,email,password) VALUES (${mysql.escape(user)}, ${mysql.escape(email)}, ${mysql.escape(password)})`;
	db.query(sql).then(data => {
		let moarSQL = `INSERT INTO player_data (id,x,y,hp,maxhp) VALUES (${mysql.escape(data.insertId)}, 1, 1, 100, 100)`;
		db.query(moarSQL);
	});
	return {
		"msg":"Your account was created! You will be redirected to the login page in 2 seconds.",
		"flag":false,
		"title":": Account Created"
Not too bad I guess.. but it still feels like callback hell
 
@copy @ndugger Let him understand promises first, before jumping to async/await...
 
that's fair
 
@SterlingArcher again, no nesting thens!
 
I only just fully understood async/await, and I knew promises for a good while before
 
return bcrypt.hashAsync(pass, 11)
	.then(password => db.query(`INSERT bla bla bla`))
	.then(data => db.query(`INSERT MORE bla bla bla`))
	.then(moarData => /* whatever */)
 
7:50 PM
The user has been kicked and cannot return for 30 minutes. Moderators have been informed.
You got it buddy
@MadaraUchiha OHHHHHH why is it bad to nest thens, then?
 
What a strange person
 
ofc he's a strange person. It's a tree
 
@SterlingArcher Because you're recreating callback hell
Instead of using the monoid properties of the .then() allowing them to stack nicely.
Also makes error handling more difficult.
 
With my example, you can tag .catch() to the end to catch any errors during the entire process.
 
7:52 PM
bcrypt.hashAsync(pass, 11).then(password => {
	let sql = `INSERT INTO players (username,email,password) VALUES (${mysql.escape(user)}, ${mysql.escape(email)}, ${mysql.escape(password)})`;
	return db.query(sql);
}).then(data => {
	let moarSQL = `INSERT INTO player_data (id,x,y,hp,maxhp) VALUES (${mysql.escape(data.insertId)}, 1, 1, 100, 100)`;
	db.query(moarSQL);
});
return {
	"msg":"Your account was created! You will be redirected to the login page in 2 seconds.",
	"flag":false,
	"title":": Account Created"
 
With a nested .then(), you can't.
 
So like that, but with prepared statements
 
@SterlingArcher Almost
You'll return before any of the actions are actually done
so you're lying to your users
 
why not return the inner query and return the object on a new then
then return the entire thing
 
Ah shit
 
7:53 PM
Since createAccount is an asynchronous function
It makes sense that it returns a promise itself!
And then the caller can use
 
return bcrypt......
.then(data => {
return query both times
}).then(()=>{
  return messages;
})
 
createAccount(/*...*/)
	.then(result => res.json(result))
	.catch(err => res.json(parseError(err)));
 
HAHAHAHAHHA
 
It worked!
@MadaraUchiha @rlemon thank you much :D
 
7:57 PM
 
@rlemon taskbah*
 
@SterlingArcher Now, say you didn't have bluebird and promisify
Promisifying a callback based function is still fairly easy:
 

« first day (1908 days earlier)      last day (3044 days later) »