Skip to content

Instantly share code, notes, and snippets.

View richrd's full-sized avatar

Richard Lewis richrd

View GitHub Profile
@eklex
eklex / 80-mount-usb-to-media-by-label.rules
Last active May 13, 2024 19:49
udev rule for Home Assistant OS (hassio) to mount USB drives into the Supervisor Media directory
#
# udev rule
# Mount USB drive to the media directory using the partition name as mount point
#
# Description:
# Created for Home Assistant OS, this rule mounts any USB drives
# into the Hassio media directory (/mnt/data/supervisor/media).
# When a USB drive is connected to the board, the rule creates one directory
# per partition under the media directory. The newly created partition is named
# as the partition name. If the partition does not have a name, then the following
@albertnis
albertnis / bedside_button.yaml
Created February 17, 2020 07:07
Making a custom multi-click push button using ESPHome
esphome:
name: bedside_button
platform: ESP8266
board: esp12e
wifi:
ssid: "ssid"
password: "example"
logger:
@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@sinclairtarget
sinclairtarget / bernoulli.c
Created August 17, 2018 20:22
Lovelace's Note G Program in C
#include <stdio.h>
/*
* Calculates what Ada Lovelace labeled "B7", which today we would call the 8th
* Bernoulli number.
*/
int main(int argc, char* argv[])
{
// ------------------------------------------------------------------------
// Data
@EWouters
EWouters / install_pivpn.sh
Created July 5, 2018 01:25
Example unattended pivpn install
do_install_pivpn() {
#curl -L https://install.pivpn.io | bash
setupVars=/etc/pivpn/setupVars.conf
if [ -e "${setupVars}" ]; then
sed -i.update.bak '/pivpnUser/d;/UNATTUPG/d;/pivpnInterface/d;/IPv4dns/d;/IPv4addr/d;/IPv4gw/d;/pivpnProto/d;/PORT/d;/ENCRYPT/d;/DOWNLOAD_DH_PARAM/d;/PUBLICDNS/d;/OVPNDNS1/d;/OVPNDNS2/d;/SERVER_NAME/d;' "${setupVars}"
else
mkdir -p /etc/pivpn
touch "${setupVars}"
fi
@takumiirie
takumiirie / spreadsheet_conditional-formatting1.txt
Created January 26, 2018 08:53
Google Spreadsheet - Regex with Conditional Formatting
# set "Apply to range" to whereever you want to apply setting.
# set "Format cells if..." to "Custom formula is" and paste following code
# Following Forumula will detect if it's match with regex or not.
=REGEXMATCH(INDIRECT("R[0]C[0]", false),"<PUT YOUR REGEX HERE>") = true
# set your "formatting style"
That's it!
function isFirefox(client) {
return client.resourceName == "navigator" && client.resourceClass == "firefox";
}
function onClientMaximizedStateChanged(client, h, v) {
if (h && v) {
client.noBorder = true;
} else {
client.noBorder = false;
function Foo(value) {
this.value = value;
}
Foo.prototype.bar = function () {
function someCall() {
return this.value;
}
const anotherCall = () => {
@bigsergey
bigsergey / review-checklist.md
Last active May 23, 2024 13:50
Front-end Code Review Checklist

Review checklist

General

  1. Does the code work?
  2. Description of the project status is included.
  3. Code is easily understand.
  4. Code is written following the coding standarts/guidelines (React in our case).
  5. Code is in sync with existing code patterns/technologies.
  6. DRY. Is the same code duplicated more than twice?