Skip to content

Instantly share code, notes, and snippets.

Damion Young theotherdy

Block or report user

Report or block theotherdy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View canvas-gist-embed.html
<p>Text afore gist</p>
<p data-gist-id="572406dce62dc51f8dfd392f3458e7e7" data-gist-hide-footer="true">&nbsp;</p>
<p>Text after gist</p>
@theotherdy
theotherdy / canvas-gist-embed.js
Last active Oct 5, 2018
Using gist-embed to embed GitHub gists nicely in instructure Canvas - see: https://learntech.imsu.ox.ac.uk/blog/embedding-a-github-gist-in-instructure-canvas/
View canvas-gist-embed.js
(function () { //method from: https://community.canvaslms.com/thread/22500-mobile-javascript-development
// The following function will retrieve and load a JavaScript file - https://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
function loadScript(url, callback) {
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState) { //IE
script.onreadystatechange = function () {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
callback();
@theotherdy
theotherdy / 4.3.1_seq1-10.r
Last active Oct 5, 2018
4.3 Data Management: Essential Commands 6-10
View 4.3.1_seq1-10.r
# by isn't needed
seq(from = 1, to = 10) # I could get the same result with seq(1, 10)
View dashboard.css
/* START - Styles for cards on Modules page */
.ou-ModuleCard{
box-sizing: border-box;
box-shadow: 0 2px 5px rgba(0,0,0,0.3);
border-radius: 6px;
overflow: hidden;
background: #fff;
width: 100%;
display: inline-block;
vertical-align: top;
View dashboard.js
/*
* Add tiles at top of modules tool:
* - Tiles are generated by calling the Canvas api, not by scraping the Modules page as before (should be more reliable as Canvas in upgraded)
* - Added a drop-down arrow which gives you a quick link to the Module item (page, discussion, etc)
* - Tiles will show any images put into a specific folder in the Course’s Files (this defaults to looking for a ’tiles’ folder). If no folder or too few images for the number of Modules, colours are used instead
* - Modules further down the page gain a coloured border to help tie things together
* - Clicking the tile anywhere except the drop-down arrow scrolls you down the Modules page to the appropriate Module.
* - I’ve added a Top button to each module which scrolls you back up to the dashboard view
*/
@theotherdy
theotherdy / UserController.php
Last active Jul 31, 2018
Validation in update (store would be the same, but without unique ignore) - see: https://learntech.imsu.ox.ac.uk/blog/angular-reactive-form-custom-validator-for-orcid/
View UserController.php
public function update(Request $request, $id)
{
$messages = [
...,
'orcid.unique' => 'This ORCID ID is already in use in our database',
'orcid.regex' => 'The ORCID ID is in the format https://orcid.org/xxxx-xxxx-xxxx-xxxx',
...,
];
View Orcid.php
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Orcid implements Rule
{
/**
* Create a new rule instance.
View edit-user.component.html
<div fxLayout="row" fxLayoutAlign='center top'>
<div fxFlex class="form-container">
<h2>Edit your profile</h2>
<form [formGroup]="userForm">
...
<mat-form-field class="full-width" appearance="outline">
<mat-label>ORCID ID</mat-label>
<input id="orcid" matInput placeholder="https://orcid.org/xxxx-xxxx-xxxx-xxxx" formControlName="orcid">
<mat-error *ngIf="orcid.errors?.pattern && (orcid.dirty || orcid.touched)">ORCID ids start with https://orcid.org/</mat-error>
<mat-error *ngIf="orcid.errors?.isORCID && (orcid.dirty || orcid.touched)">Please check your id carefully - see <a href="https://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier" target="_blank">Structure of the ORCID Identifier</a></mat-error>
View user-edit.component.ts
...
import { isORCIDValidator } from '../../shared/index';
@Component({
selector: 'user-edit-component',
templateUrl: './user-edit.component.html',
styleUrls: ['./user-edit.component.css']
})
export class UserEditComponent implements OnInit {
@theotherdy
theotherdy / orcid.validator.ts
Last active Jul 23, 2018
Angular validator for 16 digit code which uniquely identifies an ORDCID id. See: https://learntech.imsu.ox.ac.uk/blog/angular-reactive-form-custom-validator-for-orcid/
View orcid.validator.ts
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
/*
* Validator for 16 digit code which uniquely identifies an ORDCID id
* Digit 16 is a chceksum for digits 1-15 - this validator checks that
* Note: use other validators to check for valid Url which contains
* https://orcid.org
*/
export function isORCIDValidator(control: AbstractControl): {[key: string]: any} | null {
if (control.value) { // don't check null values
You can’t perform that action at this time.