Skip to content

Instantly share code, notes, and snippets.

@BradGunnerSGT
BradGunnerSGT / main-prod inventory
Last active January 11, 2020 22:57
Ansible instance-environment example:
In order to minimize slip-ups, we have a different inventory file for
each instance-environment pair, and each inventory uses a different
group name as well. Then there are group-vars files for each
instance-environment pair that set a variable so the proper playbooks
get run.
For example, here is how we have the project laid out:
site.yml
inventory/
main-prod
@mllg
mllg / Tmpwatch
Last active March 19, 2021 04:16
Utility vim function to clean up vim's undo files (or others).
function Tmpwatch(path, days)
let l:path = expand(a:path)
if isdirectory(l:path)
for file in split(globpath(l:path, "*"), "\n")
if localtime() > getftime(file) + 86400 * a:days && delete(file) != 0
echo "Tmpwatch(): Error deleting '" . file . "'"
endif
endfor
else
echo "Tmpwatch(): Directory '" . l:path . "' not found"
@kyokley
kyokley / syntax.md
Last active September 2, 2021 12:47
Preventing saving for various errors in VIM

Preventing saving for various errors in VIM (Buffer Pre-write Hook Part 2)

Introduction

This is a continuation of my buffer pre-write hook series. Check out the previous gist to follow the progression.

Have you ever tried running a file only to be stopped by "<<<<<<<"?

Wouldn't it be nice to be able to automatically run your code through pyflakes before actually saving it? Maybe even raise an error for showstopping bugs in your code?

@skybldev
skybldev / lqr.sh
Last active March 20, 2022 16:39
A script that content-aware-scales (or seam carves) a video.
#!/usr/bin/env bash
inputFile=$1 # input file
outputFile=$2 # output file
outputRes=$3 # output resolution in WIDTHxHEIGHT
fps=$4 # fps for both input and output
useLeftoverFrames=0 # whether or not to process already split frames
# create temp dir if it doesn't exist yet
if [[ ! -d ".lqrtemp/" ]]; then
echo ":: Creating temporary directory .lqrtemp/..."
@Hakky54
Hakky54 / cheat_sheet_http_client_ssl_configuration_for_java_kotlin_scala.md
Last active August 18, 2022 11:56
Cheat Sheet - Http Client SSL TLS Configuration for Java Kotlin and Scala with example http requests
@g0xA52A2A
g0xA52A2A / Vim_autoreply.md
Last active June 4, 2023 23:30
Vim autoreply

A modified version of Romain's gist.

See prior revisions for functionality closer to the original. This is now a simplification that aims only to provide prompts that would typically follow basic commands.

function! ExpandCommand(pattern) abort
  let aliases =
 \ { 'cn' : 'cnext'
@kristoferjoseph
kristoferjoseph / single-file-web-component.html
Last active November 22, 2023 01:17
Single file Web Component
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Single File Web Component</title>
</head>
<body>
<template id=single-file>
<style>
h1 {
@Checksum
Checksum / assert.jq
Last active December 29, 2023 17:09
Assertion library for jq
# A simple assertion library for jq (https://github.com/stedolan/jq)
# Author: Srinath Sankar
def assert(level; expr; msg):
if expr then
.
else
. |= . + [{ level: level, message: msg }]
end;
@SQLadmin
SQLadmin / xtrabackup_full_increment_restore.sh
Last active March 15, 2024 17:34
Automate xtrabackup for FULL/Incremental and restore
#!/bin/bash
# This is my production backup script.
# https://sqlgossip.com
set -e
set -u
usage() {
echo "usage: $(basename $0) [option]"
echo "option=full: Perform Full Backup"
@michalc
michalc / sqlite.py
Last active April 3, 2024 17:26
Use libsqlite3 directly from Python with ctypes: without using the built-in sqlite3 Python package, and without compiling anything
# From https://stackoverflow.com/a/68876046/1319998, which is itself inspired by https://stackoverflow.com/a/68814418/1319998
from contextlib import contextmanager
from collections import namedtuple
from ctypes import cdll, byref, string_at, c_char_p, c_int, c_double, c_int64, c_void_p
from ctypes.util import find_library
from sys import platform
def query(db_file, sql, params=()):