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 array = [1, 2, 3]; | |
let index = 1; // Any index | |
let filteredArray = array.filter((el, i) => i !== index); // [1, 3] |
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
// https://stackoverflow.com/questions/9439725/javascript-how-to-detect-if-browser-window-is-scrolled-to-bottom | |
window.onscroll = function(ev) { | |
if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) { | |
alert("you're at the bottom of the page"); | |
} | |
}; |
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 path = require( 'path' ); | |
const webpack = require( 'webpack' ); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
module.exports = ( env, options ) => { | |
return { | |
entry: './src/block.js', | |
output: { | |
path: path.resolve( __dirname, 'build' ), |
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 getRandomNumbers = (length: number) => { | |
const value = Array.from(Math.round(Math.random()*(Math.pow(10, length))).toString()).reverse(); | |
return new Array(length).fill('0').map((v, i) => value[i] || v).reverse().join(''); | |
} | |
const generateId = (amount: number, length: number) => new Array(amount).fill(0).map((a, i, b) => `${i && '-'}${getRandomNumbers(length)}`).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
Admit That Lake Should be Protected | Deny That Lake Should be Protected | ||
---|---|---|---|
No Danger to the Lake Exists | Lake Lives | Lake Lives | |
Danger to the Lake Exists | Lake Lives | Lake Dies |
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
I Wear Mask | I Don't Wear Mask | ||
---|---|---|---|
Mask Helps | Spread is Lowered | Spread is Increased | |
Mask Doesn't Help | Spread is Same | Spread is Same |
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
export class Client { | |
private id = generateId(4, 4); | |
// Channels | |
private dataChannels: { [id: string]: RTCDataChannel } = {}; | |
private streams: { [id: string]: MediaStream[] } = {}; | |
// Agents | |
private BroadcastingAgent = new BroadcastingAgent( | |
this.id, |
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
export class BroadcastingAgent { | |
// Participants | |
public participants: string[] = []; | |
// Subjects | |
public addParticipantSubject = new Subject<string>(); | |
public removeParticipantSubject = new Subject<string>(); | |
private commSubject: Subject<IMessage<unknown>>; | |
constructor( |
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
export class RTCMessagingAgent { | |
// Subjects | |
public OnAddParticipantSubject = new Subject<string>(); | |
public OnRemoveParticipantSubject = new Subject<string>(); | |
public OnSetLocalDescription = new Subject< | |
[string, RTCSessionDescriptionInit] | |
>(); | |
public OnSetRemoteDescription = new Subject< | |
[string, RTCSessionDescriptionInit] |
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 { Subject } from "rxjs"; | |
import { RTCMessagingAgent } from "./rtc-messaging-agent"; | |
const configuration = { | |
iceServers: [ | |
{ | |
urls: [ | |
"stun:stun.l.google.com:19302", | |
"stun:stun1.l.google.com:19302", | |
"stun:stun2.l.google.com:19302", |
OlderNewer