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 / strip_blank_lines.rb
Created July 19, 2014 02:44
A nanoc filter for stripping blank lines.
module Nanoc::Filters
class StripBlankLines < Nanoc::Filter
identifier :strip_blank_lines
def run(content, params={})
count_pre = 0
content.split("\n").each do |line|
line << "\n"
@fracai
fracai / compact.rb
Last active August 29, 2015 14:04
A nanoc filter for stripping blank lines and extraneous whitespace.
module Nanoc::Filters
class Compact < Nanoc::Filter
identifier :compact
def run(content, params={})
count_pre = 0
content.split("\n").each do |line|
line << "\n"
@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|
#