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 / show_feedback_link help
Created January 9, 2018 21:45
canvas show help link
mount /dev/sda2 /mnt
chroot /mnt
@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
#!/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
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;
# 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
@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.
redis-cli FLUSHDB
redis-cli FLUSHALL
- 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.
@samuels410
samuels410 / fizz_buzz.rb
Created February 10, 2016 06:18
Fiz buzz
def fizzbuzz(range, triggers)
range.each do |i|
result = ''
triggers.each do |(text, divisor)|
result << text if i % divisor == 0
end
puts result == '' ? i : result
end
end