Skip to content

Instantly share code, notes, and snippets.


Seb sebastian-palma

View GitHub Profile
View notesthelperrequire_cop.rb
# frozen_string_literal: true
module RuboCop
module Cop
module Custom
# Looks for the require of the rails_helper or spec_helper and raises
# a warning as those files are set to be included through the .rspec
# file.
# On auto correction it just deletes those lines.
View How do i get instance of a model with highest value from an operation?
Director.create(first_name: "Martin Scorsese", date_of_birth: "17/11/1942", id: 2)
Director.create(first_name: "Michael Bay", date_of_birth: "17/02/1965", id: 3)
Director.create(first_name: "George Lucas", date_of_birth: "14/05/1944", id: 1)
Movie.create(name: "Star Wars: Epizoda IV – Nová naděje", release_date: "25/05/1977", description: "", director_id: 1)
Movie.create(name: "Star Wars: Epizoda III – Pomsta Sithů", release_date: "15/05/2005", description: "", director_id: 1)
Movie.create(name: "Skrytá identita", release_date: "06/10/2006", description: "", director_id: 2)
Movie.create(name: "Mizerové", release_date: "07/04/1995", description: "", director_id: 3)
View viz.json
{"id":"06a4194c4b016917","slug":null,"trashed":false,"description":"","like":false,"likes":0,"publish_level":"private","forks":0,"fork_of":{"id":"17468271a273819d","slug":"visualizing-chess-games","title":"Visualizing chess games","owner":{"id":"9ba5e0b68d3e7972","github_login":"EE2dev","avatar_url":"","login":"ee2dev","name":"","bio":"","home_url":"","type":"individual"},"version":698},"update_time":"2021-05-21T20:12:48.480Z","publish_time":null,"publish_version":null,"thumbnail":null,"default_thumbnail":null,"roles":["editor","owner"],"sharing":"private","subscription":"comments","edit_unpublished":false,"owner":{"id":"77ad7d1d53486a0d","github_login":"sebastian-palma","avatar_url":"","login":"sebastian-palma","name":"Sebastián","bio":"","home_url":"","type":"individual"},"creator":{"id":"77ad7d1d53486a0d","github_login":"sebastian-palma","avatar_url":"https://avatars.githubuserc
View includes.rb
[1] pry(main)> Site.includes(:site_links).where.not(site_links: { active: true })
SQL (0.7ms) SELECT "sites"."id" AS t0_r0, "sites"."name" AS t0_r1, "sites"."created_at" AS t0_r2, "sites"."updated_at" AS t0_r3, "site_links"."id" AS t1_r0, "site_links"."site_id" AS t1_r1, "site_links"."link_id" AS t1_r2, "site_links"."active" AS t1_r3, "site_links"."created_at" AS t1_r4, "site_links"."updated_at" AS t1_r5 FROM "sites" LEFT OUTER JOIN "site_links" ON "site_links"."site_id" = "sites"."id" WHERE "site_links"."active" != $1 [["active", true]]
=> [#<Site:0x0000560ffba92250 id: 1, name: "first", created_at: Sun, 28 Mar 2021 18:46:03.661861000 UTC +00:00, updated_at: Sun, 28 Mar 2021 18:46:03.661861000 UTC +00:00>,
#<Site:0x0000560ffba90428 id: 2, name: "second", created_at: Sun, 28 Mar 2021 18:46:06.263937000 UTC +00:00, updated_at: Sun, 28 Mar 2021 18:46:06.263937000 UTC +00:00>]
[2] pry(main)> Site.includes(:site_links).where.not(" = true")
Site Load (1.0ms) SELECT "sites".* FROM "sites"
set -x PATH $HOME/.rbenv/bin $PATH
rbenv init - | source
View main.log
:debug:sysinfo macOS 10.14 (darwin/18.6.0) arch i386
:debug:sysinfo MacPorts 2.6.3
:debug:sysinfo Xcode none
:debug:sysinfo SDK 10.14
:debug:sysinfo MACOSX_DEPLOYMENT_TARGET: 10.14
:debug:main Found Dependency: path: /usr/bin filename: git regex: ^git$
:debug:main epoch: in tree: 0 installed: 0
:debug:main sbcl 2.0.6_0 exists in the ports tree
:debug:main sbcl 2.0.6_0 +fancy is the latest installed

Warming up -------------------------------------- Array#each 45.102k i/100ms Hash::[] 36.133k i/100ms Enumerable#map 38.767k i/100ms Enumerable#each_with_object 42.234k i/100ms Object#tap 42.185k i/100ms Enumerable#to_h 44.715k i/100ms Enumerable#index_by 41.212k i/100ms Calculating -------------------------------------

View asyncapi01.yml
asyncapi: 2.0.0
title: Streetlights API
version: '1.0.0'
description: |
The Smartylighting Streetlights API allows you to remotely manage the city lights.
### Check out its awesome features:
* Turn a specific streetlight on/off 🌃
$ bundle exec rails db:migrate
== 20191101233132 ExtendExecutionDatetimePrecision: migrating =================
-- change_column(:executions, :order_insert_time, :datetime, {:limit=>6})
   -> 0.0912s
== 20191101233132 ExtendExecutionDatetimePrecision: migrated (0.0913s) ========

➜  stack git:(master) ✗ bin/rails db -p
Reading table information for completion of table and column names