Skip to content

Instantly share code, notes, and snippets.

@ismasan
ismasan / concurrent_processing.rb
Last active March 24, 2024 22:11
Practical Railway-oriented Pipeline for Ruby
# A Pipeline extension to process steps concurrently
# Example
# class ConcurrentPipeline < Pipeline
# include ConcurrentProcessing
# end
#
# MyPipeline = ConcurrentPipeline.new do |pl|
# pl.step ValidateInput
#
# # These steps run concurrently
@hopsoft
hopsoft / README.md
Last active March 29, 2024 18:06
ActiveRecord ETL

ActiveRecord ETL

I created this to help me run benchmarks/comparisons against Universal ID, but it could serve as the foundation for a robust ETL data pipeline... and it's less than 70 LOC right now! 🤯 🚀

It handles the extract and transform parts of an ETL process and supports the following options:

  • only - specify which attributes to include
@bradgessler
bradgessler / oauth_google_controller.rb
Last active September 14, 2023 13:57
OAuth Google controller
class OAuth::GoogleAuthorizationsController < ApplicationController
CLIENT_ID = Rails.application.credentials.google.client_id
CLIENT_SECRET = Rails.application.credentials.google.client_secret
SCOPE = "openid email profile"
AUTHORIZATION_URL = URI("https://accounts.google.com/o/oauth2/v2/auth")
TOKEN_URL = URI("https://www.googleapis.com/oauth2/v4/token")
USER_INFO_URL = URI("https://www.googleapis.com/oauth2/v3/userinfo")
before_action :validate_state_token, only: :show
@dhairyagabha
dhairyagabha / rails-add-underline-superscript-subscript-to-trix-editor.md
Last active March 25, 2024 23:09
Rails & Trix: Add Underline, Superscript, and Subscript

Rails & Trix: Add Underline, Superscript, and Subscript

This guide will walk you through adding some extra features such as the ability to underline your text, or enhance your content by adding superscripts or subscripts for annotations or Math equations.

Prerequisites: Instruction guide assumes that you have created a Rails application and installed ActionText.

What will you learn:

@jorgemanrubia
jorgemanrubia / measure.rb
Last active November 7, 2022 15:34
Script to measure and compare speed of running tests in parallel versus sequentially
require "benchmark"
# https://github.com/rails/rails/pull/42761
class Execution
TEST_FILE_PATH = "test/threshold_test.rb"
SINGLE_TEST_DURATION = 0.1
attr_reader :threshold, :parallel
def initialize(threshold, parallel: false)
@ianstormtaylor
ianstormtaylor / .bashrc
Created August 28, 2019 13:21
Aliases for nicer branching output from Git.
alias gb="git branch --sort=-committerdate --verbose --format='%(HEAD) %(color:red)%(objectname:short)%(color:reset) - %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(color:green)(%(committerdate:relative))%(color:reset) %(color:blue)<%(authorname)>%(color:reset)'"
alias gba="gb -a"
@harigopal
harigopal / 2017-04-15-service-loggable-concern.rb
Created April 15, 2017 15:55
2017-04-15-service-loggable-concern
module Loggable
extend ActiveSupport::Concern
def log(message)
return if Rails.env.test?
Rails.logger.info "[#{current_timestamp}] [#{current_service_name}] #{message}\n"
end
private
@evanleck
evanleck / http-decorator.rb
Created September 22, 2016 17:12
Decorating Ruby's Net::HTTP for Fun and Profit
# encoding: UTF-8
# frozen_string_literal: true
require 'net/http'
require 'json'
require 'uri'
class HTTPDecorator
# Timeouts
OPEN_TIMEOUT = 10 # in seconds
READ_TIMEOUT = 120 # in seconds
@joyrexus
joyrexus / README.md
Last active May 3, 2024 10:41 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000