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
s = $document[0].createElement('script') | |
s.type = 'text/javascript' | |
s.async = true | |
s.src = "https://widget.intercom.io/widget/#{chat_settings.app_id}" | |
tags = $document[0].getElementsByTagName('script') | |
x = tags[tags.length - 1] | |
x.parentNode.insertBefore(s, x) |
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
# config/lean_application.rb | |
# | |
# Require and run only a part of your Rails app (maybe as a background process) | |
# | |
require File.expand_path('../boot', __FILE__) | |
require 'active_record/railtie' | |
require 'action_mailer/railtie' |
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
module API | |
module Middleware | |
class AppReloader | |
class << self | |
def mtimes | |
@mtimes ||= {} | |
end | |
def files |
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
Rails::Rack::Logger.class_eval do | |
def started_request_message_with_no_ip(request) | |
'Started %s "%s" at %s' % [ | |
request.request_method, | |
request.filtered_path, | |
Time.now.to_default_s] | |
end | |
alias_method_chain :started_request_message, :no_ip | |
end |
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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails', branch: 'master' # master against ref "f1f0a3f8d99aef8aacfa81ceac3880dcac03ca06" |
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
# config/initializers/quiet_assets.rb | |
class QuietAssets | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
original_level = Rails.logger.level | |
if env['PATH_INFO'] =~ %r{\A/assets/} | |
Rails.logger.level = Logger::WARN |
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
#= Should be able to handle phone numbers with varying lengths | |
# length of 11 | |
format_number('18083334444') #=> '+1 (808) 333-4444' | |
# length of 12 | |
format_number('639173334444') #=> '+63 (917) 333-4444' | |
# length of 13 | |
format_number('6140403334444') #=> '+614 (040) 333-4444' | |
# length of 14 | |
format_number('00447743334444') #=> '+0044 (774) 333-4444' |
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
# = Description | |
# Loads all words in the dictionary into memory and finds the longest word | |
# | |
# Elixir | |
File.read!("/usr/share/dict/words") |> String.split |> Enum.max_by(&String.length/1) |> IO.puts | |
#=> formaldehydesulphoxylate | |
# Time (after compiled): | |
# real 0m1.887s | |
# user 0m1.722s | |
# sys 0m0.247s |
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
describe DRG::Ruby::Condition do | |
let(:sexp) {} | |
subject { described_class.new sexp } | |
describe "#initialize" do | |
end | |
describe "#short_statement" do | |
context "if @statement =~ /(unless|if)(.+)$/ then" do |
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
# | |
# AUTOMATICALLY GENERATED SPEC | |
# | |
require "spec_helper" | |
describe UsersController do | |
subject { described_class.new } | |
describe "#index" do |