Skip to content

Instantly share code, notes, and snippets.

@cgmartin
cgmartin / vnc_install.sh
Last active January 29, 2024 00:16 — forked from x43x61x69/vnc_install.sh
Customized Steam Deck VNC Installation
#!/bin/bash
#
# Script for installing x11vnc on Steam Deck.
#
# Install:
#
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/cgmartin/26fc89f4887e4817e51a298eec937061/raw/vnc_install.sh?$RANDOM)"
#
# This will modify root filesystem so it will probably get
# overwrite on system updates but is totally ok executing
@cgmartin
cgmartin / vera_auth_test.sh
Last active March 22, 2023 19:43
Vera Auth Sessions Example
#!/bin/bash
set -e
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq but it's not installed (see: https://stedolan.github.io/jq/). Aborting."; exit 1; }
command -v curl >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed (see: https://curl.haxx.se/). Aborting."; exit 1; }
# Auth API Notes: http://forum.micasaverde.com/index.php/topic,24942.45.html
# New Server domains listing: http://forum.micasaverde.com/index.php/topic,25859.0.html
# Example implementations:
# https://github.com/rickbassham/vera/blob/master/vera_test.py
# https://github.com/amg0/ALTUI/blob/master/Remote/VeraloginAction.php
@cgmartin
cgmartin / RBLuaTest.lua
Last active September 28, 2021 08:02
RBLuaTest.lua Modifications (1.7) [Works in UI7 v1.7.3015]
module("RBLuaTest", package.seeall)
local version = "1.7"
local luadir = "/etc/cmh-ludl/"
--[[
LuaTest is a tool for testing Vera scene Lua code. It runs on Vera as an http handler.
Upload RBLuaTest.lua to Vera using APPS->Develop Apps->Luup files then restart Vera.
Enter following three lines into APPS->Develop Apps->Test Luup code (LUA) and click GO:
@cgmartin
cgmartin / le-aws-upload-cert.sh
Last active April 30, 2023 13:09
Scripts for manually creating Let's Encrypt certificates for AWS S3/CloudFront
#!/bin/bash
# Usage:
# $ le-aws-upload-cert.sh
echo "Current list of certificates in AWS"
echo "-----------------------------------"
aws iam list-server-certificates
echo
read -p "Domain name: " domain_name
@cgmartin
cgmartin / check-certs.sh
Created January 17, 2016 18:00
Bash SSL Certificate Expiration Check
#!/bin/bash
TARGET="mysite.example.net";
RECIPIENT="hostmaster@mysite.example.net";
DAYS=7;
echo "checking if $TARGET expires in less than $DAYS days";
expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \
| openssl x509 -text \
| grep 'Not After' \
|awk '{print $4,$5,$7}')" '+%s');
in7days=$(($(date +%s) + (86400*$DAYS)));
@cgmartin
cgmartin / users-router.js
Created November 12, 2015 04:04
node-cache-manager promisify example (w/ bluebird)
'use strict';
var express = require('express');
var usersApi = require('../lib/users-api');
var Promise = require('bluebird');
var cacheManager = require('cache-manager');
var cache = cacheManager.caching({store: 'memory', max: 100, ttl: 900});
Promise.promisifyAll(cache);
@cgmartin
cgmartin / README.md
Last active August 29, 2015 14:22 — forked from domenic/README.md
Node git pre-commit hook

Here's how this works:

  • Include a git-hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Ensure the files under the git-hooks/ directory are executable: chmod 755 git-hooks/*
  • Add test script to your package.json, e.g.
    "scripts": {
        "test": "mocha"
 }
@cgmartin
cgmartin / logging-middleware.js
Created May 24, 2015 01:43
Morgan JSON log format example
'use strict';
var morgan = require('morgan');
var os = require('os');
morgan.token('conversation-id', function getConversationId(req) {
return req.conversationId;
});
morgan.token('session-id', function getSessionId(req) {
return req.sessionId;
@cgmartin
cgmartin / all-in-one.js
Created March 12, 2015 18:43
Node Proxy Example
'use strict';
var port = parseInt(process.env.PROXY_PORT || process.env.PORT || 8000);
process.env.PROXY_PORT = port;
process.env.STATIC_PORT = port + 1;
process.env.API_PORT = port + 2;
process.env.CHAT_PORT = port + 3;
require('./proxy-server');
require('./static-server');
@cgmartin
cgmartin / gulpfile.js
Created February 8, 2015 21:03
Node ES6 istanbul, isparta, mocha-co gulpfile example
'use strict';
var gulp = require('gulp');
var del = require('del');
var mocha = require('gulp-mocha-co');
var istanbul = require('gulp-istanbul');
var isparta = require('isparta');
var coverageEnforcer = require('gulp-istanbul-enforcer');
var paths = {
server: {