This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
class Graphite | |
def initialize(host) | |
@host = host | |
end | |
def socket | |
return @socket if @socket && [email protected]? | |
@socket = TCPSocket.new(@host, 2003) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' | |
require 'optparse' | |
# Collect INFO from Redis, report it to Graphite | |
opts = OptionParser.new do |opts| | |
opts.banner = "Usage: redis-graphite.rb redis-host[:redis-port] graphite-host" | |
opts.on( '-h', '--help', 'Display this screen' ) do | |
puts opts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require 'socket' | |
statsd_host = "" | |
statsd_port = "8125" | |
namespace_prefix = "statsd-ruby" | |
mode = "statsd" | |
ARGV.each do |arg| | |
name, value = arg.split '=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Dashboard_Model_OAuth_Consumer extends OCAD_Db_Row | |
{ | |
public function recordRequest($timestamp, $nonce) | |
{ | |
if( $timestamp > $this->timestamp ) | |
{ | |
// Update saved timestamp | |
$this->timestamp = $timestamp; | |
$this->setNonces(array($nonce)); // Clear saved nonces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :ocadu do | |
"Returns the number of delayed jobs in the queue" | |
task :job_count => :environment do | |
puts Delayed::Job.where("run_at < UTC_TIMESTAMP() AND locked_at is null").count | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These queries generate *other* queries that can be used to drop and recreate constraints on all tables in the database. | |
# Both must be run while the constrains still exist | |
# Drop constraints | |
SELECT 'ALTER TABLE "'||nspname||'"."'||relname||'" DROP CONSTRAINT "'||conname||'";' | |
FROM pg_constraint | |
INNER JOIN pg_class ON conrelid=pg_class.oid | |
INNER JOIN pg_namespace ON pg_namespace.oid=pg_class.relnamespace | |
ORDER BY CASE WHEN contype='f' THEN 0 ELSE 1 END,contype,nspname,relname,conname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Do sanity check on imported data by comparing the number of rows in each table | |
require 'pg' | |
require 'mysql2' | |
tables = %w( { list the tables to compare here }) | |
p = PG.connect(dbname:'canvas', host: 'postgres.ocad.ca', user: 'canvas_user') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Set the colours you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var $body = $('body'); | |
// Add a button to launch the Outline Builder, which triggers the RTE LTI Launch | |
if($body.hasClass('syllabus')) { | |
// #editor_tabs is only visible when the RTE is active | |
$('#editor_tabs').prepend('<div style="padding-bottom:1em;"><a class="Button Button--primary icon-compose" id="launch_outline_editor_button">Course Outline Builder</a></div>'); | |
$('#launch_outline_editor_button').click(function(){ | |
// Existing RTE LTI buttons are added with aria-label set to the "Name" of the tool, as defined in the tool settings UI, not the XML | |
$('div[aria-label="Outline Builder"]').click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attachment.where(workflow_state:'zipped').find_each do |attachment| | |
delete_attachment attachment | |
};nil | |
def delete_attachment(attachment) | |
# Don't delete parent Attachments | |
return if attachment.children.present? | |
# Delete associated ContentExports | |
content_export_for(attachment).try(:delete) |
OlderNewer