Skip to content

Instantly share code, notes, and snippets.

@sechel
sechel / @ BroadcastChannel Polyfill.md
Created September 13, 2018 15:47
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);
@Everlanders
Everlanders / LightMonitor.py
Created March 13, 2018 14:47
Headlight and Reverse Lights monitor for YouTube Commenters - UNTESTED but should work fine.
#!/usr/bin/python
# A quick hack of my button monitor script to monitor headlights and reverse lights to
# Dim the screen and switch to the reverse camera.
# I have not tested this...
# Remember, the switch or opto is switching to ground, so the logic is inverted... 0 = on 1 = off
# Also, you would run only one of these "Monitor" scripts. you can't be running RearviewMonitor.py AND LightMonitor.py
import RPi.GPIO as GPIO
import time
import subprocess, os
@Everlanders
Everlanders / backlight.sh
Created March 6, 2018 15:16
Script to Change the Backlight brightness on the Official Raspberry Pi 7" display.
#!/bin/bash
level=$1
#echo "level given is $level"
if [ $# != 1 ]; then
echo "USAGE: $0 brightness_level (0 to 255)"
exit 1
fi
@Everlanders
Everlanders / ButtonMonitor.py
Last active May 8, 2024 05:09
Python Script to monitor GPIO button presses and call the Camera and Backlight.
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess, os
import signal
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
RearView_Switch = 14 # pin 18
Brightness_Switch = 15 # pin 16
@codinronan
codinronan / InputMask.html
Last active October 26, 2018 23:44 — forked from JoeMeeks/InputMask.html
Custom Ionic 2 & 3 Input Mask Directive
<ion-input type="tel" pattern="\d*" placeholder="(xxx) xxx-xxxx" mask="(***) ***-****" [(ngModel)]="phone" name="phone"></ion-input>
<ion-input type="tel" pattern="\d*" placeholder="xxx-xx-xxxx" mask="***-**-****" [(ngModel)]="ssn" name="ssn"></ion-input>
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active July 11, 2024 21:59
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 / deflate.conf
Last active November 15, 2017 11:21
Plesk enable mod_deflate 11.5+
# file: /etc/httpd/conf.d/deflate.conf
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
DeflateCompressionLevel 8
</ifmodule>
# or set in Additional nginx directives per site:
gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
@ganey
ganey / .htaccess
Last active December 20, 2016 15:25
Compression for htaccess
## Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
## Fix other types
AddType text/javascript .js
AddType text/css .css
@vjandrea
vjandrea / phpversion.sh
Last active June 19, 2023 20:44
Change php cli version in plesk
#!/bin/sh
printf "Switching php to version 5.6 with symlinks.\n"
printf "Press any key to continue...\n"
read CONTINUE
printf "Creating backups..."
# Backup original binaries