Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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 / 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 / Mealplan.md
Last active December 8, 2017 22:50
Fitness Plan

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)

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 December 26, 2015 12:08
Trying to create a database from a recipe
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
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 -%>
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 July 31, 2013 16:37
nginx config (that doesn't work)
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;