Skip to content

Instantly share code, notes, and snippets.

View wakproductions's full-sized avatar
💭
Hey, I'm working on it!

Winston Kotzan wakproductions

💭
Hey, I'm working on it!
View GitHub Profile
@wakproductions
wakproductions / pdf_merger.rb
Created August 5, 2021 18:27 — forked from eclosson/pdf_merger.rb
Merging PDFs with Prawn
class PdfMerger
def merge(pdf_paths, destination)
first_pdf_path = pdf_paths.delete_at(0)
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf|
pdf_paths.each do |pdf_path|
pdf.go_to_page(pdf.page_count)
@wakproductions
wakproductions / left_join_arel_example.rb
Created December 30, 2018 16:17 — forked from mildmojo/left_join_arel_example.rb
LEFT JOIN in ARel for ActiveRecord in Ruby on Rails
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of
# the mechanics, not a real-world use case.
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord
# extension that works for any named association. That's what I really wanted!
# Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446
# == DEFINITIONS
# - A Taxi is a car for hire. A taxi has_many :passengers.
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi.
@wakproductions
wakproductions / gist:6da2d3764f2a9db318432f16e6a27e12
Created December 13, 2018 03:03 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@wakproductions
wakproductions / postgres-brew.md
Created December 6, 2018 16:53 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@wakproductions
wakproductions / instance-name-tag.sh
Created April 11, 2017 19:41 — forked from swithrow/instance-name-tag.sh
EC2 Instance Name Tag in the bash prompt.
#!/bin/bash
#
# copy this into /etc/profile.d/instance-name-tag.sh
#
# you will need:
# - curl, jq, and aws cli installed
# - an IAM role that gives the EC2 instance access to describe tags
#
@wakproductions
wakproductions / docker_cheat_sheet.md
Last active September 20, 2017 20:46 — forked from dvdasari/gist:439ce7c1814c2392c3bf
Docker Commands Cheat Sheet

Base commands:

Creating a new container

docker run [-d (runs in background] [-p <host-system-port>:<container-port>] <image:tag>
* Creates a new container from an image
* If you run it 4 times, it will create 4 containers
Options:
 --name Give the container a name, otherwise it will pick a default name.
module WAKUtils
def self.reload(require_regex)
$".grep(/#{require_regex}/).each {|e| $".delete(e) && require(e) }
end
end