AWS Cognito gives quite poor options to customize the auth popup
We cannot add new elements, cannot create new inputs for extra css styles, etc. But there is way to make it a little bit more flexible.
AWS Cognito gives quite poor options to customize the auth popup
We cannot add new elements, cannot create new inputs for extra css styles, etc. But there is way to make it a little bit more flexible.
In Windows 10 I always suffered without the old good thing:
Since Windows 98 through Windows XP and Windows 7 it was becoming smaller and harder to find and finally disappeared completely in Windows 10. So, let's bring it back!
Google Chrome extensions aim to add extra functionality to the browser and/or separate pages. The example below demonstrates how to create a simple extension from scratch. The functionality will be implemented - navigation back and forward with mouse gestures.
The core component of every Chrome extension is the manifest.json file. So let's create the base version of the file:
{
"name": "Mouse Gestures",
"version": "1.0",
"manifest_version": 2,
"browser_action": {
"default_popup": "index.html"
},
"content_security_policy": "script-src 'self' 'sha256-GgRxrVOKNdB4LrRsVPDSbzvfdV4UqglmviH9GoBJ5jk='; object-src 'self'"
}
As declared in the manifest.json file, we have to add the index.html file. It could be any simple 'hello-world' html file like this:
<!DOCTYPE html>
<html lang="en">
<body>
Hello, I am an awesome chrome extension!!
</body>
</html>
So, the first version of the extension is ready, let's install it. Open chrome://extensions/ page, turn on the 'Developer mode' toggle on the top panel, then press the 'Load unpacked' button and select the folder with the extension we just created. The new extension appeared on the list and the 'M' icon appeared on the top panel too. If we click it we can see the popup:
1. Creating the PowerShell script.
2. Adding the task to the task scheduler.
3. Export the task to another machine.
As being just a newbie at react-native, I ran into many obstacles trying to setup everything for it. I spent quite a while resolving all issues, googling every bug and making my first 'pomodoro' app working. So I decided to track some steps here I did just in case I forget them and I can to refresh my memory reading this post :). Almost everything here is as is, without detailed explanation. But it works. At least for me.
Today, as the lunch break challenge I decided to create Tabs in Vanilla JS and that's what I made:
In descriptive writing, the author does not just tell the reader what was seen, felt, tested, smelled, or heard. Rather, the author describes something from their own experience and, through careful choice of words and phrasing, makes it seem real. Descriptive writing is vivid, colorful, and detailed.
Good descriptive writing creates an impression in the reader's mind of an event, a place, a person, or a thing. The writing will be such that it will set a mood or describe something in such detail that if the reader saw it, they would recognize it.
To be concrete, descriptive writing has to offer specifics the reader can envision. Rather than "Her eyes were the color of blue rocks" (Light blue? Dark blue? Marble? Slate?), try instead, "Her eyes sparkled like sapphires in the dark."
To be evocative, descriptive writing has to unite the concrete image with phrasing that evokes the impression the writer wants the reader to have. Consider "her eyes shone like sapphires, warming my night" versus "the woman's eyes had a light like sapphires, bright and hard." Each phrase uses the same concrete image, then employs evocative language to create different impressions.
To be plausible, the descriptive writer has to constrain the concrete, evocative image to suit the reader's knowledge and attention span. "Her eyes were brighter than the sapphires in the armrests of the Tipu Sultan's golden throne, yet sharper than the tulwars of his cruelest executioners" will have the reader checking their phone halfway through. "Her eyes were sapphires, bright and hard" creates the same effect in a fraction of the reading time. As always in the craft of writing: when in doubt, write less.
n this excerpt from Jamaica Inn by Daphne du Maurier, notice the writer's choice of adjectives, adverbs, and verbs. Granite. Mizzling. Du Maurier's choice of words allows the reader to almost feel the weather occurring on the page.
A paragraph without a header.
The HTML is the following:
Swagger is a tool that allows to describe a service API. One of the reasons for that is creation of documentation for all API functions so make it easy to examine and navigate through. Even further, swagger allows to call the API functions in a simple manner like let's say Postman does. So working with ExpressJS I just discovered the swagger-ui-express library that gives us opportunity to build the swagger UI in literaly few steps. So I created the simplest possible example (Github Link) that will be be taken to pieces below step-by-step.
As usually, we start with installing the package npm install -s swagger-ui-express.
Now let's create a simple ExpressJS HTTP server with several CRUD functions.
const express = require('express');
const app = express();
const uuidv4 = require('uuid/v4');
//stores the books collection
let _books = [];
app.route('/api/book')
.get(function (req, res) {
res.json(_books.filter(b => b.id == req.query.id));
})
.put(function (req, res) {
let book = JSON.parse(JSON.stringify(req.query));
book.id = uuidv4();
_books.push(book);
res.json(book);
})
.delete(function (req, res) {
_books = _books.filter(b => b.id != req.query.id);
res.json(_books);
})
app.get('/api/books', function (req, res) {
res.json(_books);
});
// start the server in the port 3000
app.listen(3000, function () {
console.log('Start app listening on port 3000.');
});
The service exposes functions allow to get/add/delete records (books) and retrieve all the books as well.
Next step is to display that API on UI.
Updating an element style using javascript is pretty easy: document.getElementById(id).style.property = new style. But what if we have hundreds/thousands/.. elements to be updated? Calling the property setter above will force page re-rendering every time, so it would take considerable time. That's where bulk update is really helpful. Instead of applying styles after every change we can compose the css sheet with all the styles collected together and appy it at once.
Recently I discovered that Array.prototype.forEach() function is not suitable for 'awaitable' functions. Let's have a look at an example.
const getAsyncData = (n) => {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(n), 500)
})
};
const arr = [1,2,3,4,5];
//forEach example
(async () => {
let total = 0;
arr.forEach(async n => {
let res = await getAsyncData(n);
console.log(res);
total += res;
});
console.log('total = ' + total);
})();
I expected that forEach will await for every call of the getAsyncData() function so that to calculate total correctly, but surprisingly the result was different.
total = 0Obviously, forEach ignores await keyword and quits immediately so total is not calculated.
const fs = require('fs');
fs.copyFile(
'./config/webpackDevServer.config.js',
'./node_modules/react-scripts/config/webpackDevServer.config.js',
err => {
if (err) {
console.error('Cannot copy webpackDevServer.config');
console.error(err);
throw err;
}
console.log('webpackDevServer.config is copied');
}
);
['1', '7', '11'].map(parseInt);I surprisingly saw the result [1, NaN, 3] instead of [1, 7, 11]. But if we try parseFloat
['1', '7', '11'].map(parseFloat);the result is correct [1, 7, 11]
['1', '7', '11'].map(i => parseInt(i));we get the proper outcome as well.
<html>
<body>
<script>
function createString() {
return "0".repeat(25 * 1024 * 1024).substring(0, 12);
}
var arr = [];
setInterval(function() {
let str = createString();
arr.push(str);
}, 500);
</script>
</body>
</html>
run it in your browser and open the task manager you could notice that the browser takes some limited amount of memory ~200Mb. But what if we update one single digit in our code
return "0".repeat(25 * 1024 * 1024).substring(0, 13);i.e. replace 12 with 13, run it into a browser and have a look at the process memory. It grows unstoppable and makes the browser crash in a half a minute! Why does it happen?
<html>
<body>
<script>
function createString() {
return "0".repeat(25 * 1024 * 1024).substring(0, 12);
}
var arr = [];
setInterval(function() {
let str = createString().split('').join('');
arr.push(str);
}, 500);
</script>
</body>
</html>
That manoeuvre breaks the link with the original string and prevents memory leak.
const Users = React.lazy(() => import('./Users'));
render(
<div>
<Suspense fallback={<div>Loading...</div>}>
<Users />
</Suspense>
</div>
);
<input type="file" id="uploadVideoFile" accept="video/*" />So to access the chosen file we will call
var fileInput = document.getElementById("uploadVideoFile");
To display video we need a video element
div id="videoSourceWrapper">
<video style="width: 100%;" controls>
<source id="videoSource"/>
</video>
</div>
The following snippet displays the video after it is chosen in the video element for preview
$('#uploadVideoFile').on('change',
function() {
var fileInput = document.getElementById("uploadVideoFile");
console.log('Trying to upload the video file: %O', fileInput);
if ('files' in fileInput) {
if (fileInput.files.length === 0) {
alert("Select a file to upload");
} else {
var $source = $('#videoSource');
$source[0].src = URL.createObjectURL(this.files[0]);
$source.parent()[0].load();
$("#videoSourceWrapper").show();
}
} else {
console.log('No found "files" property');
}
}
);
<div id="heart"></div>