Skip to content

Instantly share code, notes, and snippets.


Eric Boehs ericboehs

View GitHub Profile
ericboehs / flatten_json.rb
Created Aug 19, 2021
Flatten a JSON object (for Slack)
View flatten_json.rb
require 'json'
def flatten_hash(hash)
hash.each_with_object({}) do |(k, v), h|
if v.is_a? Hash
flatten_hash(v).map { |h_k, h_v| h["#{k}.#{h_k}".to_sym] = h_v }
h[k] = v
ericboehs /
Created Mar 9, 2021
LaunchAgent for continually connecting to SOCKS via autossh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
View proxy.pac
function FindProxyForURL(url, host) {
if (shExpMatch(host,"*")) {
return PROXY;
if (shExpMatch(host,"*.vetsgov-internal")) {
return PROXY;
View blink-solarized.js
View s3_directory_service.rb
# frozen_string_literal: true
# This file lives in lib/active_storage/service/s3_directory_service.rb.
require 'aws-sdk-s3'
require 'active_storage/service/s3_service'
require 'active_support/core_ext/numeric/bytes'
module ActiveStorage
class Service
View assinc.rb
require 'minitest/autorun'
class TestArray < Minitest::Test
def test_array
assert_includes %(a b c), 'a'
def test_array_refutation
refute_includes %(a b c), 'd'
View yts_downloader
#! /usr/bin/env ruby
require 'cgi'
require 'net/http'
require 'json'
# Adds a movie to based on search term
class MovieDownloader
attr_reader :term
ericboehs / application_record.rb
Last active Sep 7, 2019
Helper method to get the URL to an ActiveStorage Blob/Variant
View application_record.rb
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def attached_url_for(attached, variant: nil, cloudfront_endpoint: ENV['CLOUDFRONT_ENDPOINT'], fallback_url: nil)
if attached.attached?
attached = attached.variant variant if variant
path_helper = Rails.application.routes.url_helpers.method :rails_blob_path
ericboehs / index.html
Last active Aug 25, 2019
Sticky side and top nav via UIKit and position: sticky
View index.html
<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
.tm-height-100vh { height: 100vh; }
.tm-position-top-sticky {
ericboehs / autocomplete.html
Last active Jul 16, 2019
Vanilla JavaScript Autocomplete
View autocomplete.html
<!-- Check out the codepen here: -->
<div class="uk-container-xsmall uk-margin-top uk-margin-auto">
<input class="tm-autocomplete-input uk-input" autocomplete="false" type="text" placeholder="Search Country...">
<ul class="tm-autocomplete" hidden></ul>