Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bfg100k
bfg100k / snapRAID_helper.sh
Last active January 26, 2024 20:22
Bash helper script to help with the automation of routine snapRAID tasks. Add it as a cron job to automate the routine tasks of running sync and scrub. Script will optionally send you email of status and issues encountered during the run.
#!/bin/bash
#######################################################################
# This is a helper script that keeps snapraid parity info in sync with
# your data and optionally verifies the parity info. Here's how it works:
# 1) It first calls diff to figure out if the parity info is out of sync.
# 2) If parity info is out of sync, AND the number of deleted files exceed
# X (configurable), it triggers an alert email and stops. (In case of
# accidental deletions, you have the opportunity to recover them from
# the existing parity info)
# 3) If partiy info is out of sync, AND the number of deleted files exceed X
for i in `hg branches |grep -v 'default' |grep -v 'develop' |grep inactive |awk 'NF>1{print $(NF-1)}'`; do hg update -r "$i" && hg commit -m "Closed branch" --close-branch; done
@kchida
kchida / gist:d1c15f3968f4f8272c49
Created July 17, 2014 05:06
etcd vs consul vs ???
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
@morkevicius
morkevicius / gist:10549920
Last active July 13, 2016 21:54 — forked from chancancode/gist:2830878
.net ticks to ruby time, ruby time to ticks 1.8.7
class Time
# See http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx
# https://gist.github.com/chancancode/2830878
TICKS_SINCE_EPOCH = -(Time.utc(0001, 01, 01).to_i * 10000000)
def to_ticks
utc.to_i * 10000000 + TICKS_SINCE_EPOCH # ruby 1.8.7 doesn't support nano seconds so we're ok without it
# to_i * 10000000 + nsec / 100 - TICKS_SINCE_EPOCH
# <seconds from 1970-01-01 multiplied by 10 000 000> result is ticks + <self nsec which by default would be skipped>/100 result is ticks + ticks from 0001-01-01
end
@Thermionix
Thermionix / auth-basic.conf
Last active November 4, 2021 00:56
nginx reverse proxy for sickbeard, couchpotato etc.
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active March 31, 2024 18:45 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@kagemusha
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@pgriess
pgriess / demo.py
Created December 19, 2011 01:12
Script to stream audio from Rdio
#!/bin/env python
#
# Demo tool to generate the rtmpdump(1) command for streaming a song from Rdio.
import httplib
from optparse import OptionParser
from os.path import basename
from pprint import pprint
from pyamf.remoting.client import RemotingService
from rdioapi import Rdio
@tlrobinson
tlrobinson / google-translate-drums.js
Created November 30, 2010 06:19
A drum machine for the German Google Translate. See instructions in comments below.
(function() {
// Notes from http://news.ycombinator.com/item?id=1952531
var notes = {
"suspended cymbal":"zk",
"snare":"bschk",
"brush":"pv",
"bass":"bk",
"flam1":"tk",
"roll tap":"vk",
"flam2":"kt",
@fcalderan
fcalderan / inception-javascript.js
Created November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");