Skip to content

Instantly share code, notes, and snippets.

View cnk's full-sized avatar

Cynthia Kiser cnk

View GitHub Profile
@cnk
cnk / gist:6216
Created August 19, 2008 18:37 — forked from haikuwebdev/gist:6215
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 => 'abenter@caltech.edu', :password => 'abenter', :password_confirmation => 'abenter')
@cnk
cnk / user.rb
Created January 10, 2012 02:59
FactoryGirl and protected attributes
class User < ActiveRecord::Base
# devise configuration info omitted
# admin column is defined with :default => false
attr_accessible :email, :password, :password_confirmation
end
@cnk
cnk / .rvmrc
Created July 15, 2012 18:00
.rvmrc file for RideBum
.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"
else
rvm --create use "ruby-1.9.3-p194@Ride-Bum"
fi
## 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
application 'foo' do
path '/srv/ads/rails/foo'
owner 'rails'
group 'rails'
repository 'git@bitbucket.org:...'
revision 'master'
rollback_on_error false
# Apply the rails LWRP from application_ruby
@cnk
cnk / app-controllers-application_controller.rb
Created March 15, 2015 02:58
Work around for files getting uploaded as application/octet-stream
class ApplicationController < ActionController::Base
# omitted stuff
private
# 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)
end
In the parent cookbook's attributes/default.rb:
default['dev-django-skeleton']['database']['host'] = "127.0.0.1"
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: "127.0.0.1" } } }
When I run 'kitchen converge'', this if statement is consistently evaluating to the RDS name:
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
cnk / shell_output.sh
Created July 10, 2015 00:11
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...
@cnk
cnk / test.py
Created January 26, 2016 23:49
seen = StudentMaterialIndividualization.objects.filter(student=student_id,
material__knowledge_goal=knowledge_goal) \
.order_by('started_at')
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