Skip to content

Instantly share code, notes, and snippets.

@sebflipper
sebflipper / README.md
Last active Jul 16, 2020
Quickly and easily deploy an Eleventy Static Site to GitHub Pages with a custom domain
View README.md

Deploying an Eleventy Static Site to GitHub Pages with a custom domain

Quickly and easily deploy an Eleventy Static Site to GitHub Pages with an optional custom domain.

Setup

  1. Use or create a new Eleventy project and commit and push it to a GitHub repo.
  2. In the root folder of your Eleventy project create a new file deploy.sh and copy the contents into it and on the commandline run chmod +x deploy.sh
  3. Edit your package.json file adding "deploy": "./deploy.sh" into the bottom of the scripts: section.
@sebflipper
sebflipper / Dockerfile
Last active Jul 13, 2019
Docker Android build container
View Dockerfile
FROM openjdk:8-jdk-slim-stretch
SHELL ["/bin/bash", "-c"]
# Install build tools & newer version of cmake from Debian backports
RUN echo "deb http://deb.debian.org/debian stretch-backports main contrib non-free" >> /etc/apt/sources.list.d/backports.list \
&& apt-get update \
&& apt-get install -y \
build-essential \
bzip2 \
@sebflipper
sebflipper / autostart
Last active Oct 22, 2019
Auto start Raspberry Pi Chromium fullscreen from a list of bookmarks
View autostart
# /home/pi/.config/lxsession/LXDE-pi/autostart
@bash /home/pi/chromium-monitoring.sh
@sebflipper
sebflipper / .gitignore
Last active Jul 5, 2019
Concourse CI with a Windows worker
@sebflipper
sebflipper / raspberry-pi-cec-client.md
Created May 13, 2019
Using cec-client on a Raspberry Pi to control TV power and inputs via HDMI
View raspberry-pi-cec-client.md

Using cec-client on a Raspberry Pi

Most modern HDMI connected devices support Consumer Electronics Control (CEC). It allows devices to send commands to each other, typically to get the TV to switch input and control volume. If you have ever turned on a Game Console and had your TV automatically change input to that device you have seen CEC in action. It is very convenient and useful, sort of a universal remote that works.

Every manufacturer seems to have it’s own branding of CEC (e.g. Samsung Anynet+, LG SimpLink, Sharp Aquos Link) but it may need to be enabled. Check your manual for details.

Using a Raspberry Pi connected to a TV that supports CEC, you can use the command line cec-client application to control the inputs and the TV itself. These are notes on how to use cec-client and understand the different options.

Details

@sebflipper
sebflipper / sort-package-json.sh
Created Dec 4, 2018
Sorts dependencies in all `package.json` files in the current directory
View sort-package-json.sh
# yarn global add npm-sort
# find . ! -path "*node_modules*" -type f -name "package.json" -exec `pwd`/sort-package-json.sh "{}" \;
pushd `dirname $1` && npm-sort && sed -i '' -e '$a\' package.json && popd
@sebflipper
sebflipper / index.js
Last active Mar 25, 2020
Log all incoming HTTP and HTTPS requests
View index.js
const fs = require('fs');
const https = require('https');
const Koa = require('koa');
const multipartBodyParser = require('koa-body');
const app = new Koa();
app.use(
multipartBodyParser({
@sebflipper
sebflipper / index.js
Created Aug 1, 2017
Node Chrome Headless wait until element exists
View index.js
const chromeLauncher = require('chrome-launcher');
const CDP = require('chrome-remote-interface');
const sleep = require('sleep-async');
// Optional: set logging level of launcher to see its output.
// Install it using: yarn add lighthouse-logger
// const log = require('lighthouse-logger');
// log.setLevel('info');
/**
@sebflipper
sebflipper / wait-until-javascript-has-finished-executing.html
Last active Aug 1, 2017
Waits until JavaScript has finished executing (Hacky! Waits 500ms after other JavaScript processes have stopped modifying the DOM, so doesn't wait for other async events to finish like fetch)
View wait-until-javascript-has-finished-executing.html
<!-- Place before </body> -->
<script async defer type="text/javascript">
(function() {
if (window.addEventListener) {
window.addEventListener('load', loadHandler, false);
} else if (window.attachEvent) {
window.attachEvent('onload', loadHandler);
} else {
window.onload = loadHandler; // Or you may want to leave this off and just not support REALLY old browsers
}
View system-info.sh
#!/usr/bin/env bash
mem=$(free -m | grep Mem)
memAvaMb=$(echo $mem | awk '{print $2}')
memFreeMb=$(echo $mem | awk '{print $4}')
memPercentFree=$(free | grep Mem | awk '{print $4/$2 * 100.0}' OFMT="%3.1f%")
disk=$(df -h / | grep /)
diskTotal=$(echo $disk | awk '{print $2}')
diskUsed=$(echo $disk | awk '{print $3}')
You can’t perform that action at this time.