Skip to content

Instantly share code, notes, and snippets.

View omgreenfield's full-sized avatar

Matthew Greenfield omgreenfield

  • Medely
  • Santa Barbara County, CA
View GitHub Profile
@omgreenfield
omgreenfield / higher_version.rb
Created August 13, 2021 21:09
Finding the higher version between two objects
objects = [
# This is the higher version
{ name: "thing1", version: "5.15.6" },
# but string comparison would think this one is
{ name: "thing2", version: "5.6.1" },
]
objects.sort do |a, b|
# The comparison operator works as you'd expect on arrays of numbers
a_comps = a[:version].split(".").map(&:to_i)
@omgreenfield
omgreenfield / developing_for_ubuntu_on_windows.md
Last active March 1, 2021 21:18
Developing for Ubuntu on Windows

Outline

  • Install Windows Terminal
  • Install VS Code
  • Install WSL2
  • Install Ubuntu
  • Install Remote Development extension for VS Code
  • Forward ports
  • Develop

Forward ports

@omgreenfield
omgreenfield / expedia_selenium_example.md
Last active October 17, 2019 00:25
expedia_selenium_example

Directory structure

  • pages
  • drivers
  • cases
  • suites

pages/home

  class HomePage
 def flightButton
@omgreenfield
omgreenfield / install_rails_nginx_puma_and_ssl_with_letsencrypt.md
Last active October 10, 2019 18:16
Install Rails, Nginx, Puma, and an SSL cert with Let's Encrypt

Pre-requisites

  • Ubuntu 16.04
  • Custom DNS name
  • Rails app working in RAILS_ENV=production on ubuntu box (i.e. can run RAILS_ENV=production rails s and go to the app)

Puma

Put in file /etc/systemd/system/puma.service

@omgreenfield
omgreenfield / gtd.md
Last active April 23, 2024 19:52
Getting things done (GTD)

Getting Things Done (GTD)

Recently, I started listening to the David Allen's audio book, "Getting Things Done: The Art of Stress-Free Productivity". In only a few chapters, this audio book has inspired me to completely revamp how I "get things done".

While I haven't heard the entire GTD system or even fully grasped everything I've heard, here are a few concepts that have already helped me become more productive at work and helped my family become more productive at home.

Get it out of your head

TLDR: always put actions, ideas, and reminders in a place that gets them out of your head but always in reach.

@omgreenfield
omgreenfield / method_driven_execution.md
Last active June 28, 2018 05:11
Method driven execution

TLDR

  • Use verbose method names.
  • Put the final result at the top of a piece of code instead of the bottom.
  • Write like Example 3, not Example 1

Meat and taters

Ever since reading a code snippet from an old colleague, I've strongly preferred a liberal amount of method calls to methods with verbose names. When others read my code, I want them to be able to quickly read a few method calls and understand what my the code should be doing from a very superficial level.

@omgreenfield
omgreenfield / remove_peek_delay.md
Last active January 20, 2018 01:02
How to remove the delay for task bar peek in Windows 7 & Windows 10

I frequently like to close programs by hovering over a group of windows, and middle clicking them closed.

The problem is, it takes something like a full second before the peek is shown, making the windows uncloseable for that time.

To remove this delay, add/edit the following registry DWORD (32-bit) value:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ExtendedUIHoverTime

To remove the delay, set it to 1, not 0 (which seems to set it to the default of something like 1000 milliseconds).

@omgreenfield
omgreenfield / install_rails_on_windows.md
Last active June 16, 2017 17:03
Installing Rails on Windows

Download Ruby Installer and DevKit

  1. Go to http://rubyinstaller.org/downloads/
  2. Download an install for ruby. For example, for 2.3.1, get rubyisntaller-2.3.1.exe
  3. Download the DevKit

1. Initialize

  1. Run the rubyinstaller.exe. It'll create a folder like C:\ruby23 for version 2.3.x
  2. Create a folder in that C:\ruby23 folder called "devkit", put the devkit.exe in there, and run it
@omgreenfield
omgreenfield / downloading_pdfs.markdown
Last active February 10, 2022 18:17
Generating and Download PDF's in Rails (Windows)

Generating and Downloading PDF's in Rails (Windows)

I had a lot of trouble trying to get one of my Rails apps to accomplish this common task. For one thing, my dev box runs Windows 7, which notoriously does not play nicely with Ruby on Rails. Another thing... all the instructions/tutorials/document for the gem I'm using, Wicked PDF, were either incomplete or, for some reason or another, didn't work for me.

That's all to say, here are the steps I took, and I hope they will help someone.

I used the Wicked PDF gem. Ryan Bates over at RailsCasts goes over using PDFKit, but this writeup will be all about Wicked PDF.

These next steps I got straight from the instructions on the GitHub page:

@omgreenfield
omgreenfield / ror_heroku.markdown
Last active September 3, 2016 09:41
How to Make a RoR App Ready for Heroku Deployment

When you make a new Ruby on Rails app, there are a few changes you must make to your app so that the production environment (Heroku) functions properly.

Firstly, if you don't have the Heroku CLI installed and the app setup. Go do that. This page isn't for that.

Next, in your Gemfile, make sure that if you're using anything other than postgreSQL for your Dev DB, you isolate it. Heroku uses postgreSQL.

Heroku also uses some other gem that the dev environment doesn't need. So you should have different gems for dev and production. Like so:

group :development, :test do