Skip to content

Instantly share code, notes, and snippets.

@JoshAshby
JoshAshby / unitypackage_extractor.rb
Created September 26, 2020 19:57
Quick and dirty utility to extract a unitypackage's contents
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
require 'pathname'
def unpack filename, output
output_path = Pathname.new output
Zlib::GzipReader.open filename do |gz|
@JoshAshby
JoshAshby / tagger.rb
Last active September 25, 2017 19:52
Manipulate and list the Finder tags on an MacOS file.
#!/usr/bin/env ruby
require "ffi-xattr"
require "cfpropertylist"
require "pry"
class Tag
COLORS = {
white: 0,
gray: 1,
@JoshAshby
JoshAshby / do_dns.rb
Last active September 21, 2017 19:26
Converts chef databag dns records into DigitalOcean DNS entries
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
Bundler.require :default
class DODNS
TOKEN = ENV["DO_TOKEN"].freeze
DNS_FILE_LOC = Pathname.new("data_bags/dns").freeze
{
"header": {
"Name": "WorkDox",
"Layout": "Ashby1",
"Base": "Blank",
"Version": "0.1",
"Author": "JoshAshby 2016",
"KLL": "0.3c",
"Date": "2015-09-12",
"Generator": "KIICONF 0.2"
@JoshAshby
JoshAshby / hope_schedule.rb
Created June 27, 2016 14:57
Mostly parses the HOPE 11 Schedule into a TSV, messes up on one or two rows with the "extra info"
require 'net/http'
require 'net/https'
require 'nokogiri'
uri = URI('https://hope.net/schedule.html')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
class MylarLogger
attr_accessor :logger, :log, :saved_lines
def initialize logger, saved_lines: 20
@logger, @log, @saved_lines = logger, [], saved_lines
end
def method_missing name, *args, &block
@log.push({ method: name, args: args })
@log.shift if @log.length > @saved_lines
@JoshAshby
JoshAshby / elasticsearch.yml
Created December 1, 2015 19:15
Single node, no cluster connection elasticsearch config.
##################### Elasticsearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# Elasticsearch comes with reasonable defaults for most settings,
@JoshAshby
JoshAshby / run_and_notify.rb
Last active August 29, 2015 14:17
Runs the given command and sends a notification if it fails
#!/usr/bin/env ruby
require 'washbullet'
require 'thor'
class CommandCLI < Thor
desc "pushbullet COMMAND", "Runs the given COMMAND and sends a pushbullet notification if the exit status is non-zero"
long_desc <<-DESC
Runs the given command and sends a pushbullet notification if the exit status is non-zero.
module Exceptatron
class Middleware
def initialize app
@app = app
end
def call request
raise StandardError.new "Bubbling down"
code, headers, body = @app.call request
@JoshAshby
JoshAshby / base.coffee
Created December 6, 2014 05:25
Basic start of a quill.js powered thingy that supports KaTeX with a custom format
$output = $("#output")
window.editor = new Quill('#editor', {
modules: {
'toolbar': { container: '#toolbar' },
'link-tooltip': true
},
theme: 'snow'
})