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
#application controller | |
around_filter :update_user_seen_on | |
def update_user_seen_on | |
yield | |
if signed_in? | |
current_user.last_seen_on = DateTime.now | |
current_user.save |
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
def fizzbuzz( number, index = 1 ) | |
# Do this in one pass | |
value = "" | |
value += "fizz" if (index % 3 == 0) | |
value += "buzz" if (index % 5 == 0) | |
p value | |
# and next number | |
fizzbuzz( number, index + 1 ) |
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
require 'spec_helper' | |
describe Parser do | |
def parser(str = nil) | |
Parser.new(str) | |
end | |
describe "when initialized" do | |
describe "with a valid string" do |
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
# In config/initializers/local_override.rb: | |
require 'devise/strategies/authenticatable' | |
module Devise | |
module Strategies | |
class LocalOverride < Authenticatable | |
def valid? | |
true | |
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
def build_table | |
build_table_head | |
build_table_body unless @collection.blank? | |
end | |
versus | |
def build_table | |
build_table_head |
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
#config/production.rb (line 1) | |
def compile_asset?(path) | |
# ignores any filename that begins with '_' (e.g. sass partials) | |
# all other css/js/sass/image files are processed | |
if File.basename(path) =~ /^[^_].*\.\w+$/ | |
puts "Compiling: #{path}" | |
true | |
else | |
puts "Ignoring: #{path}" |
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
source 'https://rubygems.org' | |
gem 'rails', "3.2.10" | |
# omitted | |
group :stage, :production do | |
gem 'pg' | |
gem 'unicorn' | |
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
FROM debian:10 | |
################################################################ | |
# Install bulk copy program (bcp) | |
################################################################ | |
RUN apt install -y gnupg2 apt-transport-https wget curl | |
RUN wget -q -O- https://packages.microsoft.com/keys/microsoft.asc | \ | |
gpg --dearmor | tee /usr/share/keyrings/microsoft.gpg > /dev/null 2>&1 | |
RUN echo "deb [signed-by=/usr/share/keyrings/microsoft.gpg arch=amd64,armhf,arm64] https://packages.microsoft.com/debian/10/prod buster main" | \ | |
tee /etc/apt/sources.list.d/prod.list |
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
default: &default | |
adapter: postgresql | |
encoding: unicode | |
url: <%= ENV.fetch('DATABASE_URL') { Rails.application.credentials.database_url } %> | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
"<%= Rails.env %>": | |
<<: *default |
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
#!/bin/bash | |
: "${SOURCE:?Please provide a SOURCE which should be a database url}" | |
: "${TARGET:?Please provide a TARGET which should be a database url}" | |
dump_path=dump | |
if [ -d "$dump_path" ]; then | |
echo "/$dump_path already exists. Please remove ./$dump_path before running this script." | |
exit 1 |
OlderNewer