Skip to content

Instantly share code, notes, and snippets.

View SketchingDev's full-sized avatar

Lucas SketchingDev

View GitHub Profile
@SketchingDev
SketchingDev / Browser MediaStreams API Mocking.md
Last active June 19, 2025 10:28
Mocking a browser's MediaStreams API so you can play multiple audio files

Mocking a browser's MediaStreams API

This script is used by Puppeteer tests to be able to mock a browser's MediaStreams API allowing you to play multiple audio files.

The script is necessary as the Chrome flag --use-file-for-fake-audio-capture will only allow one audio file to be chosen, and you have no control over when it will be played.

await webRtcFrame.evaluate(mockMediaDevicesScript);
webRtcFrame.evaluate(() => window.mockMediaDevice.playAudio(/* URL */));
@SketchingDev
SketchingDev / Genesys Softphone Page Object Model.md
Last active October 23, 2024 06:54
Genesys WebRTC Softphone Page Object Model

Genesys WebRTC Softphone Page Object Model

This POM simplifies the process of interacting with Genesys's WebRTC Softphone's UI when working with testing tools like Puppeteer. It was created to serve my use-case that I posted about but can easily be extended.

Usage example:

const softphone = await webRtcSoftphone(frame);
const audioInput = await softphone.getAudioInputFromWebRtcSettings();
console.log(`Audio Input: ${audioInput}`);
@SketchingDev
SketchingDev / jrnl-save.sh
Created March 31, 2018 11:47
Bash function for saving commands and their output to jrnl (http://jrnl.sh/)
#!/bin/bash
# Save commands/output to jrnl - the command line journal
# 1. Install jrnl (http://jrnl.sh/)
# 2. Reference this file, or copy the function, into your bash profile
function save(){
SAVE_COMMAND=$(echo "$@")
SAVE_OUTPUT=$($@)
echo "$SAVE_OUTPUT"
echo -e "$SAVE_COMMAND\n$SAVE_OUTPUT\n@terminal" | jrnl
@SketchingDev
SketchingDev / DataUri.php
Created December 2, 2017 14:02
A convenient class for working with Data URIs in PHP
<?php
/* The MIT License (MIT)
* Copyright (c) 2015 FlyingTopHat (lucas@flyingtophat.co.uk)
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all