« first day (5 days earlier)      last day (202 days later) » 
00:00 - 14:0014:00 - 00:00

00:00
Alright, I got classes, feel free to ping me with commits though
Alright, have fun dude
 
2 hours later…
02:07
Before committing, please check your repository as it is more than possible that it is different.
@IsmaelMiguel Since the license is included in the source file, is that why you are allowed to have the actual jQuery file in your code?
@SirPython Yeah, it is a requirement of the license.
Which I'm perfectly fine with
Ah, good. I was thinking about using jQuery for my side project, but I didn't know if I was allowed to include the source file my code.
As long as you say "This is jQuery!", you are fine
But so far, what do you think?
I'm looking over the repo now.
02:20
Take your time
What is the legacy folder's purpose?
To contain the legacy code, until deciding what to do with it
Basically: old versions
Before the massive rewrites
I have a few commits to make to my fork.
How do I update my repo so that it is even with yours?
02:32
Great question...
nhgrif knows it, I don't
I found an article that explains how to do it with the terminal, but I'm too tired to boot up my VM now...
You can install SourceTree
It is complicated to use, but when you get the hang of it, it becomes really quick
I might actually have a git bash client on my windows side...
Try it
You don't seem to have a fork from my git
02:39
Let me investigate
Hmm. It looks like what Malachi does is keep a separate repo, but he doesn't worry about your commits.
Ooh.
That link looks good.
It does look good.
That's why I sent it
It isn't hard to follow.
Ah, I have updated my code.
Nice!
It worked?
Yes; perfectly.
02:48
That's some good news
How often should I create pull requests? Like, how many commits?
It really depends
There are files that you can commit like crazy
There are others that you need to be careful
As long as you check that no one is editing it, you can do any time you see it is working fine
 
6 hours later…
09:16
Hello :)
:-)
I've heard of promises and I'm aware callbacks are the way to go.
I'm actually learning JavaScript to learn node :P
However, my understanding of callbacks is I need to put a callback in a callback in a callback if I want to execute multiple functions after each other synced.
I still hope I ever get the hang of it, but most of my hope is gone by now :)
From what I've learned, the thing is that JavaScript is written in the way that you free up the thread while stuff(tm) happens. When that stuff is done, you have a callback that somehow triggers the next chain in line.
But you should try to write your code as independent of each-other as possible. Else the hard part becomes testing.
If things fuck up, you'll have hell trying to figure it out :P
Something like that, yea. If network I/O is busy but you have a CPU calculation going, it will keep the calculations going till the I/O is free so it won't block.
@Gemtastic Too late, things are already fucked :P
09:20
Exactly. Therefore you kinda need to forget about the train of functions that happens in synchronous programming (and GAS)
I'm attempting to unlearn that myself. I've gotten to the part where I kinda understand in theory how it works and what I'm supposed to do, but I don't know how to do it :P
It still feels a bit random with how the function parameters end up inside the functions in the functions @_@
Basically I get a request to my Node.JS server. The query inside that request contains data I need to write to hardware. So I send the request to the appropriate method handler and write it to the bus. Now, if the query says I need to write multiple times, I want those to be executed in order...
@Gemtastic That ^^
Greetings
I have VHDL experience, which does 200 things at a time, but all deterministic. JS isn't deterministic...
@Mast Then the questionis: Why do they have to happen in order?
And I'm a Java developer. :P
@Gemtastic I was writting a review to your question, I ended up overengeneering it.
09:23
Because my hardware expects it in order or won't properly function.
@IsmaelMiguel Nothing wrong with over engineering.
@IsmaelMiguel Less is more~
;P
Actually, it is A FREAKING LOT more
@Mast Hmm... I'm not familiar with that kinda problems :S
To the point where I even make the prompt stop when it is typing.
That is overengeneering at it's finest.
Assume you're writing FizzBuzz. You'll want 1,2,Fizz,4,Buzz, not 1,Fizz,2,Buzz,4
09:25
Nah, he wrote something cool
You could have the function push to an array and then order the array and print it
Now, my hardware expects it's commands in the right order as well. Just like that.
And you seem to have forgotten the 3
@IsmaelMiguel Fizz = 3
Oh, right, you were explaining order, not FizzBuzz itself
09:27
Haha XD
@Gemtastic Does JavaScript have variable length arrays, like Vectors?
Yes. Strings also have a .length
Everything is variable
But they are from differen prototypes
It's easy to learn how JavaScript (the language) is structured
09:28
@Gemtastic Structure seems to lack IMHO.
Simple structure != lack of structure
I basically need to translate my query and afterwards 'write' the translation like write(key, value)
I kinda feel like I could write my own JavaScript
But, in order. Translate first, write after and in right order.
Well, that's where the callback comes in; if success on translate, trigger write, else handle error.
I'm all full of theory, I need more practice though XD
09:33
Let's say the translation leaves 12 write commands. How would I execute those sequentially?
Synchronous and all.
Put them all in an array and walk over that? Or could I just walk over the resulting object?
10:24
Well, then you're doing it wrong :P
I don't think I know enough to exactly tell how to do that, but the way understand it you need to drop the whole "sequential" thing. JavaScript is single-threaded so there is a linear event-chain, but the functions fire and then the thread goes on to do other things while it waits. The point is to free it up so that it can deal with firing another long-running function.
If ordering is important, you can manage that by sorting before persisting or whatever you wanna do with the result.
11:11
@IsmaelMiguel, I think we should add some general language used on SE, not necessarily memes
Feel free to write a dictionary :P
11:23
@Quill That's why I have the _ common.json
I don't even know what a TLA is!
@IsmaelMiguel is _common.json for non-memes
Yes and no
It's for anything that's common
Top notch internet
Don't worry about the double-ping
@Gemtastic I can't drop sequential if the hardware requires sequential, can I?
@IsmaelMiguel Terribly Lazy Answer
11:33
To be fair, I've never heard of hardware that requires it
@Mast Thanks a lot
@Gemtastic First I need to initialize the hardware with a command. Second I need to send the data. Third I need to tell the hardware all data is in and it should execute it.
@Gemtastic Some things may require sequential operations. For example, waiting the value of a sensor that takes around 15ms to get a value. And you need that value to continue.
Things will still happen in order of execution, but the methods may end at different times. If you fire the same function printing "hello world" will print it in a sequential order because they take the exact same amount of time to execute.
@Mast That's when callbacks are the thing.
But if you can avoid it, do :P
Sometimes it is a good thing to use calbacks, even when not needed.
11:36
And well, I'm still a JS n00b so you shouldn't really be asking me for more precise tips :P
Just so that the browser can carry on and process other important stuff.
@Gemtastic Yea, but bus controlling isn't that exact.
Exactly my point though it may be unclear :P
@Gemtastic May is the keyword
Indeed
Maybe we should s/may/was
11:39
What? o.O
Feels like we're making 'Hitchhikers' Guide to SEN', with Memer
SEN?
Stack Exchange Network
More like CRS
We have memes from other sites too
11:40
We don't use lazers here, we have napalm.
Lots of ammo for zombies
Those are very old memes
monking #2
Greetings
@DanPantry Did you go to bed again?
11:43
No, I posted monking in the 2nd monitor as well :-)
oh, I saw that now :P
Wanna give me a review on some JS code? :D
maybe it'll soothe my headache and come down from this energy drink so sure
7
Q: Console-like printing of message JavaScript

GemtasticI'm learning JavaScript and I've made a very simple little document modifying script that prints a message as if it was someone typing into a console. It practices recursion and in my opinion, I feel a bit iffy about the amount of if-cases in the code. My main concern is the JavaScript though I k...

:)
I'm new to JS to please treat me kindly ;)
Looks like the other guys have cvoered more or less what I would have said
First thing that stood out was that it isn't re-usable, but @somethinghere has already covered that
Yeah, that's kinda what happens with recursion; takes away a little of the reusability :P
Otherwise, how do you think I faired as a beginner?
11:47
I think you did OK, but you need to separate DOM access from actual business logic.
@Gemtastic You can do recursion with a queue. Just how I did.
You shouldn't use IDs in selectors (css or javascript, IMO)
at least, not in the way that you have.
I would have passed an element into the function that prints to that element
and that element could be $(#yourid) or whatever, but I don't think you should have hard-coded the element into your function
though I would prefer to see .js-my-element over #my-element
@IsmaelMiguel There's a lot you can do, my code is the "make it work" part. Step two is, Make it better! :D
@Gemtastic Step 3 is letting me over-engeneer it
@DanPantry isn't that a jQuery thing?
11:50
by the way, @IsmaelMiguel it is "analyze"... not analise :P
@IsmaelMiguel pfft :P
you wouldn't want to google 'analise'
@DanPantry Challenge accepted
@Gemtastic yes, but there is a native alternative.. node.querySelector('#yourid')
@DanPantry That kinda glared at me as well. I've been wondering if I should have edited it XD
11:50
where node is a node like document
@DanPantry Ah, the query selector thingy. That one, was it the one that only reads what's there when you create the document? (Or did I get that wrong?)
@Gemtastic it will retrieve the elements that are loaded in the DOM at time of execution, yes. however you should only be running scripts after the DOM is initialized anyway.
querySelector returns the first instance of that selector matching.
querySelectorAll will return all instances
@DanPantry I understood it as that it doesn't read in changes made by things like "selectElementById"
If you use document.querySelector('#id'), you are doing it wrong.
What is selectElementById
@IsmaelMiguel I agree, it was just the side-by-side comparison. You shouldn't be using IDs in JavaScript anyway (in my opinion)
The only reason you should use IDs (again, in my opinion) is for hash-based anchors in urls
11:53
oopd I mean "getElementById"
You shouldn't hard-code an element
Sorry, I haven't memorized all the names yet blush
@Gemtastic querySelector will return id-ed elements, its just it doesnt make sense to use querySelector when retrieving an element with an iD
querySelector mainly exists because there's no getElementWithClass
Yes there is one O.o
@DanPantry There's getElementsByClassName()
hur durrr
I woke up at 6am
forgive me
Don't worry
However, I chose to use an ID here as class by the very point is supposed to use when there could be more than one
Like having many console-wannabes
The point being
11:56
Wheres I only wanted to touch that one div
the element you choose should not be chosen in the same function that does the heavy lifting.
you should have function print(element) {}
@DanPantry I feel like that every day ;P
and have the caller pass the chosen element (ID-ed or not) to the function
Yeah, that's the more OOP way of doing it
I daresay that's even DI
bbl gotta take a break in the sun ;P
that's not OOP :-)
it's just separation of concerns. stable in all dev :)
staple
12:06
@IsmaelMiguel, instead of <br> in the .md files, you add two spaces after the end of the sentence
tempted to apply to groupon
thoughts?
to?
Groupon
Don't.
Heard too many bad stories about it.
@Mast elaborate?
(or cite)
12:13
People not getting their money back, people not getting what they paid for, stuff like that.
I'd be working in the development team, not buying/selling stuff
Oh.
Well, perhaps you can fix their sh*t so the complaints go down.
@DanPantry Neigh ;D I'm a horsegrammer :O
wat @Gemtastic
12:24
Stable
Where you put horses :D
I dunno I blame the sun
So, @DanPantry do you have any recommendations for assignments to try to practice doing callbacks?
@Gemtastic my recommendation for callbacks is "don't, learn promises" :p
That's actually my idea
That I'd learn callbacks so that I know them before I even sniff on promises
There's not much to learn about callbacks, frankly lol
I never learned to successfully implement promises. I did manage callbacks, albeit ugly.
@Mast you can just use Bluebird to manage the 'implementation' for you
12:29
Promises abstracts things away. I feel that I don't learn as well when I "only" learn the abstractions
Callbacks feel like a good way to really learn JavaScript
@DanPantry I'm not going to use additional libraries. I'm already neck deep in that stuff. NodeJS is what I got.
@Mast Promise is part of the ES6 spec
Bluebird just lets you convert 'node-style' callbacks into promise-based ones easily
(it's also faster than the ES6 spec)
@Gemtastic Well, as I said, there's not much to learn. Callbacks are functions that are passed as the last argument to a function that is asynchronous.
That's like making a crazy language even crazier.
The callback is invoked once the asynchronous action is completed. node-style callbacks take two arguments, (err, result).
err is null if there was no error. If err is not null then an error is expected to have been occured.
@Mast Bluebird is one of the most widely used libraries. It's that good.
Well, I still feel like I need to get some assignment to learn how to handle them properly.
12:31
Andy ou can safely ignore the extra features of Bluebird if you really don't want to use it, but I recommend you do.
@Gemtastic I'm not giving you one :p
How does that work? How does the err pass into the function?
I don't use cbs and even if I did I can't think of an example on its own
That feels a bit like magic to me
you invoke it like a normal function, @Gemtastic.
12:32
cbs = callbacks
example async function...
function doSomethingMagic(cb) {
  setTimeout(function() {
    cb(null);
  }, 1000);
}

doSomethingMagic(function(err) { if(err) throw err; console.log('foo'); });
In promises, this looks like this.
Well, I suppose I don't fully grasp how it works with normal functions then; when you pass (err, callback) to a function, how is the err put into the err?
@DanPantry As said, extra libraries aren't an option. I think it's doable in vanilla Node.JS.
@Gemtastic you pass itl ike a normal function.... lol
function throwAnError(cb) {
  setTimeout(function() {
    cb(new Error());
  }, 1000);
}
errors are objects just like any other object in javascript
@Mast Most things are doable in NodeJS, but it's probably pretty complex
@Mast you can take that stance if you want, but it's a silly approach to take.
NodeJS has the best packagem anager inthe world, arguably - npm
and it is heavily focused on reusing packages
You are putting yourself at a disadvantage by not standing on the shoulders of giants
Besides, you need a 3rd party library if you ever want to compose asynchronous operations - except Promise.all() - so
12:35
@DanPantry I'm out of time to implement new stuff. 2 months ago I'd have agreed with you.
For example, the 'plain old node' way only used callbacks and there was no way to neatly compose those until async came along.
I feel dumb, I don't get it :/
I really need to get this stuff working and new libraries always take time to learn.
Doing a quick Memer test, don't mind me
@Mast I guarantee it will take you more time to implement your own promsie aggregation thinger than it will learning the bluebird API.
12:36
TLA
Winter Bash
@DanPantry Well, so far I don't understand both.
Duga
@Mast var timeoutAsync = Bluebird.promisify(setTimeout);
timeoutAsync(1000).then(function() { console.log('hello!'); });
or if you want to get tricky with Es6 generators
function* () { yield timeoutAsync(1000); console.log('hello!'); }
Which is perfectly unreadable JS, just like the rest of the language. I just need to execute a shitload of functions in the right order. I'm not interesting in timing, just in making sure the previous function has properly executed before starting the next.
Which seems overly complicated in JS.
It's freaking easy in C++.
that's because everything in JS is asynchronous.
Are you using promises or callbacks, @Mast?
12:38
@Mast Well, c++ is sequential and synchronous :P
@DanPantry Uh, one. When I'm getting a request which is actually meant for another server. It starts a new request, awaits it's response and than copies the result to the original client.
If you're using promises its super easy
@Gemtastic Yea, I love deterministic, sequential languages.
@DanPantry No, that's a callback.
You need a third party library for callbacks.
Or a callback pyramid (AVOID AVOID AVOID).
@Mast I can understand that, since you apparently don't work asynchronous :P
12:40
@Mast get this github.com/caolan/async
paste me the code you want to execute sequentially and I'll transform it for you.
SNR
@DanPantry I'll look up how it's currently done, it's not relying on a third party.
callbacks can only be executed sequentially with a) async or b) callback pyramid.
callback pyramids are bad.
So use async.
Your stubbornness to use a third party library is understandable, coming from C++.
But you need to let it go (THE COLD DIDN'T BOTHER ME ANYWAY) in JS.
handleGetSecondaryRequest = function(callback, res, qu) {
	var OPTIONS = {
		hostname: 'localhost', //10.33.62.68
		port: '8502',
		path: '/?' + qu
    //path: '/?GetSensors=True&GetActuators=False'
	}

	var data = null;

	http.get(OPTIONS, function(func, data) {
		func.on('data', function(chunk) {
      data += chunk;
		});
		func.on('end', function() {
			callback(res, data);
		});
	}).on('error', function(e) {
		callback(res, e);
	})
};
var handleGetSecondaryRequestCallback = function(res, receivedData)
{
	res.write(receivedData);
	res.end("END\n");
};
Which is a callback pyramid
12:43
Which is bad.
http.get - is that http from node?
ie, require('http')
Yea, it's kind of essential since it's part of a HTTP server.
Current libraries:
var http = require('http');
var url = require('url');
ok, one second.
wait
does this not work? why dod you need it to be changed?
or is it just an example
It's one of the working parts.
You just asked if I used callbacks. Well, one, here.
Yes, but I mean
Whats the issue with this code? Like, you're struggilng to execute it in sequence
where is the bit that is calling it?
12:50
That part isn't working as intended currently. I could provide an example.
There are a lot of functions to be executed, which currently go like this:
function initI2C(o) {
  Servo.writeReg(0, 0);
  Servo.writeReg(2, 0);
  console.log("Init");
  runNextMethod(o);
}
Where o is the variable for my query.
Which is totally ugly.
Next would be
function dataI2C(o) {
  Servo.writeReg((parseInt(o.ActuatorNumber*2))-1, parseInt(o.Speed));
  Servo.writeReg((parseInt(o.ActuatorNumber*2)), parseInt(o.Direction, 10));
  console.log((o.ActuatorNumber*2)-1, o.Speed);
  console.log(o.ActuatorNumber*2, o.Direction);
  console.log("Data");
  runNextMethod(o);
}
This all gets handled by a monster:
var commandsI2C={
  'initI2C':initI2C,
  'dataI2C':dataI2C,
  'executeI2C':executeI2C,
  'stopI2C':stopI2C,
}

var nextMethodIndex=0;

var methodOrder=['initI2C', 'dataI2C', 'executeI2C']

function runNextMethod(o)
{
    console.log(o);
    console.log(typeof o);
    if(nextMethodIndex<methodOrder.length)
    {
         var func = commandsI2C[methodOrder[nextMethodIndex]];
         nextMethodIndex++;
         console.log("Next method:", nextMethodIndex);
         setTimeout(func(o), 3000)
    }
RBA
let me transform this section of code to give you an idea, OK/
@DanPantry Exactly.
SNR
12:53
what bit runs handleGetSecondaryRequest?
Why is RBA not getting flagged *sigh*
Winter Bash
Teacher's Lounge
Now, what I actually want is to generate a list of writeReg(key,data) commands which should be executed in the correct order and is generated based on the query.
@DanPantry Oh, that only runs if it's not for this server.
It's the proxy function.
Jamal Mat'sMug rolfl 200_Success SimonAndréForsburg
So I can have a client calling this server, or a client calling this server relayed by a server by a server by a server.
In theory...
@Quill That's a test guys, don't worry
12:55
@Quill Forsberg is with an E
@Mast here's a little improved version of what you already had
// callback MUST be last argument
function handleGetSecondaryRequest(res, qu, callback) {
  // You know you could pass in arguments like this:
  // { GetSensors: true, GetAcutators: false }
  // And set that as 'qs' in options, right?
  var OPTIONS = {
    hostname: 'localhost',
    port: 8502,
    path: '/?' + qu
  };

  var uri = url.format(OPTIONS);
  // Pass the error and result stream to the callback.
  httpGet(uri, callback);
}

// Helper method because the in-built http.get is weird
function httpGet(uri, callback) {
@Mast Thank you
Once you set the callback as the last argument you can use composing libraries like async
But it's also common convention to set the callback as last argument setTimeout is the exception for legacy reasons
I would really recommend you stop saying JavaScript is a bad language when the real problem is that you are just coding it wrong
:S
JavaScript is not C++ and a lot of the synchronous idioms you use in C++ just don't apply here
@DanPantry I'm not saying it's a bad language, I just have trouble getting used to it. Me hating it doesn't make it a bad language.
yield (ES6) and Promises can help with making asynchronous code appear more synchronous
12:58
@DanPantry That looks a lot better than what I got.
You can use async.waterfall to help with your composition
Somebody use something abbreviationish in chat
BTW.abc is one
@DanPantry Waterfall puts them all after each other?
13:01
@mast waterfall looks like this
async.waterfall(tasks, callback)
it will execute each task in the tasks array in order. The result of each task will be passed to the next task in the chain
if there are any errors, or the task chain finishes, then the result and /or error will be passed to callback.
Now that's worth getting a library for, exactly what I need.
async.waterfall([
  function(cb) { cb(null, 1) },
  function(previousValue, cb) { cb(null, previousValue + 1); }
], function(error, finalValue) {
  console.log(finalValue);
});
this will, for example, print 2
Sorry for double post
@IsmaelMiguel, I added way more memes and fixed a few bugs. There's a pull request there.
I have a major code re-haul planned for Friday afternoon, if you like I'll keep you updated with the result.
@Mast sure. :-)
13:05
@Quill I'm off for the night, though
@quill cya cyndaQUILL c;
@DanPantry marshtomp ftw
I like this guy
@Quill Burn it, with fire!
@DanPantry So you start with defining the callback and then follows the list of functions?
@Mast async.waterfall starts by defining all of the functions first, and teh last argument is the 'finished' callback as such
It's kinda hard to envision which is why I prefer promises
13:10
So promises would be even better than async?
Well that depends
it's extra work to implement promises obviously
Does it improve readability in the end?
In my opinion, yes
getFirstRequest().then(getSecondRequest).then(reactToSecondRequest)
talk in a couple hours, i need to work
Thank you for your help so far, it has been invaluable.
now that one works!
13:37
anyone want to help me get some JS working with ASP.NET
?
@Mat'sMug!!!!
I have no experience with ASP.NET and I suck at JS, but you could post it anyway.
I can't get my code to work.
meeting in 10 minutes
I forgot all about it too
@IsmaelMiguel I can't right click in chat now
00:00 - 14:0014:00 - 00:00

« first day (5 days earlier)      last day (202 days later) »