« first day (970 days earlier)      last day (2014 days later) » 
01:00 - 04:0004:00 - 20:00

1:37 AM
Still there, @Cerberus?
 
2:06 AM
@ktm5124 Hi!
 
@Cerberus Hi!
 
I've just read that people in Florida lose their right to vote if they go to prison.
And they don't get it back after they get out of prison.
So there are now 1.5 million disinfrenchised former prisoners in Florida.
 
Wow!
 
An unimaginable number!
 
That is unimaginable!
Considering the US has only ~300 million people
 
2:07 AM
Yeah.
 
... and that's just in Florida.
I wonder if there are other states with the same law.
Probably.
 
Probably.
I don't know how many.
 
Seems draconic.
 
In Florida, Trump defeated Clinton by a margin of 100,000 votes...
 
Hahaha
I wonder who would have won the ex-con vote.
(Had they been allowed to vote.)
 
2:10 AM
Black people are Democrats and populate prisons.
So I think we can be certain that she would have won, had they be allowed to vote.
 
Lol, there are two generalizations there, but I'll grant you them :)
Dutch people are tall and smoke marijuana ;-)
 
Suppose half of those (ex-)cons went out to vote, and 55% of them voted for Clinton.
45% for Trump.
Then she would have gained (0.55-0.45)*(1,500,000/2) = 75,000 extra votes.
 
Hm, yeah. Hard to say.
 
Not quite enough.
But, if it had been 60-40, she would have got 150,000 extra votes.
Which is enough.
And turn-out might have been higher than 50%.
 
Why divided by 2?
 
2:15 AM
A 50% turn-out.
 
Ohhh
 
> Despite President Obama telling black voters that he would take it as a "personal insult" if they didn't cast their ballot for Hillary Clinton, 2016 black voters didn't coalesce behind Clinton the same way they did Obama, with Clinton earning 88% of their vote (to Trump's 8%) as compared to Obama's 93% in 2012.
That being said, the overwhelming majority of African-Americans did show their support by voting for Clinton, particularly as compared to white Americans, who ultimately won Trump the election by giving him 58% of the white vote.
 
Funny that we're talking about voting, because I'm not sure whether I'll vote this coming midterms.
I'll be in England on voting day (November 6)
I would have to cast an absentee ballot and that would take a lot of work
 
Ah, yes.
Is it really that much work?
 
Well, I have to register, which I haven't done, and then I have to get an absentee ballot mailed to me, and then mail the absentee ballot.
I guess it's not all that much work...
 
2:17 AM
Heh.
So...
 
But I probably have the same predicament as many. I'm more focused on my work and personal life than being a good citizen.
Right now I have a job that I like, but my social life is lacking, and I'm lonely these days.
I guess those factors take up more of my attention than being a good citizen.
 
Hmm.
You could join a political forum and make friends there!
They would no doubt encourage you to vote.
 
Hah
I follow politics but I'm not sure I would like a political forum
I probably follow politics more these days than I used to, because it's more entertaining than ever
I think life gets lonelier as you get older. My friends all have partners and they're busy between that and work. I have several friends in Chicago but I only see them once a month.
 
Already?
How old are they?
 
They're mostly between 28-30
One friend of mine has two children already! He's 30.
 
2:25 AM
That's young!
But I wonder why they all don't have time for social stuff.
Doesn't sound like much fun!
 
Well, they're good friends, but they're not the ones I hang out with a lot, either.
I used to have a friend I'd hang out with almost every weekend, but now he's in New York.
I had another good friend I'd hang out with once a week or once every two weeks... an Italian from just outside of Venice, but he left also.
 
Hmm too bad.
Then make new friends?
 
Yeah, that's a good idea.
On the other hand, it might not have to do with friendships. Maybe I'm just wired to want a partner.
In movies and TV, people are often lonely when they're single.
I know some people who love being single, but I don't think I'm wired that way.
 
Then go on Tinder...
 
@Cerberus Ah sorry, my browser crashed.
I actually do online dating. I'm planning to meet someone after my trip to England.
The last two girls I dated both left Chicago soon after. Rotten luck.
 
2:34 AM
Too bad!
Good that you're active.
 
You know, I also miss posting on Latin.SE. The problem is I tend to be very single-minded, so now that I have a job I focus on it almost entirely.
 
Hmm.
Maybe read a bit of Latin every day before bed?
 
Hah. Interesting.
 
I've done that, and it tends to help me fall asleep.
 
I'm watching this interview of Elon Musk about AI: youtube.com/watch?v=B-Osn1gMNtw.
He's warning about the dangers of AI which is surprising, since I thought all experts agreed there is no immediate danger.
Rather, the danger is that it will advance the military capabilities of a country.
 
2:43 AM
I don't think Musk feels the danger is immediate? But eventually, it will be dangerous, and, the earlier one warns people, the better.
Isn't he also afraid of those intelligent weapons' going rogue?
 
Yeah, I guess he doesn't say the danger is immediate.
 
We should be vigilant.
 
I guess so.
Have you heard of Alpha Go and Alpha Zero?
Alpha Zero is quite amazing from a chess player's point of view. It completely upended the way chess engines work.
Instead of having a huge database full of positions and openings, it just learns by playing itself.
 
I have heard of it.
Self-learning.
Quite impressive.
Have you ever played Starcraft?
 
The next step is to invent a program which learns languages like that :-)
I love StarCraft! I used to be competitive. I played in the World Game Tour.
 
2:54 AM
Languages are infinitely more complex than chess!
Yay!
Google is trying to make a bot that can play Starcraft.
I think there is one that can play DotA.
But Starcraft is in another league.
Cool that you played competitive!
Do you still play?
I have only played Starcraft I, very long ago.
But, oddly, I sometimes watch SC II matches on Youtube.
 
I played Starcraft I competitively. Never Starcraft II.
I wasn't that good but I could beat my friends easily :-)
That's cool, I never knew Google was doing that.
I used to try and write bots that would connect to Battle.net
 
Yay!
 
I was in a clan of programmers called x86
That was in high school when I wasn't a very good programmer!
 
So what, exactly, did the bot operate on?
Did it send packets over the Internet directly?
 
I tried writing them in Java. They would send the packets appropriate to the logon protocol.
 
2:59 AM
Ah, OK.
 
I would use a packet sniffer to see what data needed to be sent... and of course all of this was documented online.
 
Nice.
Did you succeed?
 
I think I wrote a bot that connected, but it didn't do much more than that.
 
OK.
Would you ever consider playing SC 2?
 
I was too much of a perfectionist and I kept rewriting my Java code until I was satisfied, but I was never satisfied!
 
3:00 AM
I would cheer you on!
A well known problem!
 
Heh. I'm not sure.
 
I want to play it once I have built my new computer.
Which I keep postponing.
 
Nowadays Java makes a lot more sense to me. There are paradigms and practices that guide the way you write.
 
I believe SC 2 is now free.
 
Oh wow.
 
3:02 AM
I only ever wrote two lines of Java, or so, and I didn't know what I was doing at all.
 
The main principle is that it's object-oriented, so everything is an object and objects talk to each other.
Each object has different functions which other objects can invoke.
 
I read about that.
Is it much more object oriented than Javascript?
 
Objects can also hide functions from other objects by declaring them private. It can do the same with data, by declaring it private. It's useful to hide implementation details that other objects don't need to know about.
 
I think Javascript can do that?
 
Hm, yes.
In JavaScript, you can create a local variable by declaring "var xxx = ..."
This variable is local to the function it's in.
The variable is hidden from other functions.
You can also use the "this" keyword to create a variable/function that other functions can access. Between "var" and "this" you have private and public scope.
 
3:07 AM
Yes.
 
JavaScript also makes a lot of use of objects... but the style is very different.
 
I know Javascript, though I've never used classes.
 
JavaScript function constructors are similar to Java objects.
 
I have used this in Javascript, but every time I have to look up what the rules are again as to what it refers to.
Even now I have forgotten again.
 
Well there are a few points about "this".
 
3:08 AM
The free version gets you the full Terran campaign from the main SC 2 game.
And you can use all units from all races in multiplayer.
 
Cool! Neat pictures.
When you use "this" in a function, it refers to the object that owns the function. So for example if you use this in a keydown(...) function, the object that owns the function is the input field that you're typing into.
 
Right.
That's how I have used it.
When you say it like that, it sounds easy.
But somehow, it isn't always.
 
But you can also declare a variable or function prefixed by "this." inside a function.
 
What does that look like?
 
function Car() { this.accelerate = function(changeOfVelocity) {...}}
Then you can write:
var car = new Car();
car.accelerate(10);
 
3:13 AM
Ah.
 
In this case you've used the "this" keyword to create a public function for an object.
 
I understand creating the function.
 
This is in contrast to "var", which would have created a private function inaccessible to the outside.
 
But I find functions within functions a bit confusing...
I'm a total layman.
 
Functions within functions are a very JavaScript thing.
 
3:14 AM
Yeah, and I try to avoid them.
 
I'm working on a JavaScript file that has functions which return functions!
 
Which isn't always possible.
Bleh!
 
I was confused by this for a while.
 
Why can't they just return objects or something?
 
Well, an object itself can't be invoked as a function.
Here's an example.
 
3:15 AM
No, but if you're returning something.
 
But what if you want the thing you return to be invoked as a function?
Let's say you're working with an input field and you want to restrict the characters a user can type, say, only numeric characters.
You might write a keypress function like this:
var onKeyPress = function(format) { return function(event) { ... } }
Then you can register the callback with an input field.
var format = new RegExp('^[0-9]*$')
$('#myInputField').keypress(onKeyPress(format));
 
Look confusing!
 
The idea is that the onKeyPress function returns a function, which can be invoked each time a key is pressed.
 
And you're using Jquery, too.
 
Yeah, once you start using jQuery it's hard to think in terms of JavaScript again.
 
3:19 AM
I'm afraid my level is still too low to follow your code.
I understand what you want to do, but not why you want to do it this way.
 
The main idea is that onKeyPress(format) returns a function which takes an event as an input.
That function can be invoked each time a key is pressed.
By creating a "wrapper function" around that, you can customize how it works, by accepting different inputs (in this case, we receive the Regular Expression as an input)
 
Hmm.
This is an example from my code.
Which is messy.
But it works.
Your way is probably more efficient.
 
That's a good example!
When you add a keyup listener, the function has to receive an event. The function signature must conform to this.
But what if you want the function that listens to this event to also receive a Regular Expression format, which helps it decide on acceptable keys?
This function can't accept a second argument because when it's invoked it only receives the event.
So you're shit out of luck if you want to pass it a generic RegExp format.
 
You mean if you want to block entering any character that isn't a number?
 
You have to hardcode the RegExp format inside the function(event) {...} body.
Exactly! But you want to pass it any RegExp format, so that you can change the characters that are blocked easily.
 
3:26 AM
Why would I have to hardcode it? Or would I not want to?
 
Maybe in one part of your code you want to only accept numbers, but in a separate part you want to only accept alphabet characters.
Well, in your function(event) {...} body, you would have to declare a Regular Expression that filters the acceptable characters.
 
Well, I could use an if?
 
The RegExp '^[0-9]*$' only accepts characters 0-9.
You might write that RegExp in your function(event) {...} body where you add the event listener.
But what if you want to change that RegExp? Sure, you can use an if. But what if you want it to accept any RegExp that the user supplies? i.e. make it generic.
 
Why not just use an if statement inside the event function?
That depends on how the user would supply this Regex?
 
You can use an if statement, but when you use an if statement, you create a finite number of conditions.
 
3:28 AM
I would get it from wherever he entered it, and I would do that inside the event function?
 
So you would get the RegExp from outside the function, and use it in the function.
That way you're not hardcoding it, correct?
 
I'm having trouble understanding the requirements: how would you want to act on the characters, and what should the result be?
@ktm5124 Presumably, yes.
 
Hm, I'll give an example that I'm currently working on.
I have three input fields.
On the left-hand side of my web page, I have a directory tree containing folders and sub-folders. On the right-hand side, I have three input fields.
When you type into the input fields, it updates the folder that's selected.
 
OK.
 
One input field is the abbreviated folder name (e.g. DIV) another is the folder level (e.g. 10) and another is the unabbreviated name (e.g. Division)
Thus the three input fields might read: DIV / Division / 10
 
3:32 AM
Yes.
 
Then you select another folder, call it DEP. The three input fields might read: DEP / Department / 20
DEP is level 20 because it's a sub-folder of DIV.
Now, whenever you type into the first input field (the abbreviated name)... it automatically changes the name of the folder.
So let's say the first input field reads: DEP.
Then I type: DEP-2
On each key press, the folder name is updated.
First it's updated to DEP- as I type a hyphen, and then DEP-2 as I type a 2.
 
OK.
 
This is true for all three input fields. As I type in the unabbreviated name, it updates that property of the folder, and as I type in the folder level, it updates the folder level as I'm typing.
The advantage of this is you don't need a "save" or "cancel" button when you change the folder properties, since they update on each key press.
Now... I have three input fields, and they all listen for the keypress event.
 
Sounds like a nice system.
 
But they also listen for the paste event.
If a user pastes something into the input field, it has to update the folder automatically.
It would be ugly to create three different keypress functions and three different paste functions.
Better to have one keypress function and one paste function that all the input fields use.
That requires a generic function that updates the folder based on a keypress or a paste.
The less code the better, less is more.
But now I have a generic keypress function which behaves differently based on which input field is being typed into... so I need to pass it some parameters that tell it how to behave.
For one, I need to pass it the property to update (abbreviated name, unabbreviated name, or folder level)
 
3:36 AM
I would probably just use three if statements inside the event function...
 
For another, I need to tell it what characters are acceptable (the name fields can take any character but the folder level can only take numbers)
I think it's possible to use three if statements
But you would have to discern which input field you're in, most likely using the "this" keyword.
If you pass all three input fields the same keypress function, that keypress function would need an if statement that discerns whether the field is numeric or not, etc.
 
@ktm5124 Yes, that's what I would do.
 
It would also need an if statement to discern what properties to write to. Each folder is an object and has three properties:
 
In this userscript I pasted code from, I automatically create a whole bunch of buttons on a page.
 
folder = {abbreviatedName: 'DEP', unabbreviatedName: 'Department', level: 20}
The if statement would have to say "Hey, I'm in the numeric input field, so I'm only accepting numbers and I'm updating the 'level' property for the folder object".
You might have format = new RegExp('^[0-9]*$') and target = 'level'
if (inNumericField) { format = new RegExp('^[0-9]*$') and target = 'level' }
something like that.
I concur, you can do it this way too, with three if statements.
 
3:42 AM
Yes, that's what my naïve self would do.
 
But another way is to wrap the function inside a function, and have the outer function take these variables as parameters.
var onKeyPress = function(format, target) { return function(event) { ... } }
And then inside that function(event) you can use the format and target arguments
You don't need if statements to discern what they are; they're just plugged in.
 
I would just create a separate function at the highest level of the code and call that from inside the keypress function?
If I wanted that.
Somehow, I find creating functions inside functions confusing, so I only do that when I have to.
 
You could write
numericInput.addEventListener("keyup", onKeyPress(numericFormat, "level"));
The entire phrase onKeyPress(numericFormat, "level") evaluates to a function(event)
But that function(event) is customized with the parameters you plug in.
 
So your main reason to do it this way is to keep your code shorter?
 
I think so :-)
The other reason is subjective, but it seems cleaner.
There's a third reason
Let's say your requirements change and the acceptable characters are no longer numbers but numbers from 0 to 100.
If you do it with a function inside a function, you can just pass it a different numericFormat argument.
But if you do it with if statements inside the function(event) you need to modify those if statements and add a separate case for numbers from 0 to 100.
 
3:47 AM
Or I can just change the regex in one of the if statements...
 
Each time the requirements change, you have to add a new if statement or modify it.
 
Modify it, yes.
 
What if you have 7 input fields? Would you have 7 if statements?
The code becomes a little harder to read then.
 
Yes, or using ternary operators or something.
 
You eliminate all those if statements if you have a wrapper function that takes the format as an input.
(Or ternary operators.)
 
3:48 AM
Or I would write a function outside the event function and call that from inside the event function.
 
You could. You could get the ID of the input field and call a function which returns a format for that ID.
That function would have the if statements.
It's partly just a style preference.
Whether you do it that way or with a function inside a function
 
An example: from inside the sorteren function, I call the objecten_sorteren function, which I have defined elsewhere.
All functioned are defined at the highest level, lest I get my necks in a knot!
 
Right, you could have some outside helper functions, which give you the format and the target to write to in my example.
 
Yeah, and what you're doing is using an anonymous(?) function inside the other function?
 
Exactly.
 
3:52 AM
I find it hard to wrap my heads around that.
 
You use an anonymous function, too!
You had addEventListener("keyup", function(event) {...})
 
Just as I find it hard to assign functions to variables, which I saw you do.
@ktm5124 Yes, but that is copy-pasted.
 
You're using an anonymous function as an argument.
 
And I find it hard to read. But it works, so I keep it.
 
Well, when you assign a function to a variable, it's considered a "function expression".
 
3:53 AM
Very confusing for my poor heads!
 
Conversely, when you declare a function as "function myFxn() {...}", you're creating a "function declaration"
 
That is the kind I understand.
 
The two approaches lead to either function declarations or function expressions, and they're treated a bit differently by web browsers.
It's not a big difference, though.
It's mostly just a style point.
 
Right.
 
I guess I'm just saying that there's a slight technical difference (declaration vs. expression) but it's mostly a matter of style.
 
3:54 AM
Maybe my style is a bit more verbose.
 
No, it's not.
I don't know if one style is preferred over the other.
 
I'm a total layman; I've never learned to code.
 
I started using "var f = function() {...}" after I saw my co-worker do this.
 
I just know that there are some thing I find it hard to wrap my heads around, such as functions inside functions, whereas others are immediately clear, such as case switch.
 
But then there are other things my co-workers do that I don't do...
I spent a lot of time thinking about a function returning a function. Eventually I found it convenient.
 
3:56 AM
I'm glad to know that there is no real disadvantage to just doing function sort() {...}.
 
Not at all!
There's some technical bit about function hoisting that I forget.
 
There is probably some reason why it's convenient that you get a feeling for once you're more experienced, or something.
 
Function hoisting is a topic I've forgotten...
Easily googleable, though.
 
Ugh, I've read about that.
It had something to do with at which exact moment variables were created inside a function.
Though closures are even more confusing...
I understand what they are about, but I find it impossible to remember when they happen and such.
In Autohotkey, you just do it like this:
sort(){
static internal_variable
...
}
 
01:00 - 04:0004:00 - 20:00

« first day (970 days earlier)      last day (2014 days later) »