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
/** | |
* Google Sheet: | |
* https://docs.google.com/spreadsheets/d/1rkPwzZIE60Tjdk-Rq18tewy48vdpWk1dSD3wr4wp81w/copy | |
* | |
* For more info see: | |
* https://medium.com/@hisa_py/google-sheet-to-track-job-search-68c88c699d33 | |
*/ | |
// globals | |
var STATUS_COLUMN = 12; |
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
/* | |
Given props routeIndices such as [0, 2, 2, 4] and routes such as [RouteObj, RouteObj] passed to a React component, | |
use the routeIndices to traverse down the routes tree, via RouteObj children, to get the RouteObj title attribute. | |
For example, a <Route title="Home" /> from Found. | |
*/ | |
getTitleFromRouteImperative() { | |
const { routeIndices, routes } = this.props; |
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
## | |
# Inspired in: | |
# https://github.com/robinroestenburg/tamingthemindmonkey-sinatra/blob/master/posts/2011-11-07-capybara-matchers-and-scoping-in-view-specs.markdown | |
# and | |
# https://github.com/jnicklas/capybara/blob/d087965f8110f4098a11f52bb18edea88df277ac/lib/capybara/session.rb#L281 | |
# I created my own nestable version of within() scope matcher | |
# | |
# Just put this in spec/support/view_helpers.rb | |
# | |
# Examples |
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 Client | |
has_many :sales, dependent: :restrict_with_error | |
# This is an example of how to use an Arel projection inside a select list. | |
scope :with_sales_totals, -> { | |
clients = arel_table | |
sales = Sale.arel_table | |
# this is will be agregated in the final query in the select list | |
receivables_sum = sales |
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
hash_tree = {} # hash where all the members are also hashes, even the "leaf nodes" | |
def xml_node(node, children, xml) | |
xml.send(node){ | |
children.each do | n, c | | |
xml_node(n, c, xml) | |
end | |
} | |
end | |
builder = Nokogiri::XML::Builder.new do | xml | |
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
# This is an excerpt from a spec_helper file with a section to configure VCR | |
# | |
# In lines 30 and 32 you can see examples of how to call a VCR registered request matcher from inside another. | |
# This is useful when running an example that makes a request to multiple external resources or APIs. | |
# Without this the requests were recorded the 1st time but subsequent requests raised VCR::Errors::UnhandledHTTPRequestError | |
VCR.configure do |c| | |
c.ignore_localhost = true | |
c.cassette_library_dir = 'spec/cassettes' | |
c.hook_into :webmock |
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
#!/usr/bin/env ruby | |
require 'getoptlong' | |
opts = GetoptLong.new( | |
[ '--help', '-h', GetoptLong::NO_ARGUMENT ], | |
[ '--rspec-command', '-r', GetoptLong::REQUIRED_ARGUMENT ], | |
[ '--suite-output-file', '-f', GetoptLong::REQUIRED_ARGUMENT ] | |
) |
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
//This depends on jquery and persistencejs. | |
/** | |
* Given a"model" Product. Instances of Product persist their data to Web SQL (persistencejs) | |
*/ | |
var Product = persistence.define('products', { | |
name: 'TEXT', | |
image_path: 'TEXT', | |
created_at: 'DATE', | |
updated_at: 'DATE' |
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
$.ajax({ | |
crossDomain: true, | |
type: "GET", | |
url: "https://ws.elfarosrl.net:3000/categories", | |
contentType: "application/json; charset=utf-8", | |
data:{ | |
access_token: "a7632c8200bc27b95ed11c999ff20c944dfbb0a8", | |
last_imported_at: -1 | |
} | |
}).done(function(data, textStatus, jqXHR){ |
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
# Given the following | |
ExitPoll.select('listas.id, numero, listas.nombre, listas.color') | |
.joins(:chapa_presidencial) | |
.count(group: :chapa_presidencial) | |
# Rails executes the following 2 SQL queries | |
SELECT COUNT(*) AS count_all, chapa_presidencial_id AS chapa_presidencial_id | |
FROM `exit_polls` INNER JOIN `listas` ON `listas`.`id` = `exit_polls`.`chapa_presidencial_id` | |
GROUP BY chapa_presidencial_id |
NewerOlder