Skip to content

Instantly share code, notes, and snippets.

View thomasjsn's full-sized avatar

Thomas Jensen thomasjsn

View GitHub Profile
@thomasjsn
thomasjsn / apt_updates.conf
Created January 13, 2018 22:15
Zabbix APT updates user parameters
UnsafeUserParameters=1
Timeout=10
UserParameter=apt.available.updates,updates=$(/usr/lib/update-notifier/apt-check 2>&1);echo $updates | cut -d ";" -f 1
UserParameter=apt.security.updates,updates=$(/usr/lib/update-notifier/apt-check 2>&1);echo $updates | cut -d ";" -f 2
@thomasjsn
thomasjsn / hass-fireman-alarm-mqtt-gzl.yaml
Last active September 5, 2017 11:06
Home Assistant configuration for fireman alarm toy
switch:
- platform: mqtt
name: "Firealarm strobe"
state_topic: "node/gzl/strobe"
command_topic: "node/gzl/strobe/set"
payload_off: 0
payload_on: 1
- platform: mqtt
name: "Firealarm buzzer"
state_topic: "node/gzl/buzzer"
@thomasjsn
thomasjsn / ElasticRecreateIndex.php
Created February 13, 2017 09:26
Laravel console command for reindexing Elasticsearch.
<?php
namespace App\Console\Commands;
use Elasticsearch\ClientBuilder;
use Illuminate\Console\Command;
class ElasticRecreateIndex extends Command
{
/**
@thomasjsn
thomasjsn / fail2ban-sshd.conf
Last active August 9, 2016 12:48
SSH jail with some additional conditions for fail2ban.
# Fail2Ban filter for openssh
#
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
@thomasjsn
thomasjsn / s3cmd-syntax.sh
Last active August 5, 2016 21:32
A reminder for some common s3cmd syntax.
# Sync folders, follow symlinks, don't store FS attributes
s3cmd sync -F --no-preserve origin/ s3://bucket/
# Sync folders recursivly, delete remote objects with no corresponding local file
s3cmd sync -r --delete-removed assets/ s3://bucket/assets/
# Add header to single file on bucket
s3cmd modify -r --add-header=Cache-Control:max-age=0 s3://bucket/index.html
# Remove header from all files in folder (or on bucket)
@thomasjsn
thomasjsn / nginx-microcache.conf
Created August 4, 2016 18:35
Configuration for microcaching on nginx.
# Setup var defaults
set $no_cache "";
# If non GET/HEAD, don't cache & mark user as uncacheable for X second(s) via cookie
if ($request_method !~ ^(GET|HEAD)$) {
set $no_cache "1";
}
# Drop no cache cookie if need be (for some reason, add_header fails if included in prior if-block)
if ($no_cache = "1") {
@thomasjsn
thomasjsn / export-sql.sh
Last active August 4, 2016 18:30
Export all databases that the user can access, then sync the sql files to a s3 bucket.
#!/bin/bash
USER="backup"
PASSWORD="password"
OUTPUT="/output/folder"
BUCKET="backup-bucket"
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
@thomasjsn
thomasjsn / laravel-queue.service
Last active April 26, 2024 09:34
Laravel queue worker using systemd.
# Laravel queue worker using systemd
# ----------------------------------
#
# /lib/systemd/system/queue.service
#
# run this command to enable service:
# systemctl enable queue.service
[Unit]
Description=Laravel queue worker