Skip to content

Instantly share code, notes, and snippets.

@teamradhq
teamradhq / app-GreetCommand.php
Last active January 26, 2024 07:13
Non Framework Console Commands
<?php
namespace App;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@teamradhq
teamradhq / README.md
Last active November 22, 2021 02:50
Uninstall Native Instruments Plugin on Mac
@teamradhq
teamradhq / check-found-sound-products.js
Last active February 25, 2021 04:32
When an online shop doesn't have wish list functionality :)
#!/usr/bin/env node
const { execSync } = require('child_process');
/**
* I wrote this script so I don't have to keep checking for product availability
* on a site that doesn't have a wish list feature.
*
* Just setup a daily cron that calls {checkFoundSoundProducts} function with a
* set of product ids and log output if there are any available.
*
@teamradhq
teamradhq / primeThePump.js
Created February 23, 2021 13:04
Reading book 3 of Dark Tower series and couldn't solve the other riddles... but this one ;)
/**
* Check for obvious cases, then check for
* factors up to square root of {n}.
*
* @param {number} n
*
* @return {boolean}
*/
const isPrime = (n) => {
if (n < 1 || n !== Number.parseInt(n, 10)) {
@teamradhq
teamradhq / copyToClipboard-transpiled.js
Last active May 10, 2019 07:48
Copy to Clipboard Transpiled
var copyToClipboard = function copyToClipboard(str) {
var el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
var selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
el.select();
document.execCommand('copy');
const copyToClipboard = (() => {
const el = document.createElement('textarea');
/* Setup our textarea and add to DOM */
el.setAttribute('readonly', '');
el.style.display = 'none';
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
/* Return our copy function */
return (str) => {
/** Set sessionStorage {key} value to {val}. */
const set = (key, val) => sessionStorage.setItem(key, val);
/** Get {key} from sessionStorage. */
const get = key => sessionStorage.getItem(key);
/** Remove all {keys} from sessionStorage. */
const remove = (...keys) => keys
.forEach((key) => sessionStorage.removeItem(key));
constructor() {
if (!this.search && this.page <= (minPage || 1)) {
this.start();
return;
}
this.continue();
}
start() {
this.reset();
this.search = prompt('Enter a title to search for:');
if (!!this.search) {
this.goTo(this.lastPage);
}
}
checkForMatches() {
return [...document.querySelectorAll('.bucket-item.track')]
.filter((el) => this.elementMatches(el));
}