Skip to content

Instantly share code, notes, and snippets.

@cmaxw
cmaxw / Authorization layout.md
Last active August 29, 2015 14:13
Authorization Schema

Main Points

  • Overall permissions and assignments will be stored in PostgreSQL
  • A simplified cached version of a users' permissions will be stored in Redis
    • Contains a hash with the permission name and class and id of the object if relevant
  • Authorization will reference the cached version in Redis using Ohm
  • The cache will be build if there is no data in it when Rails starts
  • Changes to permissions or permissions assignments will trigger a cache update job(in Resque)
  • Users will have a default Role assigned which will contain permissions everyone who is logged in has
  • AnonymousUsers will have a default Role assigned which will contain permissions logged out users have
@cmaxw
cmaxw / projects_controller.rb
Last active August 29, 2015 05:13
012 RailsClips HTTP Basic Authentication
http_basic_authenticate_with name: "cmaxw", password: "railsclips"
@cmaxw
cmaxw / _task.json.jbuilder
Created August 31, 2015 21:54
013 RailsClips JBuilder
json.name task.name
json.due_at task.due_at.strftime("%Y-%m-%d")
@cmaxw
cmaxw / rss_redirector.rb
Created October 7, 2021 19:15
compare 2 rss feeds and create nginx redirects
#!/usr/bin/env ruby
require 'httparty'
require 'feedjira'
def get_feed(source)
if source.start_with?("http")
xml = feed_from_url(source)
else
xml = feed_from_file(source)