Skip to content

Instantly share code, notes, and snippets.

@codebubb
codebubb / visibility-change.js
Created October 28, 2020 09:15
Beacon and PageVisibility API
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
window.navigator.sendBeacon('/log', 'session ended');
}
});
@codebubb
codebubb / app.js
Created October 28, 2020 09:16
Beacon and PageVisibility API
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...'));
@codebubb
codebubb / index.html
Created October 28, 2020 09:18
Beacon and PageVisibility API
<!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 = [];
@codebubb
codebubb / click-events.js
Created October 28, 2020 09:20
Beacon and PageVisibility API
window.addEventListener('click', event => {
window.events.push({ type: 'Click', x: event.clientX, y: event.clientY });
});
@codebubb
codebubb / commandline_exercises.txt
Created November 3, 2020 19:31
Command Line Exercises
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?
@codebubb
codebubb / react-youtube-07-App.scss
Created November 5, 2020 20:56
React YouTube Viewer
body {
font-family: "Commissioner", sans-serif;
font: "Commissioner", sans-serif;
}
.app-container {
padding: 50px;
}
.search {
@codebubb
codebubb / react-youtube-08-App.js
Created November 5, 2020 21:05
React YouTube Viewer
import React, { useState, useEffect } from 'react';
import { Search } from './Search';
import { Video } from './Video';
export function App() {
const [videos, setVideos] = useState([]);
const [currentChannelId, setCurrentChannelId] = useState();
const [channelName, setChannelName] = useState();
const [searchError, setSearchError] = useState(); // Create searchError state
@codebubb
codebubb / nginx.example
Created December 4, 2021 10:04
nginx Example Server Config
server {
listen 80;
listen [::]:80;
root /var/www/{domain}/html;
index index.html index.htm index.nginx-debian.html;
server_name {domain} www.{domain};
location /api/ {
@codebubb
codebubb / workspace.json
Created December 7, 2021 09:44
Example workspace.json
{
"version": 2,
"projects": {
"rickandroll": {
"root": "apps/rickandroll",
"sourceRoot": "apps/rickandroll/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/node:build",
@codebubb
codebubb / fixed-header-footer.css
Created October 12, 2023 18:52
Fixed header footer