Snippets Collections
$ mkdir projects
$ cd projects
$ rails new ideastore
    create
    create  README.md
    create  Rakefile
...
    remove  config/initializers/cors.rb
    remove  config/initializers/new_framework_defaults_6_0.rb
       run  bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using concurrent-ruby 1.1.7
...
Fetching webpacker 4.3.0
Installing webpacker 4.3.0
Bundle complete! 17 Gemfile dependencies, 74 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
    run  bundle binstubs bundler
    run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted
      rails  webpacker:install
    create  config/webpacker.yml
Copying webpack core config
    create  config/webpack
    create  config/webpack/development.js
    create  config/webpack/environment.js
    create  config/webpack/production.js
    create  config/webpack/test.js
...
Installing all JavaScript dependencies [4.3.0]
         run  yarn add @rails/webpacker@4.3.0 from "."
yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
...
├─ webpack-dev-middleware@3.7.2
├─ webpack-dev-server@3.11.0
└─ ws@6.2.1
✨  Done in 19.51s.
Webpacker successfully installed 🎉 🍰
require 'net/http'
require 'json'

url = "https://api.currencyapi.com/v3/latest?apikey=YOUR-API-KEY"
uri = URI(url)
response = Net::HTTP.get(uri)
response_obj = JSON.parse(response)

rate = response_obj['data']
"Hello" is a song recorded by English singer-songwriter Adele, released on 23 October 2015 by XL Recordings as the lead single from her third studio album, 25 (2015). Written by Adele and with its producer, Greg Kurstin, "Hello" is a piano ballad with soul influences (including guitar and drums), and lyrics that discuss themes of nostalgia and regret. Upon release, the song garnered critical accl

def hello
  return "hello"
end
# Create sales managers
5.times do
    SalesManager.create(
      name: Faker::Name.name,
      email: Faker::Internet.email,
      password: 'password'
    )
  end
  
  # Create merchandisers
  10.times do
    Merchandiser.create(
      name: Faker::Name.name,
      email: Faker::Internet.email,
      password: 'password',
      salesManager_id: SalesManager.all.sample.id,
      route_plan_id: rand(1..5)
    )
  end
  
  # Create outlets
  20.times do
    Outlet.create(
      name: Faker::Company.name,
      latitude: Faker::Address.latitude,
      longitude: Faker::Address.longitude
    )
  end
  
  # Create route plans
  5.times do
    RoutePlan.create(
      salesManager_id: SalesManager.all.sample.id,
      start_date: Faker::Date.between(from: '2022-01-01', to: '2022-12-31'),
      end_date: Faker::Date.between(from: '2023-01-01', to: '2023-12-31')
    )
  end
  
  # Create route plan details
  RoutePlan.all.each do |route_plan|
    Merchandiser.all.each do |merchandiser|
      Outlet.all.sample(rand(1..5)).each do |outlet|
        RoutePlanDetail.create(
          routePlan_id: route_plan.id,
          merchandiser_id: merchandiser.id,
          outlet_id: outlet.id,
          date: Faker::Date.between(from: '2022-01-01', to: '2023-12-31')
        )
      end
    end
  end
  
  # Create GPS logs
  Merchandiser.all.each do |merchandiser|
    rand(10..50).times do
      GpsLog.create(
        merchandiser_id: merchandiser.id,
        latitude: Faker::Address.latitude,
        longitude: Faker::Address.longitude,
        gpsStarted: Faker::Time.between(from: '2022-01-01', to: '2023-12-31'),
        gpsStopped: Faker::Time.between(from: '2022-01-01', to: '2023-12-31')
      )
    end
  end
create_table "gps_logs", force: :cascade do |t|
    t.integer "merchandiser_id", null: false
    t.string "latitude"
    t.string "longitude"
    t.datetime "gpsStarted"
    t.datetime "gpsStopped"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "merchandisers", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.string "password_digest"
    t.integer "salesManager_id", null: false
    t.integer "route_plan_id", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "outlets", force: :cascade do |t|
    t.string "name"
    t.string "latitude"
    t.string "longitude"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "route_plan_details", force: :cascade do |t|
    t.integer "routePlan_id", null: false
    t.integer "merchandiser_id", null: false
    t.integer "outlet_id", null: false
    t.string "date"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "route_plans", force: :cascade do |t|
    t.integer "salesManager_id", null: false
    t.datetime "start_date"
    t.datetime "end_date"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "sales_managers", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.string "password_digest"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end
create_table "gps_logs", force: :cascade do |t|
    t.integer "merchandiser", null: false
    t.string "latitude"
    t.string "longitude"
    t.datetime "gpsStarted"
    t.datetime "gpsStopped"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "merchandisers", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.string "password_digest"
    t.integer "salesManager", null: false
    t.integer "current_route_plan", null: false
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "outlets", force: :cascade do |t|
    t.string "name"
    t.string "latitude"
    t.string "longitude"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "route_plan_details", force: :cascade do |t|
    t.integer "routePlan", null: false
    t.integer "merchandiser", null: false
    t.integer "outlet", null: false
    t.string "date"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "route_plans", force: :cascade do |t|
    t.integer "salesManager", null: false
    t.datetime "start_date"
    t.datetime "end_date"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "sales_managers", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.string "password_digest"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end
api_key = ENV['SENDGRID_API_KEY']
<%= label_tag :search, "Type something to search", class: "sr-only" %>
<%= text_field_tag "search", params[:search] %>
<%= submit_tag "Search" %>
<%= form_for :form, html: { class: "inaccessible-form" } do |f| %>
  Product name: <%= f.text_field :product_name %>
  Description: <%= f.text_field :description %>
  In stock: <%= f.check_box :available %>
  <%= f.submit "Save" %>
<% end %>
# original code found at
# https://github.com/forem/forem/blob/8cbbc222e9a9c31f8cb8ab5e7b1df08c2109885b/app/views/admin/shared/_destroy_confirmation_modal.html.erb

<p id="confirmation-text-instructions">To confirm this update, type in the sentence: <br />
  <strong>My username is @<%= current_user.username %> and this action is 100% safe and appropriate.</strong>
</p>
<div id="mismatch-warning" class="crayons-notice crayons-notice--warning hidden" aria-live="polite">
  The confirmation text did not match.
</div>
  <input
    aria-label="Type the sentence above to confirm this update"
    aria-describedby="confirmation-text-instructions"
    type="text"
    id="confirmation-text-field"
    class="crayons-textfield flex-1 mr-2"
    placeholder="Confirmation text" />
</div>
describe SvgHelper do
  include SvgHelper

  describe '#inline_svg' do
    subject { inline_svg(svg, options) }
    let(:svg) do
      '<svg viewBox="0 0 10 20"><circle cx="50" cy="50" r="50"/></svg>'
    end
    let(:parsed_file) { Nokogiri::HTML::DocumentFragment.parse(svg) }

    before do
      allow(File).to receive(:read).and_return(parsed_file)
    end

    context "when no options are passed" do
      let(:options) { {} }

      it "returns hidden svg" do
        expect(subject).to include 'aria-hidden="true"'
      end
    end
    
    context "when options are passed" do
      let(:options) { { title: 'test', style: 'background-color:Blue' } }
      
      it "returns svg with a role of img" do
        expect(subject).to include 'role="img"'
      end

      it "adds title with correct id" do
        expect(subject).to include '<title id="svg-title">test</title>'
      end
      
      
      it "adds aria-labelledby attribute" do
        expect(subject).to include 'aria-labelledby="svg-title"'
      end

      it "updates svg styles" do
        expect(subject).to include 'style="background-color:Blue"'
      end
    end
  end
end
module SvgHelper
  def inline_svg(filename, options = {})
    parse_file(filename) if options.empty?

    svg = svg_from_file(filename)
    update_svg_attributes(svg, options)

    if options[:title].present?
      svg = build_with_title(svg, options[:title])
    else
      hide_svg(svg)
    end

    svg.to_html.html_safe
  end

  private

  def read_file(filename)
    File.read(Rails.root.join('app', 'assets', 'images', filename))
  end

  def parse_file(filename)
    file = read_file(filename)
    Nokogiri::HTML::DocumentFragment.parse(file)
  end

  def svg_from_file(filename)
    doc = parse_file(filename)
    doc.at_css('svg')
  end

  def update_svg_attributes(svg, options)
    svg['class'] = options[:class] if options[:class].present?
    svg['style'] = options[:style] if options[:style].present?
    svg['viewBox'] = options[:viewbox] if options[:viewbox].present?
  end

  def build_with_title(svg, title)
    svg['role'] = "img"
	svg['aria-labelledby'] = "svg-title"
    svg_tag = svg.to_s.match(/<svg .*/)
    svg_title = "<title id='svg-title'>#{title}</title>"
    svg_with_title = svg_tag.to_s + svg_title + svg.children.to_s + "</svg>"
    Nokogiri::HTML::DocumentFragment.parse(svg_with_title)
  end

  def hide_svg(svg)
    svg['aria-hidden'] = true
  end
end
<%= link_to "I'm technically a link", "#", class: "button" %>
What is your name? Stan
Adios. thtan!
matteast@192 thith-meanth-war % 
print "What is your name? "
user_input = gets.chomp.downcase!

if user_input.include? "s"

user_input.gsub!(/s/, "th")

else 
  print "There are no s's'"

end

puts "Adios. #{user_input}!"
<fieldset>
  <legend>Which color do you prefer?</legend>
  <%= form_for :color do |f| %>
    <%= radio_button :color, :select, :red %> 
    <%= label :color, :select_red, 'Red' %>
    <%= radio_button :color, :select, :green %> 
    <%= label :color, :select_green, 'Green' %>
    <%= radio_button :color, :select, :blue %>
    <%= label :color, :select_blue, 'Blue' %>
  <% end %>
</fieldset>
<%= f.input :username, label: 'Your username' %>
<%= f.input :username, label_html: { class: 'sr-only' } %>
 <%= form_for :product do |f| %>
  <%= f.label :product_name, "Product name" %>
  <%= f.text_field :product_name %>
  <%= f.label :description, "Description" %>
  <%= f.text_field :description %>
  <%= f.label :available, "In stock" %>
  <%= f.check_box :available %>
  <%= f.submit "Save" %>
<% end %>
<%= inline_svg 'edinburgh.svg', title: 'A drawing of the Edinburgh skyline on a purple background' %>
<%= inline_svg_tag('icon.svg', aria_hidden: true) %>
<%= inline_svg_tag('icon.svg',
    aria: true,
    title: 'An SVG',
    desc: 'This is my SVG. There are many like it. You get the picture')
%>
<%= image_tag "rails.png", alt: "Alternative text" %>
# with aria-live
<% flash.each do |msg| %>
  <p aria-live="polite" aria-atomic="true"><%= msg %></p>
<% end %>
 
# with role
<% flash.each do |msg| %>
  <p role="status"><%= msg %></p>
<% end %>
# original code found at
# https://github.com/forem/forem/blob/5e93d3a25ecc800703aa100d286c8c75c9173ddf/app/views/users/edit.html.erb#L77

<% if @user.unconfirmed_email.present? %>
  <div class="crayons-notice crayons-notice--warning mb-6" role="alert">
    <h3 class="mb-2"><%= t("views.settings.email") %></h3>
    <p><%= t("views.settings.finalize_html", email: link_to(@user.unconfirmed_email, "mailto:#{@user.unconfirmed_email}")) %></p>
  </div>
<% end %>
<%= form_for :product do |f| %>
  <%= f.label :product_name, "Product name" %>
  <%= f.text_field :product_name, required: true %>
  <%= f.submit "Save" %>
<% end %>
# original code found at
# https://github.com/forem/forem/blob/5e93d3a25ecc800703aa100d286c8c75c9173ddf/app/views/users/edit.html.erb#L63
  
 <% if current_user.email.blank? %>
  <div class="crayons-notice crayons-notice--warning mb-6" aria-live="polite">
    <h3 class="mb-2"><%= t("views.settings.complete.heading") %></h3>
    <p>
      <%= t("views.settings.complete.desc") %>
      <% if @user.twitter_username.blank? %>
        <%= t("views.settings.complete.twitter") %>
      <% elsif @user.github_username.blank? %>
        <%= t("views.settings.complete.github") %>
      <% end %>
    </p>
  </div>
<% end %>
package main

import (
  "fmt"
"strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://dink.ga/api/criarURL"
  payload := strings.NewReader("{\n\t\"url\": \"https://example.com\"\n}")
  req, _ := http.NewRequest("POST" url, payload)

  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://dink.ga/api/criarURL")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = "{\n\t\"url\": \"https://example.com\"\n}"

response = http.request(request)
puts response.read_body
1=> x = [1, 2, 5, 8]

2=> y = [2, 4, 5, 9]

3=> z = [3, 7]

4

5=> x.intersection(y) # x & y

6=> [2, 5]

7

8=> x.intersection(z) # x & z

9=> []
  def search
    baseurl = "https://api.themoviedb.org/3/discover/movie?api_key=#{ENV['REACT_APP_TMDB_API_KEY']}&language=en-						US&sort_by=popularity.desc&with_watch_monetization_types=flatrate&include_adult=false&include_video		=false&page=${moviePageIndex}";
    urladdon = params[:urlAddon]

    require 'uri'
    require 'net/http'

    uri = URI("#{baseurl}#{urladdon}")
    res = Net::HTTP.get_response(uri)

    if res.is_a?(Net::HTTPSuccess)
      render json: res.body
    else
      render json: res.body, status: :bad_request
    end
  end
# https://regex101.com/r/nOoiJ6/2
PAGINATION_PARAMETERS_REGEX = %r{
  \A                                      # Start of string
  (?:\s*)                                 # initial possible whitespace
  @(?<latitude>[-+]?\d{1,2}(?:[.,]\d+)?)  # latitude: @10.78472
  (?:\s*,\s*)                             # separator between latitude and longitude
  (?<longitude>[-+]?\d{1,3}(?:[.,]\d+)?)  # longitude: @-110
  (?:\s*,\s*)                             # separator between longitude and zoom
  (?<zoom>\d{1,2}(?:[.,]\d+)?)z           # zoom: 9.22
  \z                                      # End of string
}x

EARTH_RADIUS_IN_METERS = 6371010
TILE_SIZE = 256
SCREEN_PIXEL_HEIGHT = 768
RADIUS_X_PIXEL_HEIGHT = 27.3611 * EARTH_RADIUS_IN_METERS * SCREEN_PIXEL_HEIGHT

def pagination(ll, start)
  extracted_parameters = ll.match(PAGINATION_PARAMETERS_REGEX)

  return "" unless extracted_parameters

  "!4m8!1m3!1d" +
    altitude(extracted_parameters[:zoom].to_f, extracted_parameters[:latitude].to_f) +
    "!2d" +
    extracted_parameters[:longitude] +
    "!3d" +
    extracted_parameters[:latitude] +
    "!3m2!1i1024!2i768!4f13.1!7i20!8i" +
    (start || "0") +
    "!10b1!12m25!1m1!18b1!2m3!5m1!6e2!20e3!6m16!4b1!23b1!26i1!27i1!41i2!45b1!49b1!63m0!67b1!73m0!74i150000!75b1!89b1!105b1!109b1!110m0!10b1!16b1!19m4!2m3!1i360!2i120!4i8!20m65!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i240!7m50!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!22m3!1s!2z!7e81!24m55!1m15!13m7!2b1!3b1!4b1!6i1!8b1!9b1!20b0!18m6!3b1!4b1!5b1!6b1!13b0!14b0!2b1!5m5!2b1!3b1!5b1!6b1!7b1!10m1!8e3!14m1!3b1!17b1!20m4!1e3!1e6!1e14!1e15!24b1!25b1!26b1!29b1!30m1!2b1!36b1!43b1!52b1!54m1!1b1!55b1!56m2!1b1!3b1!65m5!3m4!1m3!1m2!1i224!2i298!89b1!26m4!2m3!1i80!2i92!4i8!30m28!1m6!1m2!1i0!2i0!2m2!1i458!2i768!1m6!1m2!1i974!2i0!2m2!1i1024!2i768!1m6!1m2!1i0!2i0!2m2!1i1024!2i20!1m6!1m2!1i0!2i748!2m2!1i1024!2i768!34m16!2b1!3b1!4b1!6b1!8m4!1b1!3b1!4b1!6b1!9b1!12b1!14b1!20b1!23b1!25b1!26b1!37m1!1e81!42b1!46m1!1e9!47m0!49m1!3b1!50m53!1m49!2m7!1u3!4s!5e1!9s!10m2!3m1!1e1!2m7!1u2!4s!5e1!9s!10m2!2m1!1e1!2m7!1u16!4s!5e1!9s!10m2!16m1!1e1!2m7!1u16!4s!5e1!9s!10m2!16m1!1e2!3m11!1u16!2m4!1m2!16m1!1e1!2s!2m4!1m2!16m1!1e2!2s!3m1!1u2!3m1!1u3!4BIAE!2e2!3m1!3b1!59B!65m0!69i540"
end

def altitude(zoom, latitude)
  ((RADIUS_X_PIXEL_HEIGHT * Math.cos((latitude * Math::PI) / 180)) / ((2 ** zoom) * TILE_SIZE)).to_s
end
def pagination(ll, start)
  extracted_parameters = ll.match(PAGINATION_PARAMETERS_REGEX)

  return "" unless extracted_parameters

  "!4m8!1m3!1d" +
    altitude(extracted_parameters[:zoom].to_f, extracted_parameters[:latitude].to_f) +
    "!2d" +
    extracted_parameters[:longitude] +
    "!3d" +
    extracted_parameters[:latitude] +
    "!3m2!1i1024!2i768!4f13.1!7i20!8i" +
    (start || "0") +
    "!10b1!12m25!1m1!18b1!2m3!5m1!6e2!20e3!6m16!4b1!23b1!26i1!27i1!41i2!45b1!49b1!63m0!67b1!73m0!74i150000!75b1!89b1!105b1!109b1!110m0!10b1!16b1!19m4!2m3!1i360!2i120!4i8!20m65!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i240!7m50!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!22m3!1s!2z!7e81!24m55!1m15!13m7!2b1!3b1!4b1!6i1!8b1!9b1!20b0!18m6!3b1!4b1!5b1!6b1!13b0!14b0!2b1!5m5!2b1!3b1!5b1!6b1!7b1!10m1!8e3!14m1!3b1!17b1!20m4!1e3!1e6!1e14!1e15!24b1!25b1!26b1!29b1!30m1!2b1!36b1!43b1!52b1!54m1!1b1!55b1!56m2!1b1!3b1!65m5!3m4!1m3!1m2!1i224!2i298!89b1!26m4!2m3!1i80!2i92!4i8!30m28!1m6!1m2!1i0!2i0!2m2!1i458!2i768!1m6!1m2!1i974!2i0!2m2!1i1024!2i768!1m6!1m2!1i0!2i0!2m2!1i1024!2i20!1m6!1m2!1i0!2i748!2m2!1i1024!2i768!34m16!2b1!3b1!4b1!6b1!8m4!1b1!3b1!4b1!6b1!9b1!12b1!14b1!20b1!23b1!25b1!26b1!37m1!1e81!42b1!46m1!1e9!47m0!49m1!3b1!50m53!1m49!2m7!1u3!4s!5e1!9s!10m2!3m1!1e1!2m7!1u2!4s!5e1!9s!10m2!2m1!1e1!2m7!1u16!4s!5e1!9s!10m2!16m1!1e1!2m7!1u16!4s!5e1!9s!10m2!16m1!1e2!3m11!1u16!2m4!1m2!16m1!1e1!2s!2m4!1m2!16m1!1e2!2s!3m1!1u2!3m1!1u3!4BIAE!2e2!3m1!3b1!59B!65m0!69i540"
end
PAGINATION_PARAMETERS_REGEX = %r{
  \A                                      # Start of string
  (?:\s*)                                 # initial possible whitespace
  @(?<latitude>[-+]?\d{1,2}(?:[.,]\d+)?)  # latitude: @10.78472
  (?:\s*,\s*)                             # separator between latitude and longitude
  (?<longitude>[-+]?\d{1,3}(?:[.,]\d+)?)  # longitude: @-110
  (?:\s*,\s*)                             # separator between longitude and zoom
  (?<zoom>\d{1,2}(?:[.,]\d+)?)z           # zoom: 9.22
  \z                                      # End of string
}x
EARTH_RADIUS_IN_METERS = 6371010
TILE_SIZE = 256
SCREEN_PIXEL_HEIGHT = 768
RADIUS_X_PIXEL_HEIGHT = 27.3611 * EARTH_RADIUS_IN_METERS * SCREEN_PIXEL_HEIGHT

def altitude(zoom, latitude)
  (RADIUS_X_PIXEL_HEIGHT * Math.cos((latitude * Math::PI) / 180)) / ((2 ** zoom) * TILE_SIZE)
end
$ bundle exec rails runner 'puts Search.new(engine: :google_maps, q: "coffee", lat: 36.3996184, long: -113.9511419, alt: 2124931.1267513777, offset: 20, psi: "rZkJYJuoINHmrgTP1IVI").query_randomized' | xargs curl -s -k -x $HTTP_PROXY -A 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.46' - > f.txt

# "https://www.google.com/search?tbm=map&authuser=0&hl=en&gl=ua&pb=!4m8!1m3!1d2124931.1267513777!2d36.3996184!3d-113.9511419!3m2!1i1024!2i768!4f13.1!7i20!8i20!10b1!12m25!1m1!18b1!2m3!5m1!6e2!20e3!6m16!4b1!23b1!26i1!27i1!41i2!45b1!49b1!63m0!67b1!73m0!74i150000!75b1!89b1!105b1!109b1!110m0!10b1!16b1!19m4!2m3!1i360!2i120!4i8!20m65!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i240!7m50!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!22m3!1sgpYJYKSwMsH9rgT0_7nAAg!2zMWk6Mix0OjEyNjk2LGU6MSxwOmdwWUpZS1N3TXNIOXJnVDBfN25BQWc6MjM!7e81!24m55!1m15!13m7!2b1!3b1!4b1!6i1!8b1!9b1!20b0!18m6!3b1!4b1!5b1!6b1!13b0!14b0!2b1!5m5!2b1!3b1!5b1!6b1!7b1!10m1!8e3!14m1!3b1!17b1!20m4!1e3!1e6!1e14!1e15!24b1!25b1!26b1!29b1!30m1!2b1!36b1!43b1!52b1!54m1!1b1!55b1!56m2!1b1!3b1!65m5!3m4!1m3!1m2!1i224!2i298!89b1!26m4!2m3!1i80!2i92!4i8!30m28!1m6!1m2!1i0!2i0!2m2!1i458!2i768!1m6!1m2!1i974!2i0!2m2!1i1024!2i768!1m6!1m2!1i0!2i0!2m2!1i1024!2i20!1m6!1m2!1i0!2i748!2m2!1i1024!2i768!34m17!2b1!3b1!4b1!6b1!7b1!8m4!1b1!3b1!4b1!6b1!9b1!12b1!14b1!20b1!23b1!25b1!26b1!37m1!1e81!42b1!46m1!1e9!47m0!49m1!3b1!50m72!1m68!2m7!1u3!4sOpen+now!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCMgJKBY!10m2!3m1!1e1!2m7!1u2!4sTop+rated!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCMkJKBc!10m2!2m1!1e1!2m7!1u1!4sCheap!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCMoJKBg!10m2!1m1!1e1!2m7!1u1!4sUpscale!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCMsJKBk!10m2!1m1!1e2!2m7!1u16!4sVisited!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCMwJKBo!10m2!16m1!1e1!2m7!1u16!4sHaven%27t+visited!5e1!9s0ahUKEwizhPrmpK3uAhXBvosKHfR_DigQ_KkBCM0JKBs!10m2!16m1!1e2!3m11!1u16!2m4!1m2!16m1!1e1!2sVisited!2m4!1m2!16m1!1e2!2sHaven%27t+visited!3m1!1u2!3m2!1u1!3e0!3m1!1u3!4BIAE!2e2!3m1!3b1!59BQ2dBd0Fn!65m0!69i540&q=coffee&tch=1&ech=1&psi=rZkJYJuoINHmrgTP1IVI.1611241093531.1"

# Hit next page in browser, copy URL and curl it.

$ curl -s -k -x $HTTP_PROXY -A 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.46' 'https://www.google.com/search?tbm=map&authuser=0&hl=en&gl=ua&pb=!4m8!1m3!1d2124931.1267513777!2d-113.9511419!3d36.3996184!3m2!1i1024!2i768!4f13.1!7i20!8i20!10b1!12m25!1m1!18b1!2m3!5m1!6e2!20e3!6m16!4b1!23b1!26i1!27i1!41i2!45b1!49b1!63m0!67b1!73m0!74i150000!75b1!89b1!105b1!109b1!110m0!10b1!16b1!19m4!2m3!1i360!2i120!4i8!20m65!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i240!7m50!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!22m3!1srZkJYJuoINHmrgTP1IVI!2zMWk6Mix0OjEyNjk2LGU6MSxwOnJaa0pZSnVvSU5IbXJnVFAxSVZJOjIz!7e81!24m55!1m15!13m7!2b1!3b1!4b1!6i1!8b1!9b1!20b0!18m6!3b1!4b1!5b1!6b1!13b0!14b0!2b1!5m5!2b1!3b1!5b1!6b1!7b1!10m1!8e3!14m1!3b1!17b1!20m4!1e3!1e6!1e14!1e15!24b1!25b1!26b1!29b1!30m1!2b1!36b1!43b1!52b1!54m1!1b1!55b1!56m2!1b1!3b1!65m5!3m4!1m3!1m2!1i224!2i298!89b1!26m4!2m3!1i80!2i92!4i8!30m28!1m6!1m2!1i0!2i0!2m2!1i458!2i768!1m6!1m2!1i974!2i0!2m2!1i1024!2i768!1m6!1m2!1i0!2i0!2m2!1i1024!2i20!1m6!1m2!1i0!2i748!2m2!1i1024!2i768!34m17!2b1!3b1!4b1!6b1!7b1!8m4!1b1!3b1!4b1!6b1!9b1!12b1!14b1!20b1!23b1!25b1!26b1!37m1!1e81!42b1!46m1!1e9!47m0!49m1!3b1!50m72!1m68!2m7!1u3!4sOpen+now!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCN8KKBY!10m2!3m1!1e1!2m7!1u2!4sTop+rated!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCOAKKBc!10m2!2m1!1e1!2m7!1u1!4sCheap!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCOEKKBg!10m2!1m1!1e1!2m7!1u1!4sUpscale!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCOIKKBk!10m2!1m1!1e2!2m7!1u16!4sVisited!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCOMKKBo!10m2!16m1!1e1!2m7!1u16!4sHaven%27t+visited!5e1!9s0ahUKEwig-8Lpp63uAhVRs4sKHU9qAQkQ_KkBCOQKKBs!10m2!16m1!1e2!3m11!1u16!2m4!1m2!16m1!1e1!2sVisited!2m4!1m2!16m1!1e2!2sHaven%27t+visited!3m1!1u2!3m2!1u1!3e0!3m1!1u3!4BIAE!2e2!3m1!3b1!59BQ2dBd0Fn!65m0!69i540&q=coffee&tch=1&ech=1&psi=rZkJYJuoINHmrgTP1IVI.1611241905488.1' > correct.txt

# Compare f.txt and correct.txt in a text editor - they almost the same.
if offset
  long ||= -73.91476977539236
  lat ||= 40.68525694561602
  alt ||= 120027.44487325678

  offset ||= 40

  psi ||= "b24JYPPGOoaJrwTXlbHACw"

  google_query = "#{query_scheme_and_domain}/search?tbm=map&authuser=0&hl=en&gl=ua&pb=!4m12!1m3!1d#{alt}!2d#{lat}!3d#{long}!2m3!1f0!2f0!3f0!3m2!1i1920!2i549!4f13.1!7i20!8i#{offset}!10b1!12m8!1m1!18b1!2m3!5m1!6e2!20e3!10b1!16b1!19m4!2m3!1i360!2i120!4i8!20m65!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i240!7m50!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!22m3!1s#{psi}!2s1i%3A2%2Ct%3A12696%2Ce%3A1%2Cp%3A#{psi}%3A1273!7e81!24m56!1m16!13m7!2b1!3b1!4b1!6i1!8b1!9b1!20b0!18m7!3b1!4b1!5b1!6b1!9b1!13b0!14b0!2b1!5m5!2b1!3b1!5b1!6b1!7b1!10m1!8e3!14m1!3b1!17b1!20m4!1e3!1e6!1e14!1e15!24b1!25b1!26b1!29b1!30m1!2b1!36b1!43b1!52b1!54m1!1b1!55b1!56m2!1b1!3b1!65m5!3m4!1m3!1m2!1i224!2i298!89b1!26m4!2m3!1i80!2i92!4i8!30m28!1m6!1m2!1i0!2i0!2m2!1i458!2i549!1m6!1m2!1i1870!2i0!2m2!1i1920!2i549!1m6!1m2!1i0!2i0!2m2!1i1920!2i20!1m6!1m2!1i0!2i529!2m2!1i1920!2i549!31b1!34m16!2b1!3b1!4b1!6b1!8m4!1b1!3b1!4b1!6b1!9b1!12b1!14b1!20b1!23b1!25b1!26b1!37m1!1e81!42b1!46m1!1e9!47m0!49m1!3b1!50m73!1m68!2m7!1u3!4sOpen+now!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNUJKBg!10m2!3m1!1e1!2m7!1u2!4sTop+rated!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNYJKBk!10m2!2m1!1e1!2m7!1u1!4sCheap!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNcJKBo!10m2!1m1!1e1!2m7!1u1!4sUpscale!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNgJKBs!10m2!1m1!1e2!2m7!1u16!4sVisited!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNkJKBw!10m2!16m1!1e1!2m7!1u16!4sHaven%27t+visited!5e1!9s0ahUKEwiPrMCgia3uAhUjlYsKHanUBmYQ_KkBCNoJKB0!10m2!16m1!1e2!3m1!1u3!3m1!1u2!3m2!1u1!3e1!3m11!1u16!2m4!1m2!16m1!1e1!2sVisited!2m4!1m2!16m1!1e2!2sHaven%27t+visited!4BIAE!2e2!3m2!1b1!3b1!59BQ2dBd0Fn!65m0!69i540&q=#{safe_query}&tch=1&ech=1&psi=#{psi}.1611230833287.1"
end
class Bear
  def eat(food)
    raise "#{food} is not edible!" unless food.respond_to? :nutrition_value
    food.nutrition_value
  end
end
class Bear
  def hunt
    forest.select(&:food?)
  end
end
def extract_js_image(image_node)
  return unless image_node
  
  thumbnail_id = image_node["id"]
  return unless thumbnail_id
  
  if (found_thumbnail = extracted_thumbnails[thumbnail_id])
    JSUtils.unescape(found_thumbnail)
  end
end
def extracted_thumbnails
  return @extracted_thumbnails if @extracted_thumbnails.present?
  
  js_image_regexes = JS_IMAGE_REGEXES.detect { |key, _| engine.starts_with?(key.to_s) }&.last || JS_IMAGE_REGEXES[:all]
@extracted_thumbnails = js_image_regexes.collect { |regex|
    regex_capture_names = regex.names
thumbnail_index = regex_capture_names.index(THUMBNAIL_CAPTURE_NAME)
    thumbnail_id_index = regex_capture_names.index(THUMBNAIL_ID_CAPTURE_NAME)

    html.scan(regex).collect do |match|
      found_thumbnail = match[thumbnail_index]
      found_thumbnail_id = match[thumbnail_id_index]

      found_thumbnail_id.split(",").map { |thumb| Hash[thumb.tr("'", "").squish, found_thumbnail] }
    end
  }.flatten.inject(:merge) || {}
end
# tmp/profiler.rb

require "ruby-prof"

profile = RubyProf.profile do
  search_params = { engine: "google", q: "roller blades", location: "Austin, United States", google_domain: "google.com", hl: "en", gl: "us", num: "500", device: "desktop", tbm: "shop", tbs: "p_ord:rv", file_path: "tmp/roller-blades.html" }

  Search.new(search_params).parse!
end

printer = RubyProf::FlatPrinter.new(profile)
printer.print($stdout, min_percent: 2)
    support_price = order.site.price_for_support(
      addons.find_by(group: "support"),
      order.should_show_incentive_addon_prices?
    ) * facilitators
require 'pry'

class String

  def sentence?
    self.end_with?(".")
  end

  def count_sentences
    self.split(/\.|\?|\!/).delete_if {|w| w.size < 2}.size
  end
end
array.each do |item|
  puts "The current array item is: #{item}"
end
 # Single line comment

=begin
multiline
comment
=end
namespace :javascript do
  desc "Compiles each js file"
  task validate: :environment do
    JS_PATH = "app/assets/javascripts/**/*.js"
    Dir[JS_PATH].each do |file_name|
      puts "\n#{file_name}"
      puts Uglifier.compile(File.read(file_name))
    end
  end
end
file = "#{Rails.root}/public/users.csv"
headers = ["Name", "Company Name", "Email", "Role", "Team Name"]
CSV.open(file, 'w', write_headers: true, headers: headers) do |writer|
    Team.all.each do |team|
      team.users.each do |user|
        writer << [user.name, user.company_name , user.email, user.roles&.first&.name, team.name]
      end
    end
  end
star

Tue Jul 23 2024 10:01:20 GMT+0000 (Coordinated Universal Time) https://dhanusir.com/ruby-on-rails/section-three/app-idea-model

#ruby #rubyonrails
star

Fri Jun 07 2024 08:30:13 GMT+0000 (Coordinated Universal Time) https://www.dappfort.com/bybit-clone-script/

#ruby #nodejs #json #react.js #css
star

Tue Aug 08 2023 08:05:07 GMT+0000 (Coordinated Universal Time) https://currencyapi.com/docs/examples/ruby-currency-converter

#ruby ##currencyconverter
star

Sun Jun 18 2023 10:40:24 GMT+0000 (Coordinated Universal Time) https://en.wikipedia.org/wiki/Hello_(Adele_song)

#ruby
star

Tue Apr 18 2023 23:18:43 GMT+0000 (Coordinated Universal Time)

#ruby
star

Tue Apr 18 2023 23:12:09 GMT+0000 (Coordinated Universal Time)

#ruby
star

Tue Apr 18 2023 21:11:45 GMT+0000 (Coordinated Universal Time)

#ruby
star

Wed Jan 04 2023 00:07:10 GMT+0000 (Coordinated Universal Time) https://docs.sendgrid.com/ui/account-and-settings/api-keys

#ruby
star

Thu Dec 22 2022 18:55:36 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Thu Dec 22 2022 18:45:10 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Sat Dec 17 2022 10:15:00 GMT+0000 (Coordinated Universal Time) https://github.com/forem/forem/blob/8cbbc222e9a9c31f8cb8ab5e7b1df08c2109885b/app/views/admin/shared/_destroy_confirmation_modal.html.erb#L16

#ruby #rubyonrails
star

Wed Dec 14 2022 21:08:03 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Wed Dec 14 2022 21:02:50 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Tue Jul 19 2022 21:44:39 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Tue Jun 28 2022 15:01:28 GMT+0000 (Coordinated Universal Time)

#ruby
star

Tue Jun 28 2022 14:08:23 GMT+0000 (Coordinated Universal Time)

#ruby
star

Fri Jun 17 2022 09:38:30 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:36:50 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:35:26 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:32:50 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:31:08 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:28:08 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:25:48 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:18:45 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:16:41 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:14:18 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:12:40 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Fri Jun 17 2022 09:07:51 GMT+0000 (Coordinated Universal Time) https://github.com/forem/forem/blob/5e93d3a25ecc800703aa100d286c8c75c9173ddf/app/views/users/edit.html.erb#L63

#ruby #rubyonrails
star

Sun Jun 05 2022 15:31:34 GMT+0000 (Coordinated Universal Time)

#ruby
star

Sun Jun 05 2022 15:28:39 GMT+0000 (Coordinated Universal Time)

#ruby
star

Fri May 28 2021 14:33:01 GMT+0000 (Coordinated Universal Time) https://bigbinary.com/blog/ruby-3-1-adds-array-intersect

#ruby
star

Mon May 24 2021 18:07:47 GMT+0000 (Coordinated Universal Time)

#react #api #ruby #rubyonrails
star

Mon Mar 08 2021 16:02:07 GMT+0000 (Coordinated Universal Time) https://en.wikipedia.org/wiki/Separation_of_concerns

#ruby
star

Mon Mar 08 2021 16:01:47 GMT+0000 (Coordinated Universal Time) https://en.wikipedia.org/wiki/Separation_of_concerns

#ruby
star

Tue Feb 09 2021 10:06:00 GMT+0000 (Coordinated Universal Time)

#json #ruby #webscraping #serpapi
star

Tue Feb 09 2021 10:03:03 GMT+0000 (Coordinated Universal Time)

#json #ruby #webscraping #serpapi
star

Tue Feb 09 2021 09:46:46 GMT+0000 (Coordinated Universal Time) https://medium.com/serpapi/how-we-sped-up-data-extraction-from-html-from-3s-to-800ms-or-how-to-profile-and-optimize-ruby-3390d69bce91

#ruby #webscraping #serpapi
star

Wed Feb 03 2021 20:52:35 GMT+0000 (Coordinated Universal Time)

#ruby
star

Thu Dec 03 2020 20:21:58 GMT+0000 (Coordinated Universal Time) https://github.com/learn-co-students/ruby-oo-self-count-sentences-lab-dumbo-web-010620/blob/solution/lib/count_sentences.rb

#ruby
star

Thu Aug 13 2020 18:18:29 GMT+0000 (Coordinated Universal Time) https://medium.com/forest-admin/rails-migrations-tricks-guide-code-cheatsheet-included-dca935354f22

#rubyonrails #ruby
star

Thu Aug 13 2020 18:17:17 GMT+0000 (Coordinated Universal Time) https://medium.com/forest-admin/rails-migrations-tricks-guide-code-cheatsheet-included-dca935354f22

#rubyonrails #ruby
star

Wed Aug 12 2020 22:24:08 GMT+0000 (Coordinated Universal Time) https://www.google.com/search?q=ruby foreach

#ruby
star

Tue Aug 11 2020 22:31:06 GMT+0000 (Coordinated Universal Time) https://www.google.com/search?q=ruby multiline comment

#ruby
star

Mon May 18 2020 19:08:51 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/37512603/rails-attach-some-data-to-head-ok-response

#ruby #rubyonrails
star

Mon May 11 2020 16:41:09 GMT+0000 (Coordinated Universal Time)

#ruby #rubyonrails
star

Mon May 11 2020 16:38:22 GMT+0000 (Coordinated Universal Time) custom

#ruby #rubyonrails

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension