Skip to content

Instantly share code, notes, and snippets.

Cynthia Kiser cnk

Block or report user

Report or block cnk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:6216
require File.dirname(__FILE__) + '/../test_helper'
class EditorActionsTest < ActionController::IntegrationTest
# CNK not sure if we are going to use fixtures
# I would prefer to use factories but am having trouble with that
# fixtures :users, :roles, :roles_users, :pages
def setup
@home_page = Factory.create_home_page
@editor = Factory.create_user_with_role('editor', :login => 'abenter', :email => '', :password => 'abenter', :password_confirmation => 'abenter')
cnk / user.rb
Created Jan 10, 2012
FactoryGirl and protected attributes
View user.rb
class User < ActiveRecord::Base
# devise configuration info omitted
# admin column is defined with :default => false
attr_accessible :email, :password, :password_confirmation
cnk / .rvmrc
Created Jul 15, 2012
.rvmrc file for RideBum
View .rvmrc
if [[ -s "/home/cnk/.rvm/environments/ruby-1.9.3-p194@Ride-Bum" ]] ; then
. "/home/cnk/.rvm/environments/ruby-1.9.3-p194@Ride-Bum"
rvm --create use "ruby-1.9.3-p194@Ride-Bum"
View gist:f9f454ff808c03fe5907
## afer installing ruby 2.2.0 with ruby_build_ruby
## and setting
# default['passenger']['ruby_bin'] = '/usr/local/bin/ruby'
# in my cookbook's attributes/default.rb
[vagrant@default-centos-65 ~]$ cat /etc/httpd/mods-enabled/passenger.conf
PassengerRoot /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/passenger-4.0.53
PassengerRuby /usr/local/bin/ruby
PassengerMaxPoolSize 6
View gist:4910e794c4c065fbc3f5
application 'foo' do
path '/srv/ads/rails/foo'
owner 'rails'
group 'rails'
repository ''
revision 'master'
rollback_on_error false
# Apply the rails LWRP from application_ruby
cnk / app-controllers-application_controller.rb
Created Mar 15, 2015
Work around for files getting uploaded as application/octet-stream
View app-controllers-application_controller.rb
class ApplicationController < ActionController::Base
# omitted stuff
# Used to correct content type for files uploaded with bulkupload or from PicMonkey
def correct_content_type_for_octet_stream(filedata)
return nil if filedata.blank?
# see what the unix file command thinks this is
if filedata.content_type == 'application/octet-stream'
filedata.content_type = type_from_file_command(filedata.path)
View gist:3e7934c5e9982a1bb89f
In the parent cookbook's attributes/default.rb:
default['dev-django-skeleton']['database']['host'] = ""
In my wrapper cookbook's attributes/default.rb:
normal['dev-django-skeleton']['database']['host'] = "an RDS name"
In my kitchen.yml for the local Vagrant:
attributes: { dev-django-skeleton: { database: { host: "" } } }
When I run 'kitchen converge'', this if statement is consistently evaluating to the RDS name:
View import_experts.rake
cat import_experts.rake
#use FasterCSV for importing from our file
require 'fastercsv'
# We are working from an FMP export that should contain the following fields:
# Person id
# Caltech UID
# First name (with middle initial)
cnk /
Created Jul 10, 2015
Example code from Chapter 7 (Library Example 1: Modules and Mixins) of Customizing Ruby
$ chef-client --once --local-mode --config /\
Users/cnk/Code/sandbox/customizing_chef/part3_examples/solo.rb --override-runlist testcookbook::default
Starting Chef Client, version 12.3.0
[2015-07-09T17:08:42-07:00] WARN: Run List override has been provided.
[2015-07-09T17:08:42-07:00] WARN: Original Run List: []
[2015-07-09T17:08:42-07:00] WARN: Overridden Run List: [recipe[testcookbook::default]]
resolving cookbooks for run list: ["testcookbook::default"]
Synchronizing Cookbooks:
- testcookbook
Compiling Cookbooks...
seen = StudentMaterialIndividualization.objects.filter(student=student_id,
material__knowledge_goal=knowledge_goal) \
for item in seen:
material = MaterialVersion.objects.filter(material_key=item.material_key, version=item.version)
# I am trying to end up with a list of materials so would like to query MaterialVersion but based on restrictions from StudentMaterialIndividualization
You can’t perform that action at this time.