Skip to content

Instantly share code, notes, and snippets.

@cmaxw
cmaxw / rss_redirector.rb
Created Oct 7, 2021
compare 2 rss feeds and create nginx redirects
View rss_redirector.rb
#!/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)
@cmaxw
cmaxw / _task.json.jbuilder
Created Aug 31, 2015
013 RailsClips JBuilder
View _task.json.jbuilder
json.name task.name
json.due_at task.due_at.strftime("%Y-%m-%d")
@cmaxw
cmaxw / projects_controller.rb
Last active Aug 29, 2015
012 RailsClips HTTP Basic Authentication
View projects_controller.rb
http_basic_authenticate_with name: "cmaxw", password: "railsclips"
@cmaxw
cmaxw / Authorization layout.md
Last active Aug 29, 2015
Authorization Schema
View Authorization layout.md

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 / Mealplan.md
Last active Dec 8, 2017
Fitness Plan
View Mealplan.md

Meal Plan

Breakfast - 520 calories

  • 2 eggs(scrambled)
  • 2 slices bacon
  • 2 slices toast (buttered)

Lunch (A Day) - 420 calories

  • Campbells Chunky Soup (1 can)
View HackNightList.md

Hack Night Ideas

  • 5 minute Rails setup. (ie. if config options are missing, launch a form to get them in the browser.)
  • "Rate this page" service (from Parley. Embeddable via JS for static sites.)
  • Cohort plugin for devise, sorcery, or similar
  • Cohort analytics (see above)
  • Chat room (EM, Node, etc.)
  • Survey plugin with simple markup language/DSL
@cmaxw
cmaxw / chef-stacktrace.out
Last active Dec 26, 2015
Trying to create a database from a recipe
View chef-stacktrace.out
opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:193:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/client.rb:193:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application.rb:183:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application/client.rb:302:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application/client.rb:294:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application/client.rb:294:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/application.rb:66:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'^C
View chef-stacktrace.out
Generated at 2013-10-08 13:56:58 +0000
Chef::Mixin::Template::TemplateError:
Chef::Mixin::Template::TemplateError (undefined method `each' for nil:NilClass) on line #5:
3:
4: <% @apache_listen_ports.each do |port| -%>
5: <% @apache_listen_addresses.each do |address| -%>
6: Listen <%= address.length > 0 ? "#{address}:" : '' %><%= port %>
7: <% end -%>
View batters.rb
require 'csv'
module Baseballer
class Batter
attr_accessor :attributes
def self.load(file_path = "../../data/Batting-07-12.csv")
path_to_file = File.expand_path(file_path, File.dirname(__FILE__))
batters = []
CSV.foreach(path_to_file, headers: true, return_headers: false) do |row|
@cmaxw
cmaxw / rubyrogues.conf
Created Jul 31, 2013
nginx config (that doesn't work)
View rubyrogues.conf
server {
server_name rubyrogues.com www.rubyrogues.com rubyrogues.bluebox-placeholder.com;
access_log /var/log/nginx/rubyrogues.com.access.log;
error_log /var/log/nginx/rubyrogues.com.error.log;
root /var/www/rubyrogues;
passenger_enabled on;
passenger_base_uri /parley;
rails_env production;