Skip to content

Instantly share code, notes, and snippets.

@bagofarms
bagofarms / settings_patch.php
Last active July 30, 2020 19:11
This patch allows UDOIT to be used with Chrome's new secure-by-default cookie policy
// Patch for older versions of UDOIT to fix secure-by-default cookies in Chrome for cross-site cookies
// Place in config/settings.php directly under define('UDOIT_VERSION',....
$lifetime = 0;
$path = '/';
$domain = null;
$secure = true;
$httponly = false;
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params($lifetime, "$path; samesite=None", $domain, $secure, $httponly);
} else {
@bagofarms
bagofarms / udoit_statistics.sql
Created August 30, 2017 21:17
Here are some SQL statements I use to generate statistics about UDOIT usage.
/* Count the number of scans run per day */
SELECT COUNT(1) AS scans, DATE(date_run) as date
FROM reports
GROUP BY DATE(date_run)
/* Count the number of scans run by each user */
SELECT user_id, COUNT(1) AS scans
FROM reports
GROUP BY user_id
ORDER BY scans DESC
@bagofarms
bagofarms / customize_add_people.js
Created May 3, 2017 13:56
This script will customize the content of the Add People window in Canvas.
$(document).ready(function(){
//The function below checks to see that an element has rendered. When called
//the function will look for a particular selector. Do not remove.
function onElementRendered(selector, cb, _attempts) {
var el = $(selector);
_attempts = ++_attempts || 1;
if (el.length) return cb(el);
if (_attempts == 60) return;
setTimeout(function() {
onElementRendered(selector, cb, _attempts);

Keybase proof

I hereby claim:

  • I am bagofarms on github.
  • I am jacobbates (https://keybase.io/jacobbates) on keybase.
  • I have a public key whose fingerprint is 8E6A 6E8B 3E39 7E6F A6E0 CE55 DD6F 4E4A A809 1B65

To claim this, I am signing this object:

onPage(/\/courses\/\d+\/settings/, function() {
// do something
});
hasAnyRole('admin', function(hasRole) {
if (hasRole) {
// do something
} else {
// do something else
}
@bagofarms
bagofarms / ikea_dioder_time_controlled.ino
Created November 17, 2012 21:51
IKEA Dioder Controlled by Time
#include <TimeLord.h> // Provides sunrise/sunset information
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 RTC;
// Set the three PWM pins to use for each color. 9,10,11 are the other 3
const int redPin = 9;
const int grnPin = 10;
const int bluPin = 11;