Skip to content

Instantly share code, notes, and snippets.

View myers's full-sized avatar

Myers Carpenter myers

View GitHub Profile
zpool create \
-o cachefile=/etc/zfs/zpool.cache \
-o ashift=12 -o autotrim=on -d \
-o feature@async_destroy=enabled \
-o feature@bookmarks=enabled \
-o feature@embedded_data=enabled \
-o feature@empty_bpobj=enabled \
-o feature@enabled_txg=enabled \
-o feature@extensible_dataset=enabled \
-o feature@filesystem_limits=enabled \
@myers
myers / put_upload_middleware.py
Created May 16, 2020 15:24
Simple Django 2.2 Middleware that handles file uploads via PUT requests
from django.http import QueryDict
from django.http.multipartparser import MultiValueDict
from django.core.files.uploadhandler import (
SkipFile,
StopFutureHandlers,
StopUpload,
)
class PutUploadMiddleware(object):
@myers
myers / model_to_csv.rb
Created March 3, 2016 19:09
How to dump the data in a Rails model to csv
model = MyModel
CSV.new(File.new(model.to_s.underscore + ".csv", "w")).tap do |csv|
column_names = model.column_names
csv << column_names
model.find_each do |ii|
csv << column_names.map do |cn|
ii.send(cn)
end
end
# Why 'utf8_unicode_ci'? Read http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
THE_ONE_TRUE_COLLATION = 'utf8_unicode_ci'
task convert_db_to_utf8: :environment do
c = ActiveRecord::Base.connection
database_name = Rails.configuration.database_configuration[Rails.env]['database']
puts "Setting default for new tables for #{database_name.inspect}..."
c.execute("ALTER DATABASE `#{database_name}` CHARACTER SET `utf8` COLLATE `#{THE_ONE_TRUE_COLLATION}`")
## Side Kick
You helped a fellow Treehouse member in our forum. You're a helpful person, like a superhero's side kick!
SideKick.png
Number of learners with this badge: 19
## Accessibility
Accessibility is the practice of making websites available to all people, regardless of their abilities or disabilities.
Accessibility_Alt.png
Number of learners with this badge: 687

Keybase proof

I hereby claim:

  • I am myers on github.
  • I am myers (https://keybase.io/myers) on keybase.
  • I have a public key whose fingerprint is 632B 5A28 9024 993E CE78 8891 2380 E721 91FB 6F04

To claim this, I am signing this object:

defmodule SessionHerderTest do
use ExUnit.Case
setup do
{:ok, sup_pid} = Chat.SessionSupervisor.start_link
{:ok, herder_pid} = Chat.SessionHerder.start_link
{:ok, pids: [sup_pid, herder_pid]}
end
teardown config do
@myers
myers / reddit-ppa.pem
Last active December 25, 2015 19:59
Reddit PPA PGP key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.4
Comment: Hostname: keyserver.ubuntu.com
mI0ET0gy2QEEAMbpVvYeszQ6u6OMrXqyebsaDLQO3wsgI1vYgqVed/RcipzihDIXerYW74FV
np6xUG8ZyZyPqctXyYYel7QzHq5ea2liSrRU2UB406tDQaqFzs8MTx2xUu1rDN4W+UtS6K2y
OPIM3n1d9UEatuVFcyunHwG4ai0FXWXRD0CFfGT7ABEBAAG0GExhdW5jaHBhZCBQUEEgZm9y
IHJlZGRpdIi4BBMBAgAiBQJPSDLZAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB+
B71BZVBtJ3CNA/9nJyEpv5OI7O8nis7jrLnZN84pPZvawmOn7uZNXr2m1ppqSx9+87exbRRu
cVqeL6FPYumPLsq5cn+FvCyWnhDS5aFVTKW1OHEssKapkCXmfDEV5bFUsjdzSkud0ytlnqZg
@myers
myers / Vagrantfile
Last active December 25, 2015 19:59
vagrant plugin list error
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_plugin 'vagrant-berkshelf'
Vagrant.require_plugin 'vagrant-omnibus'