These two matchers are referenced from the blog post Segment.io and Ruby.
This file contains 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
name: CI | |
on: [push] | |
jobs: | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12 |
This file contains 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
factory :post do | |
title "Example Post" | |
body "This is the body of the example post" | |
meta { { version: 2 } } | |
# or | |
meta({ version: 2 }) | |
created_at "2012-06-01 17:53:13" | |
end |
This file contains 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
require "money" | |
class Decorator < BasicObject | |
undef_method :== | |
def initialize(component) | |
@component = component | |
end | |
def method_missing(name, *args, &block) |
This file contains 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
web: bundle exec puma -C config/puma.rb | |
webpack: bin/webpack-dev-server | |
livereload: watchexec -w app/views touch app/javascript/packs/application.js |
This file contains 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
diff --git a/src/attributes.rs b/src/attributes.rs | |
index e1641b2..a03d803 100644 | |
--- a/src/attributes.rs | |
+++ b/src/attributes.rs | |
@@ -38,7 +38,9 @@ fn evaluate_attribute_value_components<'a>( | |
.iter() | |
.map(|v| match v { | |
AttributeValueComponent::RawValue(value) => value.to_string(), | |
- AttributeValueComponent::InterpolatedValue(values) => context.interpret(values), | |
+ AttributeValueComponent::InterpolatedValue(values) => { |
This file contains 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
WITH weeks AS ( | |
SELECT generate_series('2008-12-29'::date, now(), '7 days'::interval)::date AS week | |
) | |
SELECT | |
j.id AS category_id, | |
weeks.week, | |
COALESCE(SUM(t.amount), 0) AS weekly_spend, | |
COALESCE(MIN(t.amount), 0) AS minimum_spend, | |
COALESCE(MAX(t.amount), 0) AS maximum_spend, | |
COUNT(t.amount) AS transaction_count, |
This file contains 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
use chrono::prelude::*; | |
// weeks | |
pub fn beginning_of_week(date: &NaiveDate) -> Option<NaiveDate> { | |
if date.weekday() == Weekday::Sun { | |
Some(date.clone()) | |
} else { | |
NaiveDate::from_isoywd_opt(date.iso_week().year(), date.iso_week().week(), Weekday::Sun) | |
.map(|d| d - chrono::Duration::weeks(1)) |
This file contains 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
def recursive_flatten(input, keys = [], acc = {}) | |
input.keys.each do |k| | |
result_key = keys + [k] | |
if input[k].is_a?(Hash) | |
recursive_flatten(input[k], keys + [k], acc) | |
elsif input[k].is_a?(Array) && input[k].any? {|v| v.is_a?(Hash) } | |
input[k].each_with_index do |array_value, index| | |
result_key_with_index = keys + [k, "[#{index}]"] |
This file contains 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
require 'rubygems' | |
# what about this? |
NewerOlder