Skip to content

Instantly share code, notes, and snippets.

View refactor8's full-sized avatar

Ryan Flores refactor8

  • World
View GitHub Profile
digraph architecture {
rankdir=LR;
subgraph client_side_apps {
front_end -> {auth_api, my_app_api};
extension -> {auth_api, my_app_api};
{rank=same; front_end, extension, auth_api};
}
@refactor8
refactor8 / LC_CTYPE.txt
Created November 25, 2017 10:35 — forked from thanksdanny/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@refactor8
refactor8 / remove-docker-containers.md
Last active September 13, 2017 08:05 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@refactor8
refactor8 / README.md
Created September 10, 2017 22:01 — forked from dmitryrck/README.md
Zero to Up and Running a Rails Project only using Docker - README

My Blog

Running

Setup:

% docker-compose run --rm -u root web bash -c "mkdir -p /bundle/vendor && chown railsuser /bundle/vendor"
% docker-compose run --rm web bundle install
% docker-compose run --rm web bundle exec rake db:setup
@refactor8
refactor8 / .dockerignore
Created September 5, 2017 20:29 — forked from davidderus/.dockerignore
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
doc
.yardoc
coverage
jsdoc
tmp
log
README.md
public/uploads/
@refactor8
refactor8 / filterable.rb
Created September 2, 2017 20:01 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@refactor8
refactor8 / custom_logger.rb
Created August 21, 2017 13:55 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@refactor8
refactor8 / 1_initial_migration.rb
Created June 11, 2017 22:33 — forked from wrburgess/1_initial_migration.rb
Setting up UUID columns for Rails 5+ models utilizing Postgres 9.4+
class InitialMigration < ActiveRecord::Migration[5.0]
def change
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto")
end
end
@refactor8
refactor8 / os-x-syslog-server.md
Created May 27, 2017 22:46 — forked from darconeous/os-x-syslog-server.md
Using OS X as a Syslog Server

Using OS X as a Syslog Server

This document describes how to set up an OS X to be a syslog server that logs messages from the local network. It was largely meant for my own purposes so that I don't forget what I did, but feel free to use it for your own purposes.

A problem with just "turning this on" is that you will not see the correct hostname in the syslog entries. What we will do is use

@refactor8
refactor8 / gist:1c944f888edde0cbdd63a3dcdb5d9cd5
Created April 25, 2017 02:16 — forked from JanDintel/gist:6088237
Using RSpec with Rails 4 PATCH method

Using Rspec with Rails 4 patch method

In Rails 4 PATCH is the new HTTP methode for an update action. You can find the details here: http://weblog.rubyonrails.org/2012/2/25/edge-rails-patch-is-the-new-primary-http-method-for-updates/

Using PATCH in your specs

As you can imagine you need to use the PATCH method to test the update action in your controller. Because of how the users controller in this example works you need to specify the id and user. This particular spec tests whether the user gets redirected if it's not logged in.

(./spec/controllers/users_controller_spec.rb)

require 'spec_helper'