Skip to content

Instantly share code, notes, and snippets.

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: redis-rest
namespace: MY_NAMESPACE
rules:
- apiGroups: ['extensions']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
apiVersion: v1
kind: Service
metadata:
name: redis-rest
namespace: MY_NAMESPACE
spec:
type: NodePort
ports:
- name: http
port: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-rest
namespace: MY_NAMESPACE
spec:
selector:
matchLabels:
app: redis-rest
template:
class IntervalWorker
def initialize(interval_id)
@interval_id = interval_id
end
def perform
interval = Interval.where(id: @interval_id).first
interval.complete! if interval.present?
end
end
@mikeraimondi
mikeraimondi / lessons.rb
Created July 9, 2013 02:13
Seeder for Memworks lessons
module Seeders
module Lessons
class << self
def seed
Lesson.destroy_all
lessons = []
base_path = 'db/seed_data'
Dir.glob(Rails.root.join(base_path, 'lessons', '*.yml')) do |file|
lesson = YAML.load_file(file)
@mikeraimondi
mikeraimondi / database_cleaner.rb
Created June 29, 2013 00:25
database_cleaner config for Capybara/RSpec with poltergeist
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = Capybara.current_driver == :rack_test ? :transaction : :truncation
DatabaseCleaner.clean
DatabaseCleaner.start
end
@mikeraimondi
mikeraimondi / post.rb
Created June 15, 2013 04:11
expressive association example
class Post < ActiveRecord::Base
belongs_to :author,
class_name: 'User',
foreign_key: 'author_id',
inverse_of: :posts
attr_accessible :body, :title
end
@mikeraimondi
mikeraimondi / user.rb
Created June 15, 2013 04:10
expressive association example
class User < ActiveRecord::Base
has_many :posts,
foreign_key: 'author_id',
inverse_of: :author
attr_accessible :name, :email
end
@mikeraimondi
mikeraimondi / post.rb
Created June 15, 2013 03:55
expressive association example
class Post < ActiveRecord::Base
belongs_to :user,
inverse_of: :posts
attr_accessible :body, :title
end
@mikeraimondi
mikeraimondi / user.rb
Created June 15, 2013 03:54
expressive associations example
class User < ActiveRecord::Base
has_many :posts,
inverse_of: :user
attr_accessible :name, :email
end