Skip to content

Instantly share code, notes, and snippets.

View pauljacobson's full-sized avatar
:octocat:

Paul Jacobson pauljacobson

:octocat:
View GitHub Profile
@pauljacobson
pauljacobson / A Real-Time Date-Time Script in JavaScript (ES6) - variation
Created October 25, 2017 08:29
This is a variation on my previous Real-Time Date-Time script
Date.prototype.dayName = function() {
const today = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return today[this.getDay()];
}
function time() {
const now = new Date().toLocaleTimeString('en-GB');
const dateNow = new Date().toLocaleDateString('en-GB', {year: 'numeric', month: 'long', day: 'numeric'});
const todayNow = new Date().dayName();
document.querySelector('.clock').innerHTML = `<p>Today is ${todayNow}, ${dateNow}. The current time is ${now}.</p>`;
@pauljacobson
pauljacobson / A Real-Time Date-Time Script in JavaScript (ES6)
Last active October 22, 2017 10:02
Sharing code for a JavaScript script that displays a real-time date-time field that updates automatically, without a browser refresh.
// The purpose of this block is to list the month names which will correspond with the
// corresponding numerical value of the particular month that is other derived from
// the getDate() method.
Date.prototype.monthName = function() {
const monthsOfYear = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];
return monthsOfYear[this.getMonth()];
}
@pauljacobson
pauljacobson / array_iteration_thoughts.md
Created September 13, 2017 09:16 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

Verifying that +pauljacobson is my blockchain ID. https://onename.com/pauljacobson
Would you like to use emoji on your iPad or iPhone? Your device has an emoji keyboard that you need to activate to use emoji on your device. Here are three simple steps you can follow to add the emoji keyboard:
<h3>Step 1:</h3>
Open your ``Settings`` panel and select the ``General`` tab. Look for the ``International`` menu item and tap that.
<a title="View 'http://farm8.staticflickr.com/7097/7285178314_a8b3fb84c2_z.jpg' on Flickr.com" href="http://www.flickr.com/photos/73753110@N00/7285178314"><img style="display: block; margin-left: auto; margin-right: auto;" title="http://farm8.staticflickr.com/7097/7285178314_a8b3fb84c2_z.jpg" src="http://farm8.staticflickr.com/7097/7285178314_a8b3fb84c2_z.jpg" alt="http://farm8.staticflickr.com/7097/7285178314_a8b3fb84c2_z.jpg" width="640" height="480" border="0" /></a>
<h3>Step 2:</h3>
In the ``International window``, select the ``Keyboards`` option to view your current keyboards.