Skip to content

Instantly share code, notes, and snippets.

@abraithwaite
abraithwaite / restic-backup.conf
Last active January 27, 2024 13:14
Automated Restic Backups with CPU+Memory throttling, inspired by: https://fedoramagazine.org/automate-backups-with-restic-and-systemd/
B2_ACCOUNT_ID=XXXXXXXXXXXXXXXXXXXXXXXXX
B2_ACCOUNT_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RESTIC_REPOSITORY=b2:XXXXXXXXXXXXXXXXXX:/
RESTIC_PASSWORD=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BACKUP_PATHS="/home/naomi.nagata"
BACKUP_EXCLUDES="--exclude-file /home/rupert/.restic_excludes --exclude-if-present .exclude_from_backup"
RETENTION_DAYS=7
RETENTION_WEEKS=4
@prwhite
prwhite / Makefile
Last active May 16, 2024 05:50
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
@vladimir-e
vladimir-e / support_cyrillic.sh
Created December 11, 2013 03:41
Support cyrillic / russian input in rails console and IRB
$ brew install openssl readline
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p353
#########################################################################################
# Manage websites
class Dashboard::WebsitesController < ApplicationController
before_action :find_website, only: %w(show edit update destroy)
def index
@websites = current_user.websites
end
@amolpujari
amolpujari / ox_parsing.rb
Last active September 22, 2018 17:49
example of parsing large xml files in ruby using ox, define a handler, look up for a particular root element
require "awesome_print"
module XmlParsing
require "ox"
class Reader < ::Ox::Sax
def initialize file_path, target, target_handler
@target_handler = target_handler
@target = target
@file_path = file_path
@JamesDullaghan
JamesDullaghan / digitalocean.md
Created July 6, 2013 20:54
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@petehamilton
petehamilton / are_exam_results_up_yet.sh
Last active December 19, 2015 07:09
Are exams results online yet?
#!/bin/bash
EXAMS_URL="https://exams.doc.ic.ac.uk/"
echo "##############################################"
echo "# Exam Results Checker"
echo "##############################################"
echo -ne "Username: "
read username
stty -echo
@FerPerales
FerPerales / pre-push.sh
Last active December 18, 2015 11:19
pre-push
#!/bin/sh
# This pre-push hook will run 'rake' command to check if your test
# suite passes by looking for ', 0 failures' in the 'rake' output
# If found, will return exit and the git push command will continue
# Make sure you remove the .sh extension and put the hook into your
# .git/hooks directory in your project
# --------------------------------------------------------------------
@FerPerales
FerPerales / pre-commit.sh
Last active October 27, 2016 14:27
A git hook to help you avoid adding to you commit information you don't want (i.e. debugging statement)
# This script verifies if a list of "undesired" words are presented in the files you are intented to commit such console
# output, debugging information or keys/tokens/passwords
# Based on the git hook created by Mark Story
# http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
# Instructions:
# Put this file into your .git/hooks folder and remove the .sh extension
@nu7hatch
nu7hatch / _utils.bash
Created April 15, 2013 04:44
Utilities for setup scripts.
# _utils.sh --- Utilities used across all the scripts.
set -e
set -o pipefail
# Prints spaces as a prefix to the command's output.
function prefixed {
sed -e "s/^/ /"
}