Skip to content

Instantly share code, notes, and snippets.

View seejee's full-sized avatar

Chris Geihsler seejee

View GitHub Profile
@seejee
seejee / gist:5008345
Last active December 14, 2015 01:39
Schema.rb :(
seejee@seejee-mbp:~/code/apangea (review)$ git diff
diff --git a/db/enrollments_schema.rb b/db/enrollments_schema.rb
index 8e7447c..8bd8a6a 100644
--- a/db/enrollments_schema.rb
+++ b/db/enrollments_schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130211201447) do
SELECT
s.id as session_id,
s.created_at,
min(coalesce(s1.created_at, '9999-01-01')) as end_date
FROM
student_sessions s
left outer join student_sessions s1 on s.student_id = s1.student_id
AND s.created_at < s1.created_at
GROUP BY
s.id,
@seejee
seejee / gist:5031415
Last active December 14, 2015 04:49
  1. Migrate the db.

  2. Copy 'temp_session.dump' from the 'ttm-utilities' S3 bucket.

  3. Restore the dump to the master shard: (Ignore any warnings about the zmance user ... nailed it.)

    pg_restore -U -h -p -d -t tmp_session_last_attempt_date temp_session.dump

  4. Add an index to the temp table:

FactoryGirl.define do
factory :status do
end
factory :thing do
association :status, factory: status
end
end
class LessonMapBuilder
def initialize(activities, current)
@activities = activities
@current = current
end
def build
map = {}
@activities.each do |ea|
@seejee
seejee / gist:6043142
Last active December 20, 2015 00:39
Updating the data warehouse for the AWS environment

Before putting the Heroku-hosted app in maintenance mode:

  • Stop the data warehouse from auto-pooooooooling for new data in the Heroku databases:

      heroku ps:scale etl_job=0 -a ttm-reporting
    

After the AWS-hosted app is up and running:

  • Update the five database URL environment variables:
@seejee
seejee / gist:6262903
Created August 18, 2013 17:38
scalr server configure script
#!/bin/bash
# These paramters will be required when using the script.
# Scalr will ask for them.
__UPDATE_ALL_PACKAGES__=%updateAllPackages%
SCALR_FARM_NAME=%farm_name%
SCALR_ROLE_NAME=%role_name%
SCALR_INSTANCE_INDEX=%instance_index%
RECONFIGURE=%reconfigure%
RECONFIGURE_OPTS=%reconfigure_opts%
onProcess: (job, done, chatExporter = new ChatExporter()) =>
logger.debug('processing transcript', job.data.id)
hget = Q.nbind(@redis.hget, @redis)
hget('chats', job.data.id)
.then((t) -> @chatExporter.exportTranscript(JSON.parse(t)))
.then( ->
logger.debug "Successfully processed transcript:", id
done()
)
@seejee
seejee / gist:6958305
Last active December 25, 2015 09:59
ETL job execution time: ruby-1.9.3 vs. ruby-2.0 vs. rbx-2.0-ruby-2.1

Rbx 2.0:

  • Full:
    real    18m26.393s
    user	25m39.945s
    sys	1m32.109s
    
    Processing control /Users/seejee/code/reporting/etl/attempt_fact.ctl
    Source: /Users/seejee/code/reporting/etl/attempt_fact.txt
    
class FiguresOutTheNextThing
constructor: (@lesson) ->
doNextThing:
is @lesson.isntStarted() ->
navigate("#{@lesson.id}/start")
return
if @lesson.isFinished() ->
navigate('/student_dashboard')