Skip to content

Instantly share code, notes, and snippets.

@ganey
ganey / chrome_json_prettyprint_bookmark_url.js
Created April 27, 2023 11:03
Chrome JSON pretty print bookmark
javascript:(
document.querySelector('body>pre').innerText=JSON.stringify(
JSON.parse(document.querySelector('body>pre').innerText),
null,
' '
)
)()
@ganey
ganey / @ BroadcastChannel Polyfill.md
Created February 28, 2022 16:26 — forked from sechel/@ BroadcastChannel Polyfill.md
BroadcastChannel Polyfill

BroadcastChannel Polyfill

BroadcastChannel is a new communication API proposed in the HTML Standard but not yet widely implemented. It allows messages to be sent to all other BroadcastChannel instances sharing the same channel name within the same browsing context and origin.

var bc = new BroadcastChannel('name');

bc.postMessage(payload);
@ganey
ganey / crypto-aes-gcm.js
Created May 6, 2021 15:51 — forked from chrisveness/crypto-aes-gcm.js
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@ganey
ganey / bootstrap.php
Created March 2, 2021 15:02
CraftCMS 2 craft/app/tests/bootstrap.php
<?php
/**
* Craft by Pixel & Tonic
*
* @package Craft
* @author Pixel & Tonic, Inc.
* @copyright Copyright (c) 2014, Pixel & Tonic, Inc.
* @license http://buildwithcraft.com/license Craft License Agreement
* @link http://buildwithcraft.com
@ganey
ganey / electricity_price_blueprint.yaml
Last active January 17, 2021 12:48
Electricity Price HomeAssistant BluePrint
blueprint:
name: Electricity Price Blueprint
description: Call Service based on electricity price
domain: automation
input:
price_sensor:
name: Price Sensor
description: This sensor will be checked for price.
limit_number:
name: Max Price
@ganey
ganey / cpmigrate-os.sh
Created August 9, 2020 08:01
cPanel copy OS source files from old to new server
#!/bin/sh
rsync -vrplogDtH -e ssh /home/* USER@SE.RV.ER.IP:/home
rsync -vrplogDtH -e ssh /usr/local/cpanel USER@SE.RV.ER.IP:/usr/local
rsync -vrplogDtH -e ssh /var/lib/mysql USER@SE.RV.ER.IP:/var/lib
rsync -vrplogDtH -e ssh /var/cpanel USER@SE.RV.ER.IP:/var
rsync -vrplogDtH -e ssh /usr/share/ssl USER@SE.RV.ER.IP:/usr/share
rsync -vrplogDtH -e ssh /var/ssl USER@SE.RV.ER.IP:/var
rsync -vrplogDtH -e ssh /usr/local/cpanel/3rdparty/mailman USER@SE.RV.ER.IP:/usr/local/cpanel/3rdparty
rsync -vrplogDtH -e ssh /var/log/bandwidth USER@SE.RV.ER.IP:/var/log
@ganey
ganey / cpadduser.sh
Created August 9, 2020 07:53
Create cPanel account script - useful when manually restoring accounts
#!/bin/bash
# DEF$1 is the password, so for user cake, the password would become DEFcake.
# To manually add passwords when running the script, change DEF$1 to $2.
et -u
if [ "$1" = "-help" ]
then
echo "Use: ./cpadduser.sh username"
else
@ganey
ganey / reset-valet.sh
Created May 19, 2020 19:48
valet reset mac
valet uninstall
composer global remove laravel/valet
brew uninstall --force php@7.3
brew uninstall --force php@7.2
brew uninstall --force php@7.1
brew uninstall --force php nginx dnsmasq
brew upgrade
brew install php
composer global require laravel/valet
valet install
@ganey
ganey / after.sh
Last active May 5, 2020 10:23
Homestead use nginx & apache, both nginx apache proxy same homestead.yaml
#!/bin/sh
# By default, nginx & apache both use port 80/443 so can't run at the same time
# apache services will be updated, port 80 to 3888 and 443 to 3444
# nginx will proxy all requests by default over to apache ports
# nginx will also use ssl certs for each apache site via the 0-default_server config using the $ssl_server_name
# no homestead.yaml changes should be required for the nginx catch-all proxy to work
# This will also allow you to use nginx as a proxy to pm2 / node services via Homestead.yaml
# check nginx version
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";