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)
def positional_arguments(arg1, arg2, arg3)
puts [arg1, arg2, arg3].join(' ')
end
positional_arguments('Hello', 'Jean Luc', 'Picard')
def positional_with_hash(arg, opts = {})
puts [arg, opts[:firstname], opts[:lastname]].join(' ')
end
@wakproductions
wakproductions / Dockerfile
Created March 5, 2021 14:43
Dockerfile and docker-compose for PHP server
FROM httpd:2.4.23
# autoconf - needed for building debugger
# curl - useful tool for debugging in the container
# mysql-client - because we're using MySQL 5.7 on a different container
# libmysqlclient-dev - needed for mysql_config, option needed to get MYSQLI driver in compile
# gcc, make - need a C compiler to build PHP
# libxml2-dev - dependency for compiling PHP
RUN apt-get update && apt-get install -y \
autoconf \
@wakproductions
wakproductions / stonks-on-rails-2-tdameritrade-oauth.md
Last active June 14, 2022 15:45
TD Ameritrade OAuth API Connection Wrapper - Stonks on Rails #2
# app/lib/market_data_pull/tdameritrade/api_operation.rb
# Include this module inside of a class and then to use it, call
# 
# perform_request { |client| client.<operation method> }
#
module MarketDataPull; module TDAmeritrade
  module APIOperation
    module_function
@wakproductions
wakproductions / stonks-on-rails-3-rufus-vs-whenever.md
Created February 28, 2021 22:33
Rufus vs Whenever Ruby Schedulers - Stonks on Rails #3
# docker-compose.yml
version: '3'

services:
  web:
    build: ./
    command: 'rails server -b 0.0.0.0 -p 3000'
    ports:
      - 4000:3000
module IndentUtil
INDENT_SIZE = 2
def indent_chars(indent_level)
' ' * INDENT_SIZE * indent_level
end
end
class PrettifyObject
MAX_LINE_SIZE = 120
@wakproductions
wakproductions / _header.html.slim
Created June 15, 2020 16:51
Refinery CMS - Bootstrap Menu Presenter
/ views/refinery/_header.html.slim
nav#logo.navbar.navbar-light.navbar-expand(itemtype = "http://schema.org/Organization")
= link_to(Refinery::Core.site_name, refinery.root_path, class: 'navbar-brand', itemprop: 'url')
= cache [I18n.locale, 'main_menu', @page, Refinery::Page.fast_menu.map(&:updated_at).max] do
= bootstrap_main_menu(refinery_menu_pages, self).to_html
@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