Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
class SalesListOrganizationCsvDownload < Avo::BaseAction
self.name = "CSV Download"
self.may_download_file = true
self.confirm_button_label = "Download"
def handle(**args)
_models, _fields, _current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
@UsAndRufus
UsAndRufus / setting_up_hombrew_fish_node_ruby_monterery_m1.md
Last active March 5, 2022 13:32
Setting up Homebrew, Fish, Node & Ruby in macOS Monterey on Apple Silicon/M1

This is a personal guide for how to setup Fish & Ruby in macOS Monterey running on an Apple/Silicon M1. asdf is used as a version manager for Node and Ruby.

Homebrew

Go to https://brew.sh/ and run the script.

On this version of macOS, it installs to /opt/homebrew. This means that paths that reference /usr/local/share should instead reference /opt/homebrew/opt/<package-name>/share. This can be a little confusing when following guides.

@dshorthouse
dshorthouse / twitter_from_orcid.rb
Last active January 2, 2022 16:40
Query wikidata using ruby
# Install via command-line as 'gem install sparql-client'
require 'sparql/client'
headers = { 'User-Agent' => 'Ruby-Sparql-Client/1.0' }
@sparql = SPARQL::Client.new("https://query.wikidata.org/sparql", headers: headers, read_timeout: 120)
# A SPARQL query to find an item and an optional Twitter handle
def wikidata_by_orcid_query(orcid)
%Q(
SELECT ?item ?itemLabel ?twitter

Faster Rails tests

Feedback loop speed in one of the biggest contributing factors to overall development time. The faster you get results, the faster you can move on to other things. A fast enough test suite is therefore critical to teams' success, and is worth investing some time at the beginning to save in the long run.

Below is a list of techniques for speeding up a Rails test suite. It is not comprehensive, but should definitely provide some quick wins. This list of techniques assumes you're using minitest, but most everything should translate over to rspec by simply replacing test/test_helper.rb with spec/spec_helper.rb.

@trev
trev / config.yml
Created May 25, 2018 01:23
CircleCI 2.0 with parallelism & simplecov for Rails
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
defaults: &defaults
working_directory: ~/split_app
parallelism: 2
docker:
- image: circleci/ruby:2.5.0-node-browsers
@EdwardDiehl
EdwardDiehl / ruby_version.rb
Last active February 26, 2022 11:02
Read and specify ruby version in Gemfile from asdf-vm .tool-versions file.
# https://gist.github.com/EdwardDiehl/9c660b59d0fb2e936774ee2c4fcfc792
# Read and specify ruby version in Gemfile from asdf-vm .tool-versions file.
# Copy the file to your your project root.
# Add these lines at the top of your project Gemfile:
# require './ruby_version.rb'
# ruby ruby_version
def ruby_version(ruby_default_version = '2.5.0')
tool_versions_file = File.join(File.expand_path('..', __FILE__), '.tool-versions')
@pftg
pftg / .circleci_config.yml
Created January 13, 2018 21:02
Pre-compile Assets and Cache for CircleCI
- restore_cache:
keys:
- v1-asset-cache-{{ arch }}-{{ .Branch }}
- v1-asset-cache-
- run: bundle exec rake assets:precompile
- save_cache:
key: v1-asset-cache-{{ arch }}-{{ .Branch }}-{{ epoch }}
paths:
@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@iloveitaly
iloveitaly / capybara_fill_stripe_elements.rb
Created March 4, 2017 21:21
Fill in a Stripe Elements (https://stripe.com/docs/elements) credit card field using capybara
def fill_stripe_elements(card)
using_wait_time(15) { within_frame('stripeField_card_element0') do
card.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
end }

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

The JSON API specification is agnostic about how a server implements filtering strategies. In fact, the spec says:

Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.