Skip to content

Instantly share code, notes, and snippets.

View ddavisgraphics's full-sized avatar
🇺🇸
“First, solve the problem. Then, write the code.” – John Johnson

David J. Davis ddavisgraphics

🇺🇸
“First, solve the problem. Then, write the code.” – John Johnson
View GitHub Profile
@ddavisgraphics
ddavisgraphics / penguin-zsh.sh
Created October 25, 2022 15:56
Tmuxinator for BP
# This function will automatically request reviews on a github repo.
# Requires that have your PAT as a enviormental variable
# @param $1 github repo
# @param $2 pull_request number
request_review(){
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $BP_GITHUB_TOKEN" \
https://api.github.com/repos/BoldPenguin/$1/pulls/$2/requested_reviewers \
@ddavisgraphics
ddavisgraphics / docker-compose.yml
Last active July 23, 2021 16:08
Postgres YML for Docker Compose Setup.
version: "3"
services:
postgres:
container_name: postgres
image: postgres
restart: always
environment:
POSTGRES_USER: "$USER"
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
@ddavisgraphics
ddavisgraphics / EXAMPLE.sql
Created April 1, 2021 16:58
Example on Formatting SQL
SELECT
COUNT([OCLC Number]),
[Institution Symbol]
FROM
(
SELECT DISTINCT
(dbo_acrl2020.[OCLC Number]),
[Institution Symbol]
FROM
dbo_acrl2020
@ddavisgraphics
ddavisgraphics / mimes.json
Created March 31, 2021 11:15
mime_types_list.json
{
"application": [
"application/x-shockwave-flash2-preview",
"application/acad",
"application/acrobat",
"application/activemessage",
"application/andrew-inset",
"application/applefile",
"application/applefile; version=\"1\"",
"application/applefile; version=\"2\"",
@ddavisgraphics
ddavisgraphics / Conversion::Image.rb
Created February 22, 2021 19:18
Image Conversion simplified.
# Covnersion Class for Images
# The parent Conversion::Actor will decide to use the Image, Audio, Video, OCR, and PDF versions.
class Conversion::Image
# Constant pulls out only the necessary items from the fields_hash
IMAGE_PARAMS = %w[border border_width border_color image_format image_height image_resolution image_width watermark watermark_image watermark_location].freeze
# get the media object so we can work with the archived image paths and have access to the parent
# items metadata and form settings
def initialize(media_id)
@archived_media = Media.find(media_id)
@ddavisgraphics
ddavisgraphics / cheatsheet.rb
Created July 14, 2020 17:28
Script to create cheatsheet markdown file out of the ruby.json files in visual studio code, could probably be done other setups too.
require 'json'
ruby_path = "~/Library/Application Support/Code/User/snippets/ruby.json"
file_data = File.read(ruby_path)
json = JSON.parse(file_data)
md = "# Cheatsheet \n"
json.each do |snippet|
name = snippet[0].split(/ |\_|\-/).map(&:capitalize).join(" ")
shortcut = snippet[1]['prefix']

Cheatsheet

Rspec Describe

Shortcut ==> des
RSpec describe case

Rspec Context

Shortcut ==> con
RSpec context case

Rspec Let

Shortcut ==> let
Use let to define memoized helper method

Rspec Let!

Shortcut ==> let! ["Use let! to define a memoized", "helper method that is called", "in a before hook"]

@ddavisgraphics
ddavisgraphics / attempt_1.rb
Last active April 29, 2020 16:11
destroying my hopes!
require "csv"
require 'active_support/core_ext/hash'
# -----------------------------------------------------------------------------------------------
# Grab the file and open it up
# Get the hash table from CSV and use it for selects / detects
etas_title_file = './title_file.csv'
the_csv_file = CSV.parse(File.read(etas_title_file), {:headers => true, :header_converters => :symbol})
# OUTPUTS A HARD CRASH OR A SLUGGISH EVERYTHING IN ABOUT 4 HOURS
@ddavisgraphics
ddavisgraphics / item.rb
Created March 25, 2019 12:07
Demonstrating a Float Point Number on StackOverflow.
class Item
attr_reader :name, :description, :manufacturer, :price, :summary
def initialize (name, manufacturer, price, description=nil, summary=nil)
@name = name
@manufacturer = manufacturer
@price = "%.2f" % price
@description = description
if description

Ruby

  • brakeman - A static analysis security vulnerability scanner for Ruby on Rails applications
  • cane - Code quality threshold checking as part of your build
  • dawnscanner - a static analysis security scanner for ruby written web applications. It supports Sinatra, Padrino and Ruby on Rails frameworks.
  • flay - Flay analyzes code for structural similarities.
  • flog - Flog reports the most tortured code in an easy to read pain report. The higher the score, the more pain the code is in.
  • laser - Static analysis and style linter for Ruby code.
  • pelusa - Static analysis Lint-type tool to improve your OO Ruby code