This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pipes--- | |
1.Download the contents of "Harry Potter and the Goblet of fire" using the command line from here | |
wget https://raw.githubusercontent.com/bobdeng/owlreader/master/ERead/assets/books/Harry%20Potter%20and%20the%20Goblet%20of%20Fire.txt | |
1. Print the first three lines in the book | |
2.Print the last 10 lines in the book | |
3. How many times do the following words occur in the book? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('click', event => { | |
window.events.push({ type: 'Click', x: event.clientX, y: event.clientY }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Beacon API</title> | |
</head> | |
<body> | |
<script> | |
window.events = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.text()); | |
app.use(express.static('public')); | |
app.post('/log', (req, res) => { | |
console.log('Received Beacon: ', JSON.parse(req.body)); | |
}); | |
app.listen(3000, console.log('App listening...')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('visibilitychange', () => { | |
if (document.visibilityState === 'hidden') { | |
window.navigator.sendBeacon('/log', 'session ended'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('unload', () => { | |
navigator.sendBeacon('/log', JSON.stringify({ data: 'test' }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('unload', async () => { | |
await fetch('/log', { method: 'POST', body: JSON.stringify({ data: 'test' }) }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ParcelJS</title> | |
<link rel="stylesheet" href="scss/styles.scss"> | |
</head> | |
<body> | |
<h1>Hello from Parcel!</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BtnEvent } from './Button'; | |
let btnElem: HTMLElement; | |
btnElem = document | |
.getElementById('btn'); | |
btnElem.addEventListener('click', BtnEvent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>ParcelJS</title><link rel="stylesheet" href="/styles.173a965c.css"></head><body> <h1>Hello from Parcel!</h1> <button id="btn">Click Me</button> <script src="/app.700f0921.js"></script> | |
</body></html> |