Skip to content

Instantly share code, notes, and snippets.

View wlkns's full-sized avatar

JW wlkns

View GitHub Profile
@erikvullings
erikvullings / utils.ts
Last active September 22, 2022 08:51
Utility functions
/* A list of useful functions snippets */
/**
* Create a GUID
* @see https://stackoverflow.com/a/2117523/319711
*
* @returns RFC4122 version 4 compliant GUID
*/
export const uuid4 = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
@DepthDeluxe
DepthDeluxe / restic-backup.sh
Last active September 1, 2021 20:33
Restic Cron Script
#!/bin/bash
# Adapted from https://github.com/erikw/restic-systemd-automatic-backup/blob/master/usr/local/sbin/restic_backup.sh
set -e -o pipefail
export PATH="/bin:/usr/bin:/usr/local/bin"
RESTIC="/usr/local/bin/restic"
RESTIC_ENV="${HOME}/.restic.env"
BACKUP_TAG='cron'
@nfsarmento
nfsarmento / nginx-wordpress.conf
Last active July 6, 2024 20:26
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@skrajewski
skrajewski / backup.sh
Last active December 19, 2023 14:54
Automate your macOS backup to Backblaze B2 using Restic and launchd.
#!/bin/bash
PID_FILE=~/.restic_backup.pid
TIMESTAMP_FILE=~/.restic_backup_timestamp
if [ -f "$PID_FILE" ]; then
if ps -p $(cat $PID_FILE) > /dev/null; then
echo $(date +"%Y-%m-%d %T") "File $PID_FILE exist. Probably backup is already in progress."
exit 1
else
@hickinbottoms
hickinbottoms / restic-snapshot-exporter.sh
Last active September 1, 2021 20:33
Prometheus exporter for restic snapshot age
#!/bin/bash
# get current time to be used to compute age
NOW_SECONDS=$(date '+%s')
JSONDIR="/var/lib/restic-snapshot-dump"
PROMDIR="/var/lib/node_exporter"
# following will be replaced with actual restic snapshots command
for JSONFILE in "${JSONDIR}"/*.json; do
@jeetsukumaran
jeetsukumaran / bu
Last active August 30, 2022 20:32
Script to drive Restic
#!/usr/bin/env bash
#
# bu: Backup data to repository.
#
# Type 'bu --help' for help on actions and options.
#
# Configuration of 'bu' is done via environmental variables which can be set by user
# in a particular session or saved to a file and read by 'bu'.
#
# Examples of backup configuration files:
@natemoo-re
natemoo-re / README.md
Last active June 24, 2024 09:21
Visual Studio Code Snippets – Common Case Transformations

Common Case Transformation Snippets

Visual Studio Code allows Snippets to perform ✨Variable Transforms✨ using Regex.

Here are some common case transformations that you can apply to your snippets. In these examples, I'm using $TM_FILENAME_BASE, but the same transformations should apply to any of the Snippet Variables.

snippets-from-delimited.json can convert filenames like my-file-name, my_file_name, my file name. If your filename is delimited by a dash, underscore, or space, these should work.

snippets-from-mixed-case.json can convert filenames like myFileName and MyFileName. If your filename is in camel or Pascal case, these should work.

@grisha87
grisha87 / purge.php
Last active July 27, 2022 12:16
PHP.Kryptik.AB removal script
<?php
/**
* PHP.Kryptik.AB Cleanup script
*
* Usage: place the script in same directory that contains files / directories
* to be scanned. Then run `php [script_name].php` and wait a bit
*
* @link http://blog.twelvecode.com
* @author Grzegorz Godlewski <grisha87@gmail.com>