Skip to content

Instantly share code, notes, and snippets.


Ruben Izmailyan rubendinho

View GitHub Profile
ParamagicDev / capybara_read_spec.rb
Created Apr 22, 2021
Clipboard reading in Capybara
View capybara_read_spec.rb
it "should read clipboard text" do
origin: page.server_url,
permission: { name: "clipboard-read" },
setting: "granted",
clip_text = page.evaluate_async_script("navigator.clipboard.readText().then(arguments[0])")
expect(clip_text).to eq("copied text")
arlogilbert / cal2sheets.js
Last active Jun 19, 2020
Google Calendar to Google Sheets
View cal2sheets.js
This is a Google Sheets Script. Create a script on the sheet you want to store your calendar entries in, save it, and set up a trigger.
Set this up as a timed trigger in the morning against a google sheet to have an always up to date list of who you have met with.
For the initial run you may want to set the daysBack to a large number like 999
ssnickolay / base_mutation.rb
Created Apr 10, 2020
Ensuring Policies are Used in Graphql Mutation
View base_mutation.rb
class BaseMutation < GraphQL::Schema::RelayClassicMutation
include Graphql::ResolverCallbacks
include ActionPolicy::GraphQL::Behaviour
def current_user
# Enforce mutation authorization.
# This callbacks verifies that `authorize!` method has been
palkan / tracer.rb
Created Feb 13, 2020
[GraphQL] verify batch load
View tracer.rb
# frozen_string_literal: true
module Graphql
# This module implements the functionality to track whether the batch loading is
# required for a field to solve N+1 problem.
# If you want to check whether a particular field doesn't use batch loading in vain,
# mark it with `verify_batch_load: true` option.
# By default, it logs the following information when detects a possible N+1 (thus, confirms that batch loading is required).
palkan /
Last active Feb 5, 2021
graphql-ruby fragment caching

PoC: GraphQL Ruby fragment caching

This example demonstrates how we can cache the response fragments in graphql-ruby.

Existing solutions only allow caching resolved values but not all the GraphQL machinery (validation, coercion, whatever).

Caching response parts (in case of Ruby, sub-Hashes) is much more efficient.


seanlinsley / chromedriver.rb
Created Mar 14, 2019
Ensures that chromedriver always matches the version of Chrome that's currently installed
View chromedriver.rb
require 'open-uri'
require 'shellwords'
executable = if RUBY_PLATFORM =~ /darwin/
'/Applications/Google Chrome'
carlosramireziii / attached_validator.rb
Last active Dec 21, 2020
A validator and RSpec matcher for requiring an attachment using Active Storage
View attached_validator.rb
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
hopsoft / prefetch.js
Last active Mar 22, 2021
Turbolinks Prefetching
View prefetch.js
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()'GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
View graph_ql_acceptance_spec.rb
require 'spec_helper'
describe 'GraphQL acceptance' do
describe 'allLinks' do
it 'returns all links' do
link1 = create :link, description: 'first'
link2 = create :link, description: 'second'
query = %(
dansteele / create_review_app_subdomain.rake
Last active Nov 17, 2020
Use a sub-subdomain on Heroku review apps with DNSimple. Run this task from your app.json in your postdeploy script.
View create_review_app_subdomain.rake
namespace :staging do
desc 'create subdomain DNS record for Heroku review app'
task :publish_dns do
require 'dnsimple'
require 'platform-api'
STAGING_DOMAIN = ''.freeze
heroku_app_name = ENV['HEROKU_APP_NAME']
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first