Skip to content

Instantly share code, notes, and snippets.

@antarr
antarr / ruby.sh
Created Apr 30, 2020
install ruby
View ruby.sh
# Install Ruby2.6 from Brightbox APT repository
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install software-properties-common
apt-add-repository -y ppa:brightbox/ruby-ng
apt-get update
apt-get -y install ruby-switch ruby-bundler ruby2.3 ruby2.3-dev
sudo gem install bundler -v 1.16.6
SHELL
View gist:fa83abb2a79ad9ae7121954340607aee
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; font-src 'none' data: js.stripe.com;">
View install_ruby_via_rbenv.sh
sudo apt-get -y update
sudo apt-get -y install curl git-core python-software-properties ruby-dev libpq-dev build-essential nginx libsqlite3-0 libsqlite3-dev libxml2 libxml2-dev libxslt1-dev libreadline-dev
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo -H -u vagrant bash -i -c 'rbenv install 2.6.5'
@antarr
antarr / Vagrantfile
Created Feb 28, 2020
migrate mysql to pg
View Vagrantfile
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/xenial64'
config.vm.network 'forwarded_port', guest: 80, host: 80, auto_correct: true
config.vm.network 'forwarded_port', guest: 443, host: 443, auto_correct: true
@antarr
antarr / expressions.rb
Created Feb 23, 2020
Replacement Regular Expressions
View expressions.rb
# replace double quotes with single quotes as well
# needs to be updated to exclude interopolated strings
=(\s)?["|'](.*)?["|]
=$1'$2
@antarr
antarr / console
Created Jan 14, 2020
authentication_spec
View console
{"dir_array":["./test/factories/reminder_triggers.rb","./test/factories/certificate_contents.rb","./test/factories/reseller_tiers.rb","./test/factories/csrs.rb","./test/factories/signed_certificates.rb","./test/factories/assignments.rb","./test/factories/cdns.rb","./test/factories/certificates.rb","./test/factories/certificate_orders.rb","./test/factories/billing_profiles.rb","./test/factories/sub_order_items.rb","./test/factories/roles.rb","./test/factories/users.rb","./test/factories/ssl_accounts.rb","./test/factories/product_variant_group.rb","./test/factories/product_variant_item.rb"],"factory":{"aliases":[["(?-mix:(.+)_id)","\\1"],["(?-mix:(.*))","\\1_id"]],"definition_file_paths":[{"path":"/vagrant/factories"},{"path":"/vagrant/test/factories"},{"path":"/vagrant/spec/factories"}]},"always_reload":true,"kernel":{},"file_system":{},"factory_cleaner":{},"latest_mtime":null,"dir_system":{}}
@antarr
antarr / activeadmin.rb
Last active Jul 31, 2019
Active Admin Version Panel
View activeadmin.rb
# lib/ext/activeadmin.rb
module ActiveAdminPaperTrailDetails
def versions
panel 'Versions', class: 'versions' do
table_for resource.versions.order :created_at do
column(:whodunnit) { |v| auto_link User.find_by(id: v.whodunnit) }
column :event
column 'When', :created_at
column 'Changes' do |v|
attributes_table_for v.changeset.to_a do
View measurements_controller.rb
class Api::MeasurementsController < ApplicationController
skip_forgery_protection
def index
measurements = Measurement.all
render json: measurements
end
def create
if measurement = Measurement.create measurement_params
@antarr
antarr / error.txt
Last active Nov 8, 2018
using factory_bot traits
View error.txt
FactoryBot::AssociationDefinitionError: Self-referencing association 'notification_eventable' in 'property'
View prepare.sh
chef gem install knife-solo
knife solo init sonar && cd sonar
knife solo prepare antarrbyrd@35.185.84.6
knife solo bootstrap antarrbyrd@35.185.84.6
knife solo cook antarrbyrd@35.185.84.6
You can’t perform that action at this time.