Skip to content

Instantly share code, notes, and snippets.

View jyunderwood's full-sized avatar

Jonathan Underwood jyunderwood

View GitHub Profile
@jyunderwood
jyunderwood / Gemfile
Created June 26, 2020 03:43 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@jyunderwood
jyunderwood / gist:83ffa521b7e70fe3aaf837f3e741f466
Last active October 28, 2020 14:37 — forked from jvenator/gist:9672772a631c117da151
PDFtk Server Install Workaround for Mac OS X

Installing PDFtk Server edittion on your Mac

This workaround install is necessary because PDFtk was pulled from homebrew-cask due to issues with it aggressively overwriting file permissions that could impact other installed libraries. See this homebrew-cask issue.
The following steps worked on Mac OS X 10.10.1 with a standard brew installation for the PDFtk Mac OS X server libary version 2.02.
All Terminal commands separated by a full line space. Some commands wrap into multiple lines.

Download and extract the Mac OS X server install pacakge

@jyunderwood
jyunderwood / letsencrypt.conf
Created January 21, 2020 14:48
Certbot + redirects
# /etc/nginx/snippets/letsencrypt.conf
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /srv/www/letsencrypt;
}
# Hide /acme-challenge subdirectory and return 404 on all requests.
location = /.well-known/acme-challenge/ {
return 404;
@jyunderwood
jyunderwood / Program.cs
Created June 18, 2018 14:48
SCP and Email a file
using Renci.SshNet;
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.IO;
using System.Linq;
namespace PlayBall
{
internal class Program
using CRMProject.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
namespace Infrastructure.Data
{
public class AppDbContext : DbContext
{
public DbSet<Contact> Contacts { get; set; }
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
require 'base64'
require 'open-uri'
require 'net/http'
require 'net/https'
require 'json'
class OCR
attr_reader :api_key, :image_url
def self.scan(api_key:, image_url:)
@jyunderwood
jyunderwood / mboxdiff.py
Last active August 29, 2015 14:23
mboxdiff.py
import mailbox
# Open the mbox files (relative to your present working directory)
# Note, Mail.app actually exports a mbox folder that contains an mbox file
mbox1 = mailbox.mbox('Old-Archive.mbox/mbox')
mbox2 = mailbox.mbox('New-Archive.mbox/mbox')
# Use something like `subject` to unique the messages
# or they will all be unique.
def subjects(mbox):
@jyunderwood
jyunderwood / transmission.sh
Created March 11, 2015 13:38
Set Transmission.app preferences on OS X
#!/usr/bin/env bash
# Use `~/Downloads` to store incomplete downloads
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads"
# Do not prompt for confirmation before downloading
defaults write org.m0k.transmission DownloadAsk -bool false
# Trash original torrent files
---
- hosts: all
sudo: yes
tasks:
- name: "test for swap partition"
shell: 'sudo swapon -s | grep -E "^/"'
register: swapfile
ignore_errors: yes