Skip to content

Instantly share code, notes, and snippets.

View samuels410's full-sized avatar
🎯
Focusing

samuel santhosh samuels410

🎯
Focusing
View GitHub Profile
@samuels410
samuels410 / canvas-db-change
Created May 24, 2016 13:02
canvas-db-change
- Stop delayed jobs (canvas_init stop)
- Shut down canvas
- Remove the 'queue' section from database.yml
- Import the necessary functions from the queue DB into the main one. I have them in a gist here: https://gist.github.com/grahamb/4ac964d9e40de7ca9559. You can also get them by doing a full dump of the queue DB. To import them, save to a file (e.g. functions.sql) and do 'cat functions.sql | psql -h yourdbserverhostname -U canvas canvas_production' (assuming you're using the default username and DB name)
- Dump the delayed and failed jobs tables to a file: 'dump -h yourdbserverhostname -U canvas -C -t delayed_jobs -t failed_jobs > jobs.sql'
- Import the dump file into the main canvas DB: 'cat jobs.sql | psql -h yourdbserverhostname U canvas canvas_production'
- Assuming no errors above, restart delayed jobs (canvas_init start) and Canvas.
- Check your delayed jobs log and /jobs to make sure everything is working.
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
server {
listen 80;
server_name example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443;
server_name example.com;
root /var/deploy/code/current/public;
charset utf-8;
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@samuels410
samuels410 / canvas_developer_key_disable_refresh_token.rb
Created May 21, 2017 06:58
canvas developer key disable refresh token
DeveloperKey.all.each do |d|
d.trusted=true
d.force_token_reuse=false
d.auto_expire_tokens=false
d.save!
end
mount /dev/sda2 /mnt
chroot /mnt
@samuels410
samuels410 / show_feedback_link help
Created January 9, 2018 21:45
canvas show help link
@samuels410
samuels410 / chrome_identifier_script.js
Last active January 15, 2018 05:48
Js script to identify chrome browser and show an alert
(function () {
var chrome = {
string: navigator.userAgent.match(/Chrome\/(\d+)/)
};
chrome.version = chrome.string ? parseInt(chrome.string[1], 10) : null;
currentUrl = window.location.href;
Domain = "https://domain";
yDomainWithoutSSL = "http://domain";
@samuels410
samuels410 / sub_account_wise_logged_in_count.rb
Last active February 8, 2018 09:16
canvas lms sub account wise logged in user count
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
logins = Pseudonym.where("last_request_at > ? and last_request_at < ? and current_login_at IS NOT NULL", DateTime.yesterday.beginning_of_day,DateTime.yesterday.end_of_day)
account_pseudonyms = {}
logins.each do |pseudonym|
course=pseudonym.user.courses.first
if course
course_account_id = course.account_id
unless account_pseudonyms[course_account_id]
account_pseudonyms[course_account_id] = []
@samuels410
samuels410 / canvas_lms_remove_unaccepted_course_invitations.rb
Created February 5, 2018 07:42
canvas lms remove unaccepted course invitations
course_ids=[1,2]
puts course_ids.size
course_ids.each do |course_id|
course=Course.find(course_id)
puts course.enrollments.where(workflow_state: 'invited').count
course.enrollments.where(workflow_state: 'invited').each do |enrollment|
enrollment.workflow_state='deleted'
enrollment.save!
end
end