Skip to content

Instantly share code, notes, and snippets.

View rubendinho's full-sized avatar

Ruben Izmailyan rubendinho

View GitHub Profile
@seanlinsley
seanlinsley / chromedriver.rb
Created March 14, 2019 00:55
Ensures that chromedriver always matches the version of Chrome that's currently installed
# https://github.com/flavorjones/chromedriver-helper/issues/79
# http://chromedriver.storage.googleapis.com/index.html
require 'open-uri'
require 'shellwords'
executable = if RUBY_PLATFORM =~ /darwin/
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
else
'google-chrome'
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 = %(
{
@palkan
palkan / tracer.rb
Created February 13, 2020 13:35
[GraphQL] verify batch load
# 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).
@arlogilbert
arlogilbert / cal2sheets.js
Last active June 19, 2020 19:12
Google Calendar to Google Sheets
/*
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
ssnickolay / base_mutation.rb
Created April 10, 2020 20:32
Ensuring Policies are Used in Graphql Mutation
class BaseMutation < GraphQL::Schema::RelayClassicMutation
include Graphql::ResolverCallbacks
include ActionPolicy::GraphQL::Behaviour
def current_user
context[:current_user]
end
# Enforce mutation authorization.
# This callbacks verifies that `authorize!` method has been
@palkan
palkan / 00_Readme.md
Last active July 16, 2022 06:50
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.

Benchmarks

@Yaffle
Yaffle / URLUtils.js
Last active September 5, 2022 02:19
parse URL + absolutize URL in javascript (URLUtils shim - http://url.spec.whatwg.org/#url)
/*jslint regexp: true, maxerr: 50, indent: 2 */
(function (global) {
"use strict";
function URLUtils(url, baseURL) {
var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
if (!m) {
throw new RangeError();
}
@dansteele
dansteele / create_review_app_subdomain.rake
Last active September 15, 2022 23:45
Use a sub-subdomain on Heroku review apps with DNSimple. Run this task from your app.json in your postdeploy script.
namespace :staging do
desc 'create subdomain DNS record for Heroku review app'
task :publish_dns do
require 'dnsimple'
require 'platform-api'
STAGING_DOMAIN = 'mystagingdomain.com'.freeze
DNSIMPLE_ACCOUNT_ID = .freeze
heroku_app_name = ENV['HEROKU_APP_NAME']
subdomain = heroku_app_name.match(/.*(pr-\d+)/).captures.first
@mareksuscak
mareksuscak / bump-version.sh
Created March 15, 2015 12:56
Bump version shell script.
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"