Skip to content

Instantly share code, notes, and snippets.

View stevehill1981's full-sized avatar
🏠
Working from home

Steve Hill stevehill1981

🏠
Working from home
View GitHub Profile
@LostKobrakai
LostKobrakai / form_live.ex
Last active April 12, 2024 18:56
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
@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'
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 5.2', '>= 5.2.3'
@philandstuff
philandstuff / lead-dev-2018.org
Last active August 23, 2018 08:56
Lead Developer London 2018

Lead dev 2018

Welcome - Meri Williams

  • @TheLeadDev #LeadDevLondon
  • white coat captioning - @whitecoatcapxg
    • wvnts.co/lduk2018

The Container Operator’s Manual - Alice Goldfuss

  • happy pride! it’s like the world cup for people with fashion sense
  • who am I?
@acolyer
acolyer / jessfraz.md
Created November 19, 2017 13:39
Containers, operating systems and other fun things from The Morning Paper
@b1ackmartian
b1ackmartian / .travis.yml
Last active December 6, 2017 14:20
Travis CI Gigalixir Deploy
language: elixir
elixir: 1.5.2
otp_release: '19.0'
script:
- mix test && ./deploy.sh
@printercu
printercu / rails-5.0-integration-tests-speedup.md
Last active March 7, 2022 01:20
Speed up Rails 5 integration tests

Speed up integration tests in Rails 5 app

Rails 5 recompiles templates on every request in test env. Fix will be released only in 5.0.2.

Add this lines to test helper to get the performance now (I've got x2 improvement):

class << ActionView::LookupContext::DetailsKey
 def clear
@mlafeldt
mlafeldt / postmortem.md
Last active March 27, 2024 09:23
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
@derwiki
derwiki / README.md
Last active September 27, 2023 17:50
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.