Skip to content

Instantly share code, notes, and snippets.

View pbraswell's full-sized avatar

Peter Braswell pbraswell

View GitHub Profile
mysql> select prop_value from participant_data where participant_id = 1394 and prop_key = 'core_2_preferred_bedtime';
+------------+
| prop_value |
+------------+
| 4:00 am |
+------------+
1 row in set (0.04 sec)
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
@pbraswell
pbraswell / gist:1acb19b4315bf45559fd
Created September 16, 2014 19:29
SF synch issues
irb(main):001:0> Task.last
=> #<Task createddate: nil, whatid: "0013000000w98bSAAQ", whoid: nil, subject: "search_for_me", isdeleted: nil, id: 938828, sfid: nil, description: "TAM call - search_for_me", _c5_source: nil, lastmodifieddate: nil, accountid: nil, ownerid: nil>
irb(main):002:0>
Results in:
2014-09-16 3:26:07 PM Salesforce error: 'Server raised fault: 'INVALID_CROSS_REFERENCE_KEY: invalid cross reference id'' 21 task 938828
@pbraswell
pbraswell / gist:bc968c70f147d280d7e4
Created September 13, 2014 23:01
SAML Integration, Gem lock file
GEM
remote: https://rubygems.org/
specs:
actionmailer (2.3.14)
actionpack (= 2.3.14)
actionpack (2.3.14)
activesupport (= 2.3.14)
rack (~> 1.1.0)
activerecord (2.3.14)
activesupport (= 2.3.14)
@pbraswell
pbraswell / gist:e07681b85b7c664ed380
Last active August 29, 2015 14:06
Issues with SAML Integration
# routes.rb
ActionController::Routing::Routes.draw do |map|
map.connect 'saml', :controller => 'saml', :action => 'init'
map.connect '/saml/:action', :controller => 'saml'
...
# Gemfile
gem 'ruby-saml'
; <<>> DiG 9.8.3-P1 <<>> short + app.shuti.me
;; global options: +cmd
;; connection timed out; no servers could be reached
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47037
;; flags: qr rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;app.shuti.me. IN A
@pbraswell
pbraswell / gist:4be4c3abacedbc19b30e
Created August 27, 2014 23:20
Participant Summary API invocation
curl -u "SleepMed_Admin:czd*ua292" http://107.22.212.178/wasabi/participants/summary/1387
Notes:
You have to use your admin credentials for this invocation. You have to use the participant login, not the pid. You should see a response like the following:
Content-Length: 1398
Content-Type: application/json; charset=utf-8
Date: Wed, 27 Aug 2014 23:13:19 GMT
ETag: "91a10a4e45145774e8f56ac33ba4f046"
Server: Apache/2.2.22 (Ubuntu)
@pbraswell
pbraswell / gist:c295773959e4d5fee55a
Created August 23, 2014 18:44
Patient creation via curl
curl -u 'api_uid:api_pw' --data "[email protected]&AddressCity=SomeCity&AddressStreet1=Main&AdressRegion=VA&TimeZone=EST&CustomerPhone=555-555-5555&CustomerLastName=Smith&CustomerFirstName=John&[email protected]&HeardAbout=yep&OrderReference=1&OrderProductName=widget&ClinicalAccessCode=CCSD2013&OrderReferrer=bob&CustomerSleepPhysician=Dr.%20Who&CustomerBirthDate=27&CustomerBirthMonth=01" http://107.22.212.178/callback/activate
Results in:
<?xml version="1.0" encoding="UTF-8"?>
<participant>
<account-type>None</account-type>
<created-at type="datetime">2014-08-23T18:42:48+00:00</created-at>
<deleted type="boolean">false</deleted>
<detailed-logging type="boolean" nil="true"></detailed-logging>
module Helpers
# Conventient way to setup filesystem attachment uploading when in dev/testing
# and use S3 otherwise
module AssetStorage
def self.included(within)
within.class_eval do
extend ClassMethods
end
class Asset < ActiveRecord::Base
include Helpers::AssetStorage
before_validation :clear_asset
belongs_to :ad, :polymorphic => true
stores_file_as :image,
:styles => {:micro => "75x43", :thumb => "128x95", :medium => "300x300", :large => "500x500"}
validates_attachment_presence :image