Skip to content

Instantly share code, notes, and snippets.

View mmichealjroberts's full-sized avatar

Michael J. Roberts mmichealjroberts

  • University College London
  • United Kingdom
View GitHub Profile
{"data": {"type": "dois", "attributes": {"doi": "10.80519/asencis.4302-4ae4", "prefix": "10.80519", "suffix": "asencis.4302-4ae4", "event": "publish", "creators": [{"name": "Roberts, Michael", "nameType": "Personal", "givenName": "Michael", "familyName": "Roberts", "nameIdentifiers": [{"nameIdentifier": "https://orcid.org/0000-0001-6203-1986", "nameIdentifierScheme": "ORCID"}]}], "titles": [{"title": "HadCRUT4 Land & Ocean Temperature Measurements"}], "publisher": "asencis", "container": {}, "publicationYear": 2020, "subjects": [], "contributors": [], "types": {"resourceTypeGeneral": "Dataset"}, "relatedIdentifiers": [], "sizes": [21510268], "formats": ["application/x-netcdf"], "descriptions": [{"description": "HadCRUT4 is a global temperature dataset, providing gridded temperature anomalies across the world as well as averages for the hemispheres and the globe as a whole. CRUTEM4 and HadSST3 are the land and ocean components of this overall dataset, respectively.", "descriptionType": "Abstract"}, {"descripti
def serialize_dataset_to_doi(dataset: DatasetStorePointer) -> Dict[str, Any]:
return {
"data": {
"type": "dois",
"attributes": {
"doi": dataset.doi,
"prefix": settings.DATACITE['DOI_PREFIX'],
"suffix": dataset.doi_suffix,
"event": "publish",
"creators": dataset.creators if dataset.creators else [],
db = {}
db['ENGINE'] = 'django.db.backends.postgresql'
db['OPTIONS'] = {'autocommit': True}
db['NAME'] = my_model_db['database']
db['PASSWORD'] = my_model_db['password']
db['USER'] = my_model_db['user']
db['HOST'] = my_model_db['host']
logger.info("Connecting to database {db} on {host}".format(db=source_db['NAME'], host=source_db['HOST']))
@mmichealjroberts
mmichealjroberts / main.js
Created May 4, 2020 08:44
Disbaling Vue.js devtools in Production
const PRODUCTION = process.env.NODE_ENV === "production";
if (PRODUCTION) {
Vue.config.devtools = false
Vue.config.debug = false
Vue.config.silent = true
}
@mmichealjroberts
mmichealjroberts / remove-objects-from-array-by-object-property.js
Created May 4, 2020 08:32
Remove Objects From Array By Object Property
// Source: http://stackoverflow.com/questions/16491758/remove-objects-from-array-by-object-property
var arr = [
{
id: 1,
property: "Property",
},
{
id:2,
property: "Property",
@mmichealjroberts
mmichealjroberts / fields.py
Created March 26, 2020 11:29
Base64EncodedImage field serializer including to_representation() method
import six
import uuid
import base64
from django.conf import settings
from django.core.files import File
from django.core.files.base import ContentFile
from rest_framework import serializers
@mmichealjroberts
mmichealjroberts / dbinfo.py
Last active February 17, 2020 11:00
Django 3.0 DB Info Management Command
from django.db import connection
from django.core.management.base import BaseCommand
from django.conf import settings
class Command(BaseCommand):
help = 'Displays The Currently Connected DB Settings'
def handle(self, *args, **kwargs):
<template>
<div>
<FilePond
v-bind:max-files="4"
v-bind:allow-multiple="true"
v-bind:accepted-file-types="allowedFiletypes"
v-bind:server="server.process"
v-bind:files="files"
v-on:init="handleFilePondInit"