Skip to content

Instantly share code, notes, and snippets.

View regularlady's full-sized avatar

Brittany Martin regularlady

View GitHub Profile
@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.

@carols10cents
carols10cents / relevant-conference-dates.md
Last active February 2, 2016 20:22
Conference dates

Dates in bold are weekends.

May

  • 4-6 Railsconf Kansas City
  • 6 - Stirtrek, likely
  • 7-8 - !!Con, NYC
  • 14-15
  • 20-21 - Self.conference Detroit
  • 21-22
@jonasbjork
jonasbjork / cloudfront.txt
Last active December 26, 2017 02:59
Nginx - Get real client IP behind Amazon Cloudfront
real_ip_header X-Forwarded-For;
real_ip_recursive on;
set_real_ip_from 10.0.0.0/16;
set_real_ip_from 54.192.0.0/16;
set_real_ip_from 54.230.0.0/16;
set_real_ip_from 54.239.128.0/18;
set_real_ip_from 54.239.192.0/19;
set_real_ip_from 54.240.128.0/18;
set_real_ip_from 204.246.164.0/22;
set_real_ip_from 204.246.168.0/22;
@O-I
O-I / hash_except.md
Last active August 2, 2023 17:31
[TIx 4] Remove key-value pairs from a hash and return the hash

Note: As of Ruby 3.0.0, Hash#except is now [part][1] of the language. However, Ruby does not implement Hash#except!.

Sometimes I want to remove a specific key-value pair from a Ruby hash and get the resulting hash back. If you're using Rails or ActiveSupport you can accomplish this using Hash#except:

hash = { a: 1, b: 2, c: 3 }
hash.except(:a)     # => { b: 2, c: 3 }

# note, the original hash is not modified
hash # => { a: 1, b: 2, c: 3 }
@wkjagt
wkjagt / audio-book-reader.md
Last active April 12, 2024 14:18
How I built an audio book reader for my nearly blind grandfather

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an

@seratch
seratch / config.yml
Created October 25, 2012 09:37
AWS SQS Example
access_key_id: xxx
secret_access_key: yyy
@nazgob
nazgob / ctags.setup
Created January 6, 2012 13:44
ctags setup on mac
# you have ctags but it does not work...
$ ctags -R --exclude=.git --exclude=log *
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
#you need to get new ctags, i recommend homebrew but anything will work
$ brew install ctags
#alias ctags if you used homebrew
$ alias ctags="`brew --prefix`/bin/ctags"