Skip to content

Instantly share code, notes, and snippets.

@loganvolkers
loganvolkers / Byte Formatting for Google Sheets.md
Last active April 16, 2024 10:42
Byte formatting for Google Sheets
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@DmitryTsepelev
DmitryTsepelev / 1_graphql_ruby_n_plus_one.md
Last active January 5, 2024 15:16
N+1 in graphql-ruby

How to run examples:

  1. Run $ createdb nplusonedb to create DB
  2. Run specs $ rspec demo.rb
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@jagthedrummer
jagthedrummer / sidekiq_transfer.rake
Created April 5, 2017 19:58
Rake task to transfer Sidekiq jobs from one redis instance to another
# This task should be run inside an environment that is already configured to connect to the redis
# instance that we're transfering AWAY FROM.
#
# The task should be handed the URL of the redis instance that we're MOVING TO.
#
# To run it and pass in the destination Redis you'd do something like this:
# rake sidekiq:transfer[redis://...]
#
# As jobs are added to the destination Redis, they're deleted from the source Redis. This
# allows the task to be restarted cleanly if it fails in the middle due to a network error
@iiwo
iiwo / through_association_autosave.rb
Last active April 26, 2022 14:45
through_association_autosave.rb
# frozen_string_literal: true
# This script illustrates caveats of ActiveRecord association autosave
# when using a combination of database constrains with a through association (join model)
#
# ## USAGE
#
# ruby through_association_autosave.rb
#
# ## EDGE CASE
@gjtorikian
gjtorikian / homepage_spec.rb
Last active December 5, 2019 20:28
Basic Capybara testing with Jekyll + Rack
require 'spec_helper'
describe "Homepage" do
before :each do
visit "/index.html"
end
it "has a title" do
expect(page).to have_css("h1", text: "GitHub Help")
@deepak
deepak / Dockerfile
Created July 5, 2013 06:59
Dockerfile to install ruby using brightbox deb
# DOCKER-VERSION 0.4.8
FROM ubuntu:12.04
MAINTAINER Deepak Kannan "deepak@codemancers.com"
RUN apt-get -y install python-software-properties
RUN apt-add-repository -y ppa:brightbox/ruby-ng-experimental
RUN apt-get -y update