Skip to content

Instantly share code, notes, and snippets.

View jesse-spevack's full-sized avatar

Jesse Spevack jesse-spevack

View GitHub Profile
@swanson
swanson / .irbrc
Last active March 3, 2024 17:14
.irbrc color coding Rails console by environment
# Add color coding based on Rails environment for safety
if defined? Rails
banner = if Rails.env.production?
"\e[41;97;1m #{Rails.env} \e[0m "
else
"\e[42;97;1m #{Rails.env} \e[0m "
end
# Build a custom prompt
@jonnyjava
jonnyjava / working_effectively_with_legacy_code.md
Created November 4, 2019 21:51
Working effectively with legacy code summary

WORKING EFFECTIVELY WITH LEGACY CODE

To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book: Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

Chapter 1 Changing Software

Four Reasons to Change Software: For simplicity’s sake, let’s look at four primary reasons to change software.

Note: this assumes you are using ZSH shell.
## Installation
Install [asdf](https://github.com/asdf-vm/asdf):
```
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.4.0
$ echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
@loilo
loilo / split-pull-requests.md
Last active April 3, 2024 07:24
Split a large pull request into two
@ryanflach
ryanflach / rails_setup.md
Last active November 13, 2023 19:49
Common setup for a new Rails project
  1. rails new <project_name> -d postgresql --skip-turbolinks --skip-spring -T
  • -d postgresql sets up the project to use PostgreSQL
  • --skip-turbolinks & --skip-spring creates a project that does not use turbolinks or spring
  • -T skips the creation of the test directory and use of Test::Unit
  1. In the Gemfile:
  • Available to all environments:
    • gem 'figaro' - store environment variables securely across your app (docs)
    • Uncomment gem 'bcrypt', '~> 3.1.7' if you will be hosting your own user accounts with passwords (docs)
  • Inside of group :test:
    • gem 'rspec-rails' - user rspec in place of minitest (docs)
@techgaun
techgaun / erlang-elixir-on-amazon-linux.md
Last active November 21, 2023 03:09
Running elixir 1.8.1 on amazon linux

Script

#!/bin/bash

yum install ncurses-devel openssl-devel -y
yum groupinstall "Development Tools" -y

cd /tmp
wget "http://erlang.org/download/otp_src_21.3.tar.gz" -O otp21.tar.gz
@mhawksey
mhawksey / getRowsData.gs
Created February 29, 2016 13:27
getRowsData and setRowsData - originally from the Google Apps Script developer site
// setRowsData fills in one row of data per object defined in the objects Array.
// For every Column, it checks if data objects define a value for it.
// Arguments:
// - sheet: the Sheet Object where the data will be written
// - objects: an Array of Objects, each of which contains data for a row
// - optHeadersRange: a Range of cells where the column headers are defined. This
// defaults to the entire first row in sheet.
// - optFirstDataRowIndex: index of the first row where data should be written. This
// defaults to the row immediately below the headers.
function setRowsData(sheet, objects, optHeadersRange, optFirstDataRowIndex) {
@eikes
eikes / run phoenix on amazon linux.sh
Created December 28, 2015 22:29
run phoenix on amazon linux
# app deps
sudo yum install git
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel
# erlang
wget http://www.erlang.org/download/otp_src_18.1.tar.gz
tar -zxvf otp_src_18.1.tar.gz
@rwarbelow
rwarbelow / running_app_in_production_locally.markdown
Created November 11, 2015 18:26
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

@spiffytech
spiffytech / import.rb
Last active October 31, 2023 18:44 — forked from evanwalsh/import.rb
Imports a Squarespace dump into Jekyll
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'nokogiri'
require 'fileutils'
require 'safe_yaml'
require 'time'
require 'uri'
require 'open-uri'