Skip to content

Instantly share code, notes, and snippets.

@jclement
jclement / gist:8caf5bfe1fb9df95994f
Created September 17, 2015 21:58
Find files older than 30 days show details and sort by size
find /home/sftp -type f -mtime +30 -exec ls -s {} \; | sort -n -r
### Keybase proof
I hereby claim:
* I am jclement on github.
* I am jsc (https://keybase.io/jsc) on keybase.
* I have a public key whose fingerprint is 6B42 6A57 875A E6A7 C910 EF91 4378 F71A B4EA 336E
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am jclement on github.
  • I am jsc (https://keybase.io/jsc) on keybase.
  • I have a public key whose fingerprint is 382A B517 8749 3ACD 7DFA CD6F 44EA FEE7 C51B 2CA8

To claim this, I am signing this object:

@jclement
jclement / blink.js
Created July 17, 2014 16:37
Blink(1) when there are outstanding RTDs
var express = require('express');
var router = express.Router();
var redis = require('redis').createClient();
var twilio = require('twilio');
/* GET home page. */
router.get('/', function(req, res) {
res.render('index', { title: 'Express' });
});

Keybase proof

I hereby claim:

  • I am jclement on github.
  • I am jsc (https://keybase.io/jsc) on keybase.
  • I have a public key whose fingerprint is 756B 89B5 9420 424C 5027 1924 120C 8032 A55D 0402

To claim this, I am signing this object:

@jclement
jclement / login_yubikey.c
Last active August 29, 2015 14:00
Updated "login_yubikey.c" for OpenBSD that adds /var/db/yubi/$user.pin with additional user pin/password that must be entered with Yubikey token.
/* $OpenBSD: login_yubikey.c,v 1.8 2013/11/27 21:25:25 deraadt Exp $ */
/*
* Copyright (c) 2010 Daniel Hartmeier <daniel@benzedrine.cx>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
@jclement
jclement / rotate.sh
Created April 1, 2014 15:30
Really quick script to remove all but latest 60 backups with a given prefix from Tarsnap. Assumes archives have common prefix and a sortable suffix.
#!/bin/sh
for f in `tarsnap --list-archives | grep "^ARCHIVE_PREFIX_HERE_" | sort -r | tail -n+60`
do
echo "Removing $f"
tarsnap -d -f $f
done
@jclement
jclement / tarsnap_with_pushover.py
Last active August 6, 2021 03:37
Quick and lazy script to backup data via Tarsnap, automatically prune old backups, and push errors / success to devices via Pushover.
#!/usr/bin/env python
import httplib, urllib
import subprocess
import time
import socket
# Configuration #########################################################
BACKUP_PREFIX=socket.gethostname() + "_"
MAX_BACKUPS=30
@jclement
jclement / parseFloatSafe.js
Last active January 3, 2016 05:49
Safer parse float function that handles commas in input and bails outright if there is text in the input
parseFloatSafe: function(v) {
// A more sane parseFloat function
// - Verifies number in a sensible format and returns NaN otherwise. Sensible format = (#,000.##..) or (#.##) or (#,000) or (#)
// - supports scientific notation (E[-+]?###)
// - null / empty string return null
// - non-string types are converted to string and parsed that way
if (v === null) {return null;}
var tmp = ('' + v).trim();
if (tmp === '') {return null;}
if (tmp.match('^[-+]{0,1}[0-9]+([,]{0,1}[0-9]{3}){0,4}([.][0-9]+){0,1}([eE][-+]{0,1}[0-9]+){0,1}$')) {