Skip to content

Instantly share code, notes, and snippets.

@Coopeh
Coopeh / kill-session.sh
Last active December 22, 2021 19:41
SSH Idle Session Kicker
#!/usr/bin/env bash
###
#
# SSH Inactive Session Killer
#
###
# Set idle time in hours - default is 12
idle_time="12"
@PattaFeuFeu
PattaFeuFeu / HA_Migrate-sqlite-to-mysql.md
Last active May 27, 2024 20:49
Steps necessary to migrate from HomeAssistant’s standard sqlite database to an external MariaDB(10) SQL database

Migrate Home Assistant’s sqlite database to MySQL, specifically MariaDB (10)

After having added a decent amount of entities to my Home Assistant setup, the user interface—especially the history tab, but also the history for each entity—became very sluggish. Having to wait for up to 30 seconds to see the history graph for a single entity became the norm with an sqlite file weighing in at 6GB and millions of entries in the “events” and “states” tables.

I wanted to keep my acquired data, so I had to migrate it from the current sqlite file to a MySQL database instead of starting anew. I’ve done this using Home Assistant version 0.81 and MariaDB 10. Some parts might change in the future.

Dump Home Assistant sqlite database

@mitchellrj
mitchellrj / export_single_slack_channel.py
Last active January 4, 2019 10:44
Export history from a single Slack channel
#!/usr/bin/env python3
import csv
import datetime
import getpass
import os
import re
import sys
import time
@lwakefield
lwakefield / tabcomplete.vim
Last active January 23, 2018 21:12
tabcomplete
inoremap <expr> <tab> pumvisible() ? '<c-n>' : '<tab>'
inoremap <expr> <s-tab> pumvisible() ? '<c-p>' : '<tab>'
augroup autocomplete
autocmd!
autocmd TextChangedI * call TypeComplete()
augroup end
fun! TypeComplete()
if getline('.')[col('.') - 2] =~ '\K' && getline('.')[col('.') - 1] !~ '\K'
call feedkeys("\<c-n>")
end
@tmaiaroto
tmaiaroto / Dockerfile
Last active June 30, 2022 08:48
WordPress on Amazon ECS
FROM alpine:3.3
MAINTAINER Tom Maiaroto <tom@outdoorsy.co>
# Install packages
RUN apk --update --repository http://dl-3.alpinelinux.org/alpine/edge/main add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \
@jgrahamc
jgrahamc / index.php
Last active June 18, 2020 09:38
Demonstrating how to use Link headers to make CloudFlare push assets
<?php
function ccbysa($imagehtml, $sourceuri, $owneruri, $ownername) {
return <<<HTML
{$imagehtml}
<br/>
<small><a href="https://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>
<a href="{$sourceuri}">image</a> by <a href="{$owneruri}">{$ownername}</a>
<br/>
HTML;
@luketurcotte
luketurcotte / Love iTunes Track
Created July 1, 2015 23:15
Simple Applescript to "Love" the currently playing track in iTunes 12.2+.
tell application "System Events"
if (name of processes) contains "iTunes" then
set iTunesRunning to true
else
set iTunesRunning to false
end if
end tell
if iTunesRunning then
tell application "iTunes"
@sn0opy
sn0opy / php.ini
Created April 7, 2014 22:20
hhvm 3.x php.ini
hhvm.server.type = fastcgi
hhvm.server.file_socket = /run/shm/hhvm.sock
hhvm.server.apc.enable_apc = true
hhvm.server.apc.table_type = concurrent
hhvm.server.apc.expire_on_sets = true
hhvm.server.apc.purge_frequency = 4096
hhvm.eval.jit = true
hhvm.eval.jit_warmup_requests = 50
@sr75
sr75 / wildcard-ssl-cert-for-testing-nginx-conf.md
Created June 1, 2013 18:35
create a self signed wildcard ssl cert for testing with nginx.conf example

just change out app_name for your purposes

openssl genrsa 2048 > app_name-wildcard.key

openssl req -new -x509 -nodes -sha1 -days 3650 -key app_name-wildcard.key > app_name-wildcard.cert

# Common Name (eg, your name or your server's hostname) []:*.app_name.com

openssl x509 -noout -fingerprint -text &lt; app_name-wildcard.cert &gt; app_name-wildcard.info
@killercup
killercup / config.fish
Last active April 12, 2022 03:43
Server Config with fish, vim an tmux
# ~/.config/fish/config.fish
. ~/.config/fish/fish_prompt.fish
set fish_greeting '' # turn off greeting
function fish_title;end
alias vi 'vim'