« first day (2031 days earlier)      last day (3139 days later) » 
00:00 - 14:0014:00 - 23:00

00:02
yo dudes
hey rlemon I sorted my routing problem :D
(hello, isit me youre looking for)
00:25
quick question, in node is there anyway to pass a variable to a layout that is only called from another jade file
my layout.jade is only called from index.jade like:
    extends layout
    block content
and I want to print a variable in layout.jade
jade? layout?
Damn it
element[0].appendChild(fragment.cloneNode(true));
it doesnt really create a copy because as soon as I do element[1].appendChild(fragment.cloneNode(true)); nothing appends
bummer :(
@rlemon omg thx so much!!!
01:23
does stroke() reset the path or do you have to do that manually?
 
1 hour later…
02:44
anyone know regex
I suck at this
should be easy I think
It isn't JS but the regex should be the following. Should have mentoined that first
"^(\\w+) ((.\\n\\r)+)$"
the weird thing is that the following works for single line
why would the \n\r be in that order
I assumed the order didn't matter
of course the order matters
02:47
what about this
"^(\\w+) ([.\\n\\r]+)$"
shouldn't this work
wait, did you mean... yeah that
still doesn't work for some reason
well I can't help if you don't explain what "doesn't work" means
sorry but it is mathematica
This gives the following output
StringReplace["command -qO- linebreak",
  RegularExpression["^(\\w+) (.+)$"] -> "$1[\"$2\"]"]
what?
02:50
command["-qO- linebreak"]
but if I add a linebreak to the regular expression it deosn't work
it isn't js though
@William please demonstrate
give me a 2nd
^ matches beginning of line $ matches end of line
02:57
Why doesn't this work in JS
/^(\w+) ([.\n]+)$/.test("a bc")
false
but this does
   /^(\w+) (.+)$/.test("a bc")
   true
because I guess you can't use . in []
!!>/^(\w+) (.+)$/.test("a bc")
use some mutually exclusive sets like [\w\W] or something
@Shea true
Is there an inclusive wildcard?
03:01
if you want multiline is the m flag
the flag is optional in chrome
I just tested it
just ping avinash
@William what?
@Shea try it
I don't even know why we have flags
03:03
!!>/^(\w+) ([\w\W\n]+)$/.test("a b\nc")
@William true
yes the flags seem rather stupid
that's because your regex is garbage
What should it be instead. Yes the above is garbarge
Collected
03:04
personally, I wouldn't even use regex for this
then again, idk what you're even trying to do
I'm building a shell type interface
it is a terrible idea
just use "command param param param".split(' ');
doesn't work for multiline
!!>"command param param param".split(' ');
@Shea ["command","param","param","param"]
03:06
then make it work
that was the whole point of this discussion
you do you you don't want newlines?
!!>"command param par\nam param".split(' ');
@Shea ["command","param","par\nam","param"]
@Shea now try "command \"par\nam\" "test\ntest""
wth is that monstrosity?
03:08
you don't want to know
a shell
all it's going to do is end up with something like:
0: command
1: "par
am"
2: "test
test"
that's what you want, no?
yes exactly
that is how shells work
@William don't use regex. Write an interpreter
internet is shitting out
@littlepootis language yes basic shell maybe
I don't intend to even have variables
03:12
I see you issue, it's not the newlines you're worried about, it's the spaces within quotes
you need to write an parser
they're actually fairly simple, for this type of thing
You could've written a simple interpreter in the time you spent trying to find the right regex
trueish regex can do anything. It can pares html!!!!@
I wrote something like this in C once
@William get out
For those that need enlightenment stackoverflow.com/questions/1732348/…
03:18
get out
you get out
no you get out please
poot
!!kick Shea William
@littlepootis That didn't make much sense. Maybe you meant: lick
who removed that command??
03:22
!!lick littlepootis
@William Mmmmmmm @littlepootis tastes just like schinkenspeck!
!!learn kick "<> The userhas been kicked and cannot talk for 300 days"
@littlepootis Command kick learned
03:38
does anyone know an alternative to .
for regex
How to make code generated by emmet for vim use tab stop of 4?
@William \.
@ZhengquanBai doesn't respect your vim settings?
no I'm trying to match like this [.\n]
@littlepootis
I don't want the actual character
why?
@Shea please stop asking why?
03:43
. match newlines too with the m flag
tha fuck
I'm not using javascript the language I am using doesn't have such flag
don't you think that is some pretty vital information to tell us?
I did earlier
You kinda entered mid conversation
@ZhengquanBai wait.. tabstop?
03:45
Meaning it just indents with a tab
no I read it, you just didn't make much sense
How it looks depends on your configuration
I set tabstop=4 in my vimrc. But emmet still uses 8
seeing how I still don't even know what language you're actually using
@Shea mathematica
03:47
@ZhengquanBai No, tabstop is how many spaces wide a tab appears
8 is the default
that's a language? I quit
go make a question on SO
I want to make it 4 spaces wide.
there you go, have fun
You can't have two different tabstopped tabs in one file
03:48
they have their own SE site, and yet you're here in JS chatroom
Can you cat your file and share it?
then you get pissy with me when I'm trying to understand your problem
@ZhengquanBai Do you use tabs or spaces?
!!tell kick Shea
@William Command shea does not exist. (note that /tell works on commands, it's not an echo.)
03:50
crap oh well
yeah I haven't had to ignore someone for quite awhile
calm your nuts
some people are so frustrating >.<
you just reminded me of my ex
.. who is also my current best friend
is your ex frustrating, or does your ex find people frustrating too?
03:55
the latter s/people/me
why doesnt this work?
or better:
var fragment = document.createDocumentFragment();
var child = s => fragment.getElementsByTagName(s);

child("div")
hello guys
i am wondering why 65280 & 255 returns 0
@Asperger not sure why it should work
there is nothing to get
It doesnt
Now its populated but still nothing. It just gives me an error:
var fragment = document.createDocumentFragment();
fragment.appendChild(document.createElement("div"));

var child = s => fragment.getElementsByTagName(s);

child("div")
fragment.getElementsByTagName is not a function
interesting:

2 & 3 --> 2
2 && 3 --> 3
3 & 2 --> 0
3 && 2 --> 2
04:39
Whats so interesting about it?
!!mdn DocumentFragment
@Shea Something went on fire; status 403
ok it was bitwise and operand
it compares the bits of both numbers
@Shea I know what the documentfragment is...and doing it directly works by the way:
fragment.getElementsByTagName("div")[0]
but not in the arrow function
04:41
if both bits are 1, it returns the first argument, otherwise the second argutment
Ok no it doesnt was a typo
but querySelectorAll works
@Shea thanks for reminding me. Im so used to the old school functions that I keep forgetting this detail
np
How do you send someone information when they connect to your server on socket.io?
I can only find documentation on sending a group of people information, but not a single individual...
@Ming just a chatbot I'm working on..
05:08
Hi, I'm wondering how can this function be converted into a promise. Appreciate the help. Thanks.
`
var fs = require('fs');
var cache = {};
function inconsistentRead(filename, callback) {
	if (cache[filename]) {
		process.nextTick(function() {
			callback(cache[filename]);
		});
	} else {
		fs.readFile(filename, 'utf8', function(err, data) {
			cache[filename] = data;
			callback(data);
		});
	}
}
i tried something like this, but I dont think it works.
function inconsistentRead(filename, callback) {
	if (cache[filename]) {
		return Promise.resolve((function() {
			return callback(cache[filename]);
		}));
	} else {
		fs.readFile(filename, 'utf8', function(err, data) {
			cache[filename] = data;
			callback(data);
		});
	}
}
a more direct question, is it possible to convert the if else code blocks into promises using just Promise.resolve() ?
so, before, your asynchronous function functions never returned a value synchronously
now, you'll return a promise synchronously and wrap your asynchronous functions as a promise executor and call either resolve or reject within it
@FilipDupanović I thought all promise.resolve() methods are async?
if I have a synchronous codeblock below.
if (cache[filename]) {
	callback(cache[filename]);
	};
promises are just a deferred-event system afaik
I can make it async with the process.nextTick
I thought why not just replace process.nextTick with promise.resolve()
all your asynchronous functions return promises synchronously, but the chains are always executed on next tick
05:23
this is the full code. it basically just reads a file 'data.txt' and prints the output to console.
var fs = require('fs');
var cache = {};
function inconsistentRead(filename, callback) {
	if (cache[filename]) {
		process.nextTick(function() {
			callback(cache[filename]);
		});
	} else {
		fs.readFile(filename, 'utf8', function(err, data) {
			cache[filename] = data;
			callback(data);
		});
	}
}


function createFileReader(filename) {
	var listeners = [];
	inconsistentRead(filename, function(value) {
		listeners.forEach(function(listener) {
			listener(value);
		});
	});

	return {
		onDataReady: function(listener) {
if i replace the process.nextTick function with promise.resolve, the code does not work
changed this
if (cache[filename]) {
		return Promise.resolve((function() {
			return callback(cache[filename]);
		}));
yes and that's a PITA, because it's easy to forget yourself and not do something like process.nextTick(() => callback()) and instead call the callback synchronously, which you should never do (have a function that's both synchronous and asynchronous)\
it's much harder to shoot yourself in the foot with promises because you always return them synchronously and you know that the remainder of the chain will be settled asynchronously
so to promisify inconsistentRead, first thing you do is return new Promise();, then you yank in the function body as an executor and instead of calling the callback, you call either resolve, reject or you throw an error
what are he arguments kf the catch function for onmousedown?
like this??
function inconsistentRead(filename, callback) {
	return new Promise(function(resolve, reject) {
		if (cache[filename]) {
			resolve(callback(cache[filename]));
		} else {
			resolve( fs.readFile(filename, 'utf8', function(err, data) {
			cache[filename] = data;
			callback(data);
		}); )
		}
	})
@FilipDupanović
still does not work. I get undefined
you don't require the caller to pass a callback anymore; people usually throw that in to allow others to pick the control-flow style that they prefer (callbacks, promises or generators), but say you yourself settled for promises
I'm trying to figure out how to fix it.
05:35
this is probably what you want hastebin.com/ovorozehez.js
@FilipDupanović thanks. but for the rest of the code. Must i .then() because I'm not getting any output. Its not executing the promise?
function createFileReader(filename) {
	var listeners = [];
	inconsistentRead(filename, function(value) {
		listeners.forEach(function(listener) {
			listener(value);
		});
	});

	return {
		onDataReady: function(listener) {
			listeners.push(listener);
		}
	};
}

var reader1 = createFileReader('data.txt');
reader1.onDataReady(function(data) {
	console.log('First call data: ' + data)
	var reader2 = createFileReader('data.txt');
	console.log(reader2.onDataReady)
})
yes, you always have to chain with a handler for fulfillment and rejection
Digging the new mobile version of so's chat
@FilipDupanović where could it chain it though. I'm not entirely sure. It seems inconsistentRead is returning the promise.
within the execution block where you are calling inconsistentRead() and getting a reference on the returned promise value
05:50
function createFileReader(filename) {
	var listeners = [];
	var prom = inconsistentRead(filename, function(value) {
		listeners.forEach(function(listener) {
			listener(value);
		});
	})
	console.log(prom)
	console.log(listeners)
	prom.then(function(x) {
		listeners.push(x);
	})
	return {
		onDataReady: function(listener) {
			listeners.push(listener);
		}
	};
}
@FilipDupanović like this? but I cant push the (x) values to listeners.
for starters, since you're not passing a callback anymore, it would being with something like var prom = inconsistentRead(filename);
prom.then((data) => { ... }).catch((err) => { ... });
function createFileReader(filename) {
	var listeners = [];
	var prom = inconsistentRead(filename, function(value) {
		listeners.forEach(function(listener) {
			listener(value);
		});
	})
	console.log(prom)
	console.log(listeners)
	prom.then(function(x) {
		console.log(x);
	})
	return {
		onDataReady: function(listener) {
			listeners.push(listener);
		}
	};
}
but with this code I can get the values though
@FilipDupanović
ah. this also works.
function createFileReader(filename) {
	var listeners = [];
	var prom = inconsistentRead(filename)
	console.log(prom)
	console.log(listeners)
	prom.then(function(x) {
		console.log(x);
	})
	return {
		onDataReady: function(listener) {
			listeners.push(listener);
		}
	};
}
yeah. your code works to
it still doesnt work though
function createFileReader(filename) {
	var listeners = [];
	var prom = inconsistentRead(filename)
	// console.log(prom)
	console.log(listeners)
	console.log('-----------')
	prom
	.then(function(x) {
		console.log(x)
		return {onDataReady: function(x) {
				listeners.push(x)
				}
			};
		})
}
@FilipDupanović
I've tried many ways already
06:22
this is the full working code with promises that I got. Is it correct? @FilipDupanović hastebin.com/sajowemuwe.coffee
07:06
Dear YouTube: once I explicitly tell you I'm not interested in a particular video, stop recommending it to me
07:51
@JanDvorak how do you explicitly tell YouTube so?
On the home page there's a context menu for each video card
@AwalGarg Like this: "I'M NOT INTERESTED IN THIS FUCKING VIDEO!"
And you have to scream it at the screen while YouTube is open.
Well then I am sure it'd be pretty easy for YouTube's monkeys to understand that
... oh. I thought that was an actual question.
08:15
Academics are a joke.
08:37
hOi
@littlepootis They aren't, they're just optimized for the era before Google
When the primary way of learning something was going to the library and read a book, and the university provided you with which books to read and with instructors to help you with said books
i have time "6:20", i want to add 20 mins to it or an hour to it
how to do that in javascript
i have tried using new Date("6:20") it didn't work :(
!!>new Date(0, 0, 0, 6, 20, 0);
@Shea "1899-12-31T11:20:00.000Z"
weird, I got Sun Dec 31 1899 06:20:00 GMT-0800 (Pacific Standard Time) in my console
anyways, @JoeSaad check out the fourth syntax option
there's no way i can just pass 6:20 and get full time for that?
08:48
maybe if you prepend a date to the front of it, but I can't think of a way, other than that.
so i split the string and insert it in this manner new Date (0,0,0, 6, 20,0)
well, the last zero isn't really necessary
@JoeSaad You can try parsing it yourself.
was just gonna say, it's not that complicated
ok, i'll just split and pass it as @Shea said
08:52
If that's the only form of input you're planning to accept, parsing it is a trivial one-liner
^ would actually recommend that
@JoeSaad oh, what about unix timestamps?
anything in javascript should work
i'm reading from excel sheet and times comes as "6:30"
i want to convert that into time so that i can add minutes and hours to it
kinda stuck here
@MadaraUchiha you know we can still learn from books without google without having the fucked up academic framework imposed on us
@AwalGarg Today, yes
50~100+ years ago, less so.
Learning with a teacher was far superior than learning on your own
09:07
explain
@AwalGarg You, for example, started out a noob, here in chat, and you learned and improved partially thanks to other people in this room
Today, you're in a position that you can read a technical book, understand, and implement it, no problem.
> Today, yes
> 50~100+ years ago, less so.
explain that ^
But imagine starting out in the field with no one helping you
You don't know where to start, you can go to the library and checkout a book, but which do you checkout? Which do you read?
All of them? That's a massive waste of time
@MadaraUchiha I'd actually love if that was actually the way it was done
@SomeGuy That's at least in theory.
09:09
In my experience, it's flipped over. They'll try to teach you things they don't understand themselves in lectures, and you have to rely on textbooks if you want to actually understand anything at all
In India, in an attempt to match the exploding demand, higher education became a grade factory.
That's a different problem.
there's no method which you just give it 6:20 and it gives that time for you?
@MadaraUchiha but that is still the situation today. people helping you pick a book is a problem today as much as it was previously
@AwalGarg Yeah, but you go to uni/college, you pay someone to teach you, share his knowledge and experience with you.
At least, that's how it is in theory
1 min ago, by Madara Uchiha
In India, in an attempt to match the exploding demand, higher education became a grade factory.
@MadaraUchiha I don't think that's how it is in theory. You also have mandatory homework, a "well thought out" code of conduct, exams and what not. I have a problem with all these things and they are a mandatory part of academics.
09:12
@AwalGarg Yes, homework is an essential part of any learning process
Whether you call it imposed homework or not
mandatory homework is not
Exams are a way to measure your performance
@AwalGarg How would you do it better?
@SomeGuy There are better alternatives
Courses etc created by actual developers and not wannabes
But those don't give you a diploma
@MadaraUchiha the position of exams is akin to traditional interviews. they might be in good intention, but in practice they turn out to be disastrous in picking up cream from milk.
09:13
Which in some parts of the world, makes a whole lot of difference.
@SomeGuy coursera?
@AwalGarg Hah, I wish.
At least we have the option to study that way on our own. I am grateful for that
And if not that, at least we can read textbooks on our own
Relying on a shitty education system isn't the only way to get an education, luckily
yeah. in real life though that system is imposed on you so you end up wasting a lot of time unwillingly. now that's not a problem of that system. the problems are distributed everywhere :P
add up to a shitty experience overall
Haha, I know. This is why you and I run into attendance issues all the time :P
You more than me, apparently, since you give fewer fucks than I do :p
09:40
how do I this: rgba(darkcyan, 0.1);?
kinda wondering if there's a syntax for that, but I'm just using the integral value atm.
10:00
@MadaraUchiha That's kind of how I started. I used to go to old book stores, but 20-30 books every year on random topics.. from Religion to Genetic Engineering and read them. I just happened to like Computer Science more than the others. Academics was nothing more than a distraction to me.
I didn't have Internet back then. And it was just my curiosity that's driven me. No guidance at all, nope.
10:12
@littlepootis That's a fine way to start
But that's a really bad way to get a mass of people into the field.
 
2 hours later…
Just to make sure I don't have a brainfart
if (A && B) { ... }
else if (!A) { ... }
The second if is redundant, right? else { ... } would suffice?
no
if A is true and B is false, then your code would behave differently with and without the second if
@AwalGarg Right, good thing I didn't trust myself.
well what was the other option?
I think it's time to take a break if I'm starting to get logic ops wrong.
12:44
write a website with JSHP instead
enterprise quality software
This is weird but why is my super class variable undefined?
class test {
  constructor() {
    this.x = "x";
    fooBar.worker();
  }
}

class fooBar extends test{
	static worker() {
  	alert(this.x);
  }
}

new fooBar();
I know, I have. Its just acts bit different from Java.
static methods have no this
@AwalGarg right this frickin minute?
12:53
@Shea yes, rtfm rtfm
!!urban rtfm
@MadaraUchiha RTFM Read The Fucking Manual
read the fantastic manual?
<Skilless15> what's rtfm
<Skilless15> i forgot
<@avaxx> read the fucking manual.
<Skilless15> why
<Skilless15> you could just tell me
@littlepootis Classic
12:54
realtime traffic flow management?
Well how am I supposed to run the child method inside my parent then? Obviously this.worker() isnt working either just static
sorry I'm slightly bored
We noticed
nvm, I got it working xD
Anyone remembers that meta post/blog article SE engineers wrote about how they handle global auth for SE and cookies? @MadaraUchiha IIRC you linked that here?
12:59
@AwalGarg Not that I remember
!!tell AwalGarg google stack exchange authentication cookies site:blog.stackoverflow.com
@Shea Command lmgtfy does not exist. (note that /tell works on commands, it's not an echo.)
(╯°□°)╯︵ ┻━┻
Finally done with my new cipher. It is using a hybrid transpositional cipher with substitution ciphers.
Normal programmers shouldnt be able to crack it xD
@Shea see that's what happens when you lmgtfy me
no, but that post does contain a link to the meta post. thanks!
hmm.. so they are doing this with iframes. mehhh
You guys leave the house once in a while?
xD
I have a similar situation. Multiple sites with potentially different logins for the same account, but mostly joint accounts and I want to support shared login. Anyone can think of a good way which is not as hacky as Stack Exchange's version?
13:11
Anways im off :D
oh nice lol
Wait, there's world outside my room?
/r/outside
@AwalGarg Different subdomains or different sites?
different subdomains are different sites, but both in this case
13:14
hmm
DOM question
I remember asking how Google does it on their productforums when I was a kid
Is there merit in performing size measurements and whatnot in a setTimeout(..., 0) under the reasoning that the browser needs that time to update the DOM/styles?
(right after making a DOM change)
What about in older browsers?
13:19
no
I wonder why it's done that way in the existing code...
Job security
try {
  title.innerHTML = videoBoxContainer.getAttribute("data-item-title"); // make change
  setTimeout(function() {
    this.fixBoxOverflow(title, videoBoxContainer.getAttribute("data-item-title"), false, video['truncate-title'] != "false"); // measure
!!>setTimeout(function () { console.log(this == global); }, 10);
@Shea TypeError: cyclic object value
@Shea "undefined" Logged: true
13:25
idk where I was going with that
00:00 - 14:0014:00 - 23:00

« first day (2031 days earlier)      last day (3139 days later) »