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
// 1.- This mixin works when you add class retina by JavaScript to html tag or when you use media queries | |
// 2.- This solution works with the sprites of http://compass-style.org/ | |
// 3.- If your retina sprite have a diferente size with your regular sprite you can set the image with the folowing mixin: | |
$icons-retina: sprite-map("icons-retina/*.png"); | |
@mixin background-retina($file-name) { | |
background: $icons-retina; | |
$ypos: round(nth(sprite-position($icons-retina, $file-name), 2) / 2); | |
background-position: 0 $ypos; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Simple JavaScrip Test</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script> | |
/* | |
Please put inside the div with id 'app' the last 5 posts (ordered by id) |
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
useEffect(() => { | |
// Do something | |
}, [firstValue, secondValue]); | |
// "Do something" will be executed | |
// every time that firstValue OR secondValue change | |
// because if any value change we are getting a different array |
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
useEffect(() => { | |
// Do something | |
}, []); | |
// Just the first render every time this component is mounted |
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
// GOOD! Place the condition inside the Hook | |
useEffect(() => { | |
if (posts === null) { | |
// This will run only if posts are not still fetched. | |
// If you mount this component more than once, | |
// the request won't beexecuted again | |
getPosts(); | |
} | |
}, []); // Besides, with the empty array this Effect just run once |
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
# ===== MULTISEARCH ===== # | |
include PgSearch::Model | |
multisearchable against: [:attributes, :you, :want, :to, :index] | |
def search(query) | |
found_ids = PgSearch.multisearch(query).pluck(:searchable_id) | |
YourModel.where(id: found_ids) | |
end | |
# configure type search options | |
PgSearch.multisearch_options = { | |
using: :tsearch |
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
class AddTsvectorColumnToYourModel < ActiveRecord::Migration[5.2] | |
def up | |
# 1. Add column to your model | |
add_column :your_model, :tsv_column_name, :tsvector | |
# 2. Create index | |
add_index(:webpros, :tsv_webpros, using: 'gin') | |
say_with_time("Adding trigger function on webpros for updating tsv_webpros column") do | |
# 3. Add trigger | |
execute <<-SQL |
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
if defined?(Rack::Cors) | |
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins 'www.getonbrd.com', 'cludfront-url.net' | |
resource '*', headers: :any, methods: [:get, :post, :options] | |
end | |
end | |
end |