This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Timecop is fun, but you don't need a whole gem for that. Just use | |
#Time.stub(:now), e.g. | |
describe "time" do | |
before do | |
@fake_time = Time.now | |
Time.stub(:now) { @fake_time } | |
end | |
it "is equal" do | |
Time.now.should == Time.now # now it passes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff --staged --name-only | xargs rubocop -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/monit/conf.d/app | |
set daemon 30 with start delay 60 | |
set log "/srv/www/app/shared/log/monit.log" # syslog facility log_daemon | |
set httpd port 2812 | |
allow localhost | |
allow login:password | |
# with ssl { | |
# pemfile: /etc/ssl/certs/app_com.pem | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# visit https://accounts.google.com/DisplayUnlockCaptcha and click to allow access | |
# edit /etc/monit/monitrc to include the following | |
set mailserver smtp.gmail.com port 587 | |
username "whoever@gmail.com" password "whatever" | |
using tls | |
with timeout 30 seconds | |
# run the following to validate access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/spree/image.rb | |
module Spree | |
class Image < Asset | |
mount_uploader :attachment, Spree::ImageUploader, | |
mount_on: :attachment_file_name | |
validates :attachment, presence: true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add `gem 'awesome_print` to Gemfile | |
rails c | |
# cl = Scryfaller::Client.new | |
# hash = cl.cards.search(q: "Aberrant Researcher // Perfected Form").body[:data].first | |
ap hash, ruby19_syntax: true, index: false, indent: 2 | |
# Copy and paste output into https://www.cleancss.com/ruby-beautify/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo apt install net-tools | |
sudo netstat -ntlp | grep LISTEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inherit_from: .rubocop_todo.yml | |
AllCops: | |
# Default formatter will be used if no `-f/--format` option is given. | |
DefaultFormatter: fuubar | |
# Cop names are displayed in offense messages by default. Change behavior | |
# by overriding DisplayCopNames, or by giving the `--no-display-cop-names` | |
# option. | |
DisplayCopNames: true | |
# Style guide URLs are not displayed in offense messages by default. Change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :changelog do | |
# simple rake task to output a changelog between two commits, tags ... | |
# output is formatted simply, commits are grouped under each author name | |
# | |
desc "generate changelog with nice clean output" | |
task :generate, :since_c, :until_c do |t, args| | |
since_c = args[:since_c] || `git tag | head -1`.chomp | |
until_c = args[:until_c] || `git rev-parse --short HEAD` | |
cmd=`git log --pretty='format:%ci::%an <%ae>::%s::%H' --after=#{since_c} --before=#{until_c}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Where | |
class <<self | |
attr_accessor :editor | |
def is_proc(proc) | |
source_location(proc) | |
end | |
def is_method(klass, method_name) | |
source_location(klass.method(method_name)) |