Skip to content

Instantly share code, notes, and snippets.

/* for rh menu */
.ou-menu-wrapper {
padding: 24px 24px 24px 0px;
}
ou-menu-wrapper-in-right-side {
padding: 0px; /*get rid of passing if showing in right-side-wrapper*/
}
.ou-menu-item-wrapper {
@theotherdy
theotherdy / orcid.validator.ts
Last active July 23, 2018 13:38
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/
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
<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>
...
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 {
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Orcid implements Rule
{
/**
* Create a new rule instance.
@theotherdy
theotherdy / UserController.php
Last active July 31, 2018 09:26
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/
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',
...,
];
/*
* 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
*/
/* 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;
@theotherdy
theotherdy / 4.3.1_seq1-10.r
Last active October 5, 2018 09:11
4.3 Data Management: Essential Commands 6-10
# by isn't needed
seq(from = 1, to = 10) # I could get the same result with seq(1, 10)
@theotherdy
theotherdy / canvas-gist-embed.js
Last active October 5, 2018 11:20
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/
(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();