This file contains 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 { codes } from './database'; | |
const app = document.querySelector('.app') as HTMLDivElement; | |
const videoEl = app.querySelector('video'); | |
const canvasEl = app.querySelector('canvas'); | |
const labelsEl = app.querySelector('.labels') as HTMLDivElement; | |
const ctx = canvasEl.getContext('2d'); | |
interface Window { | |
BarcodeDetector: any; |
This file contains 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 countryCodes = { | |
US: 'United States', | |
CA: 'Canada', | |
NG: 'Nigeria', | |
GB: 'United Kingdom', | |
}; | |
const sales = [ | |
{ code: 'US', count: 233 }, |
This file contains 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 speech from '@google-cloud/speech'; | |
import fs from 'fs'; | |
import dotenv from 'dotenv'; | |
dotenv.config(); | |
async function main() { | |
const client = new speech.SpeechClient(); | |
const config = { |
This file contains 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
/* eslint-disable */ | |
String.prototype.sarcastic = function() { | |
return [...this] | |
.map((char, i) => char[`to${i % 2 ? 'Upper' : 'Lower'}Case`]()) | |
.join(''); | |
}; | |
This file contains 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
let currentColor = '#ebedf0'; | |
let clicking = false; | |
const boxes = document.querySelectorAll('.js-calendar-graph-svg rect'); | |
const graph = document.querySelector('.js-calendar-graph-svg'); | |
// code for switching the current color | |
function handleColorChange(e) { | |
const el = e.currentTarget; | |
currentColor = el.style['background-color']; | |
console.log(currentColor) |
This file contains 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
// put this in a file where your service worker used to live, like yourdomain.com/service-worker.js. You can find out this path in the SW dev tools of your browser | |
self.addEventListener('install', (e) => { | |
console.log('[Service Worker] Installing Service Worker ...', e); | |
self.skipWaiting(); | |
}); | |
self.addEventListener('activate', (e) => { | |
console.log('[ServiceWorker] Activate'); | |
self.registration |
This file contains 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"> | |
<title>CSS Spring</title> | |
</head> | |
<body> | |
<img src="https://logo.clearbit.com/wesbos.com" class="person person1"> | |
<img src="https://logo.clearbit.com/paulirish.com" class="person person2"> | |
<img src="https://logo.clearbit.com/addyosmani.com" class="person person3"> |
This file contains 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.querySelectorAll('.invite-card')].forEach(card => { | |
const headline = card.querySelector('.headline').textContent; | |
const accept = card.querySelector('.bt-invite-accept'); | |
const decline = card.querySelector('.bt-invite-decline'); | |
const name = card.querySelector('.name').textContent; | |
if(headline.match(/recruit/gi)) { | |
console.log(`Nah. ${name} looks a little fishy to me. 🚷🚷🚷`); | |
decline.click(); | |
} else { |
This file contains 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
interface Without { | |
without(withoutWord: string): boolean; | |
} | |
// 1. Easiest / the way I'd do it | |
function youCantSpell(word: string): Without { | |
return { | |
without(withoutWord: string) { | |
return word.includes(withoutWord); | |
} |
This file contains 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
function testCSSVariables() { | |
var color = 'rgb(255, 198, 0)'; | |
var el = document.createElement('span'); | |
el.style.setProperty('--color', color); | |
el.style.setProperty('background', 'var(--color)'); | |
document.body.appendChild(el); | |
var styles = getComputedStyle(el); | |
var doesSupport = styles.backgroundColor === color; |