Skip to content

Instantly share code, notes, and snippets.

@valikos
valikos / sequel_scopes.rb
Created July 1, 2022 12:51 — forked from odigity/sequel_scopes.rb
The Sequel Gem: Everything About Scopes
# (I recommend understanding the basics of this first: http://sequel.jeremyevans.net/rdoc/files/doc/object_model_rdoc.html)
# Extending the underlying dataset (http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Extending+the+underlying+dataset)
# The recommended way to implement table-wide logic by defining methods on the dataset using dataset_module:
class Post < Sequel::Model
dataset_module do
def posts_with_few_comments
where{num_comments < 30}

Keybase proof

I hereby claim:

  • I am valikos on github.
  • I am valikos (https://keybase.io/valikos) on keybase.
  • I have a public key ASAFNgo1ArmpXEgWEJQ-tNZoNNTOO19jKthlz549Xnc_Ngo

To claim this, I am signing this object:

@valikos
valikos / caniuse-browsers-data.rb
Created October 7, 2020 11:48
caniuse browsers data
url = 'https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json'
res = Faraday.get(url)
@valikos
valikos / t.rb
Last active October 6, 2019 17:43
t
require "test_prof/recipes/rspec/let_it_be"
describe BeatleWeightedSearchQuery do
let!(:paul) { create(:beatle, name: "Paul") }
let!(:ringo) { create(:beatle, name: "Ringo") }
let!(:george) { create(:beatle, name: "George") }
let!(:john) { create(:beatle, name: "John") }
specify { expect(subject.call("john")).to contain_exactly(john) }
{
"data": {
"me": {
"firstName": "Valentyn",
"lastName": "Ostakh",
"company": "RubyGarage",
"position": "Ruby/JS developer",
"socialLinks": [
{
"name": "facebook",
query {
me {
firstName
lastName
company
position
socialLinks {
name
url
}
class MySchema < GraphQL::Schema
# Required:
query Types::Query
# Optional:
mutation Types::Mutation
subscription Types::Subscription
end
# app/graphql/types/query_type.rb
class Types::QueryType < GraphQL::Schema::Object
schema {
query: Query
mutation: Mutation
}
type Query {
character(id: ID!): CharacterType
}
schema {
class Directives::Camelize < GraphQL::Schema::Directive
description "..."
locations(
GraphQL::Schema::Directive::FIELD,
GraphQL::Schema::Directive::FRAGMENT_SPREAD,
GraphQL::Schema::Directive::INLINE_FRAGMENT
)
argument :if, Boolean, required: true, description: "..."
module Types::Interfaces::Node
include Types::BaseInterface
field :id, ID, null: false
end
module Types::Interfaces::Person
include Types::BaseInterface
field :first_name, String, null: false