Skip to content

Instantly share code, notes, and snippets.

config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
@dhh
dhh / comments_channel.rb
Last active December 16, 2020 14:24
On-boarding a specialized broadcast method in the channel itself
# Channel
class CommentsChannel < ApplicationCable::Channel
def self.broadcast_comment(comment)
broadcast_to comment.message, comment: CommentsController.render(
partial: 'comments/comment', locals: { comment: comment }
)
end
def follow(data)
stop_all_streams
class UserAuthenticationsController < AuthenticatedController
def create
if authenticate
enroll_promotions
redirect_to return_path
else
redirect_to back_path, error: authentication_error_message
end
end
#!/usr/bin/env ruby
# Requires that you have ./bin/dcpTool from https://sourceforge.net/projects/dcptool/
require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
input_camera_model = ARGV[0] || "LEICA Q (Typ 116)"
output_camera_model = ARGV[1] || "LEICA M10"
class Customers::GridCountsController < ApplicationController
def index
render json: GridCountsQuery.run(params[:grid_counts])
end
end
class GridCountsQuery
class << self
def run
query.each_with_object(Hash.new) do |row, grid|
# Option A: I'd start with this
class Micropost < ActiveRecord::Base
validate :no_profanity
private
def no_profanity
if user.minor? && profanity = profane_words_used_in_content
errors.add :content, "Profanity: '#{profanity.join(", ")}' not allowed!"
end
end
Hi,
This is Neela, recruiter from Kellton Tech Solutions (Formerly Prosoft Technology Group, Inc)
We are an Information Technology and Business Consulting firm specializing in Project-based Solutions
and Professional Staffing Services. I just tried reaching you today as your profile has been one of
the best matches for an immediate job opportunity I have with my client. So, please have a look at
the job description and let me know your interest ASAP. I would really appreciate if you could send
me your most updated resume also.
Please Note:
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
module YourApp
class Application < Rails::Application
# Convenience for loading config/foo.yml for the current Rails env.
#
# Example:
#
# config/cleversafe.yml:
#
# production:
# url: http://127.0.0.1:8080
#!/usr/bin/env node
// Results from MacBook (Retina, 12-inch, Early 2016), 1.3 GHz Intel Core m7, macOS 10.12.3, Node 7.6.0
// let a = { z: 1 }
// human-friendly x 85,821,153 ops/sec ±1.81% (87 runs sampled)
// machine-friendly x 92,613,579 ops/sec ±1.89% (85 runs sampled)
// Fastest is machine-friendly
// let a = undefined