Install the Rails gem if you haven't done so before
This file contains hidden or 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
require 'rack/handler/puma' | |
class PumaRackApp | |
def call(env | |
['200', {'Content-Type => 'text/html'}, ['Hello, World!']] | |
end | |
end | |
Rack::Handler::Puma.run(PumaRackApp.new, Post: 5000) |
This file contains hidden or 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
# Full path to this script | |
# two different ways to get the same full path | |
SCRIPT_DIR=$(dirname $(readlink -f $0)) | |
REALPATH=$(dirname $(realpath $0)) | |
echo "This script is located in: $SCRIPT_DIR" | |
echo "This script realpath is located in: $REALPATH" | |
# example use case: |
This file contains hidden or 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
def latinize(string) | |
string.unicode_normalize(:nfd).chars.select do |char| | |
char.match(/\p{Latin}|\s/) | |
end.join | |
This file contains hidden or 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
require_relative "config/environment" | |
# Note: As of Rails 7.1+ we can just use: | |
# `rails routes --unused` | |
Rails.application.routes.routes.map(&:requirements).each do |route| | |
next if route.blank? | |
next if route[:internal] | |
controller_name = "#{route[:controller].camelcase}Controller" | |
next if controller_name.constantize.new.respond_to?(route[:action]) |
This file contains hidden or 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
How to fix a corrupt zsh history file | |
Occasionally you may find you have a corrupt zsh history file preventing you from using the `fc` command or searching the history. Here's how to fix it. | |
Estimated reading time: 1 minutes | |
Table of contents | |
Corrupt ZSH history file | |
How to fix it | |
Making it a script | |
Corrupt ZSH history file | |
If you use zsh for your shell very occasionally you may find the following message appearing indicating a corrupt history file. This is normally after a reboot. |
This file contains hidden or 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
# It's super easy to create SEO friendly URLs (I love that it just works!) | |
def to_param | |
"#{id}-#{title.parameterize}" | |
end | |
## Alternative implementation of the #to_param method from the book | |
## Learn Rails 6 by Adam Notodikromo | |
## Change the default :id parameter |
This file contains hidden or 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
# Change the last 6 in the found -ruby-version files to a 7 | |
# You can change to regular expression to be less specific, this was my use case | |
find ./ -name ".ruby-version" -exec sed -i "s/6$/7/" {} + | |
# Same thing but only go down one level of subfolders | |
find ./ -mindepth 2 -name ".ruby-version" -exec sed -i "s/6$/7/" {} + |
This file contains hidden or 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
-- Remove the Git history | |
rm -rf .git | |
-- reinitialise Git | |
git init | |
git add . | |
git commit -m "Initial commit" | |
-- create repo through Github CLI | |
gh repo create --public --source=. |
This file contains hidden or 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
c9 WebsiteOne 17.10.2018 | |
be rake cucumber | |
Failing Scenarios: | |
cucumber features/hangouts/hangout.feature:131 # Scenario: Infinite scroll on hangouts scroll down until no more hangouts | |
cucumber features/premium/sponsor_other_member.feature:19 # Scenario: User upgrades another user from free tier to premium via card | |
cucumber features/premium/subscribe_self_to_nonprofit_basic.feature:12 # Scenario: Sign up for nonprofitbasic support | |
cucumber features/premium/subscribe_self_to_premium.feature:14 # Scenario: Pay by card | |
cucumber features/premium/subscribe_self_to_premium.feature:23 # Scenario: Logged in user has sponsor set to self | |
cucumber features/premium/subscribe_self_to_premium.feature:54 # Scenario: Pay by card, but encounter error |
NewerOlder