Skip to content

Instantly share code, notes, and snippets.

View christopherhein's full-sized avatar

Christopher Hein christopherhein

View GitHub Profile
@christopherhein
christopherhein / app_spec.rb
Created September 15, 2012 06:59
Write loops. They make your specs faster to write and more covered.
require 'spec_helper'
describe App do
describe "when using the factory" do
subject { create :app }
it { should be_valid }
end
@christopherhein
christopherhein / mapper.rb
Created October 9, 2012 08:02
decided to make some changes to allow for a single method to autoload external routing files
# I've been meaning to send this too you... Remember the #draw method you pulled out of edge rails, well after using it in a personal
# project (which by the way is awesome, totally digging it) I decided that I wanted to include more files in the one method, to reduce
# the amount of times I wrote draw :something, so I modified it a little and thought you'd appreciate it... Cheers!
# In lib/mapper.rb
module ActionDispatch
module Routing
module Mapper
@christopherhein
christopherhein / abstraction_layer.rb
Created November 29, 2012 19:14
Abstraction Of payments layer
# config/environments/{test,development,production}.rb
config.stripe_key = "foobar"
Rails.configuration.stripe_key
# Controller
Purchase.charge("tok_jOq0M8vJprCUUU")
# lib/media_library/models/has_profile.rb
module MediaLibrary
module Models
module HasProfile
extend ActiveSupport::Concern
# Define methods that get called on classes
# that include file
module ClassMethods
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
kubernetes.io/cluster-service: "true"
spec:
@christopherhein
christopherhein / shortcut
Created February 9, 2017 22:45
Allows you to setup very basic shortcuts to urls from the command line
#!/usr/bin/env ruby
require 'yaml'
action = ARGV[0].to_s.strip
service = ARGV[1].to_s.strip
url = ARGV[2].to_s.strip
config_file = "#{ENV['HOME']}/.shortcuts.yml"
data = File.exists?(config_file) ? YAML.load_file(config_file) : {}
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
@christopherhein
christopherhein / dynamodb-app.yaml
Created October 4, 2018 21:14
Sample DynamoDB AWS Operator Manifest
---
apiVersion: service-operator.aws/v1alpha1
kind: DynamoDB
metadata:
name: dynamo-table
spec:
hashAttribute:
name: name
type: S
rangeAttribute:
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller-cluster-rule \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:tiller
helm init --service-account tiller
→ kubectl get crds
NAME CREATED AT
alexaaskskills.awsctrl.io 2019-01-17T09:41:38Z
amazonmqbrokers.awsctrl.io 2019-01-17T09:41:33Z
amazonmqconfigurationassociations.awsctrl.io 2019-01-17T09:41:33Z
amazonmqconfigurations.awsctrl.io 2019-01-17T09:41:33Z
apigatewayaccounts.awsctrl.io 2019-01-17T09:41:33Z
apigatewayapikeys.awsctrl.io 2019-01-17T09:41:33Z
apigatewayauthorizers.awsctrl.io 2019-01-17T09:41:33Z
apigatewaybasepathmappings.awsctrl.io 2019-01-17T09:41:33Z