Skip to content

Instantly share code, notes, and snippets.

@fracai
fracai / camect.css
Created July 23, 2020 15:13
Dark mode CSS for Camect
@-moz-document domain("home.camect.com")
{
body {
background-color: #1a1a1a;
}
top-bar:not(.tabbed-top-bar),
.fs-modal .modal-header {
color: black;
background: #0c8;
}
@fracai
fracai / clean-certs.py
Created February 2, 2020 05:07
Clean stale FreeNAS certificates
#!/usr/bin/env python
import requests, json, time, sys
password='password'
host='hostname'
login = ('root', password)
headers = {'Content-Type': "application/json"}
url = 'http://'+host+'/api/v1.0/system/certificate/'
@fracai
fracai / blogging_json.rb
Created May 22, 2017 01:47
A nanoc blogging helper (without AtomFeedBuilder inheritance) for producing a JSON feed. See https://jsonfeed.org/
# frozen_string_literal: true
module Nanoc::Helpers
# @see http://nanoc.ws/doc/reference/helpers/#blogging
module Blogging_JSON
# @return [Array]
def articles
blk = -> { @items.select { |item| item[:kind] == 'article' } }
if @items.frozen?
@article_items ||= blk.call
@fracai
fracai / blogging_json.rb
Created May 22, 2017 01:47
A nanoc blogging helper for producing a JSON feed. See https://jsonfeed.org/
# frozen_string_literal: true
module Nanoc::Helpers
# @see http://nanoc.ws/doc/reference/helpers/#blogging
module Blogging_JSON
include Nanoc::Helpers::Blogging
class JSONFeedBuilder < AtomFeedBuilder
def build
require 'json'
### Keybase proof
I hereby claim:
* I am fracai on github.
* I am fracai (https://keybase.io/fracai) on keybase.
* I have a public key ASCDlpfcLaKXgjBQUFYZdqWloGdYjjKuzPVRZ0o6CeJe1Ao
To claim this, I am signing this object:
@fracai
fracai / cycle-afp.py
Created February 20, 2016 04:15
A short script using the FreeNAS API to cycle the AFP service off and back on. Just replace your root password and hostname in the script.
#!/usr/bin/env python
import requests, json, time
password='root_password'
host='freenas_hostname'
login = ('root', password)
headers = {'Content-Type': "application/json"}
url = 'http://'+host+'/api/v1.0/services/services/afp/'
@fracai
fracai / rollup.py
Created December 13, 2012 03:23
A snapshot pruning script, similar in behavior to Apple's TimeMachine. Keep hourly snapshots for the last day, daily for the last week, and weekly thereafter. Also prune empty snapshots (0 bytes used) that aren't the most recent for any dataset. Now tracked at https://github.com/fracai/zfs-rollup and https://bitbucket.org/fracai/zfs-rollup
#!/usr/bin/env python
# rollup.py - Arno Hautala <arno@alum.wpi.edu>
# This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
# (CC BY-SA-3.0) http://creativecommons.org/licenses/by-sa/3.0/
#
# For the latest version, visit:
# https://github.com/fracai/zfs-rollup
# https://bitbucket.org/fracai/zfs-rollup
@fracai
fracai / gist:3108786
Created July 14, 2012 01:56
build and iterate a sorted hash of items by class and sequence
# build the classes hash
classes = Hash.new{|h, k| h[k] = []}
items.reject { |i| ! i[:class] }.each do |i|
classes[i[:class]] << i
end
# iterate each class, then each sequence in that class
classes.keys.sort.each do |class, class_items|
class_items.sort_by { |c| c[:sequence] }.each do |c|
#
@fracai
fracai / org.macports.port.selfupdate.plist
Created April 7, 2012 02:13
A launchd task to run periodic-port.sh ( https://gist.github.com/2324493 )
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.macports.port.selfupdate</string>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
@fracai
fracai / periodic-port.sh
Created April 7, 2012 02:08
A script to update MacPorts, fetch outdated ports, compile them, remove the inactive duplicates, and then sign the archives.
#!/bin/sh
# update macports and list outdated software
HOST=$(hostname|sed "s/.local//")
/bin/echo "=== Update MacPorts" | /opt/local/bin/gawk '{print strftime("%b %d %H:%M:%S"),"'${HOST}'",$0; fflush() }'
/opt/local/bin/port selfupdate --nosync 2>&1 | /opt/local/bin/gawk '{print strftime("%b %d %H:%M:%S"),"'${HOST}'",$0; fflush() }'