Skip to content

Instantly share code, notes, and snippets.

View penalosa's full-sized avatar
🌜
I'm me

Somhairle MacLeòid penalosa

🌜
I'm me
View GitHub Profile

Update to add Login Link

function LoginLink(user: UserData | null) {
  return !user?.id && html`<a href="/.well-known/authenticate" id="login">Login</a>`;
}

Inject the link into the Page component

/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
declare class DOMException extends Error {
constructor(param0?: string, param1?: string);
readonly message: string;
readonly name: string;
readonly code: number;
readonly stack: any;
static readonly INDEX_SIZE_ERR: number;
@penalosa
penalosa / diff.md
Last active October 27, 2022 17:16

Workers/Standards diff

class DOMException

Standards:

DOMException: {
    prototype: DOMException;
    new (message?: string, name?: string): DOMException;
    readonly ABORT_ERR: number;
@penalosa
penalosa / Qualtrics.js
Created January 19, 2022 23:04
Support inline dropdown in Qualtrics
Qualtrics.SurveyEngine.addOnload(function()
{
this.hideChoices();
const alreadySelected = this.getSelectedChoices()[0]
this.getQuestionTextContainer().innerHTML = this.getQuestionInfo().QuestionText.replace(
"{{dropdown}}", "<select required name=\""+this.getQuestionInfo().QuestionID+"\" id=\""+this.getQuestionInfo().QuestionID+"-select\"><option value=\"\" disabled "+(!alreadySelected?"selected":"")+" hidden></option>"+Object.values(this.getQuestionInfo().Choices).map(c => "<option "+(alreadySelected ==c.RecodeValue?"selected":"")+ " value=\""+c.RecodeValue+"\">"+c.Text+"</option>").join("\n")+"</select>"
);
this.getQuestionTextContainer().querySelector("select").addEventListener('change', e => {
let option = e.target[e.target.selectedIndex]
this.setChoiceValueByRecodeValue(option.value, option.text)
<script>
import {Fetch} from "svelte-data-loading"
</script>
<Fetch
base="https://example.com" // optional, will be prepended to all API `load` paths. Special case of `transform`
headers={headers => ({...headers, ...headersToAdd})} // Add additional headers for e.g. auth. Special case of `transform`
transform={({method, url, headers, body}) => ({method, url, headers, body})} // Modify a request before it's made
defautLoading={Component} // display if the `loading` slot isn't provided
defaultError={Component} // display if the `error` slot isn't provided
<script>
import { Get } from "svelte-data-loading"
</script>
<Get load="/my/api" let:data>
{data}
<div slot="loading">
Loading...
</div>
<div slot="error" let:error>
<script>
import { Get } from "svelte-data-loading"
</script>
<Get load="/my/api" let:data>
{data}
</Get>
@penalosa
penalosa / Simple.svelte
Created March 23, 2021 13:13
Data fetching in Svelte
<script>
import { onMount } from "svelte"
let data
onMount(() => {
fetch("https://example.com/my/api")
.then(r => r.json())
.then(j => data = j)
}
</script>

Keybase proof

I hereby claim:

  • I am penalosa on github.
  • I am penalosa (https://keybase.io/penalosa) on keybase.
  • I have a public key ASBudht7HyNR0Wlp5KMYj8fUXjqOB5LzIbB6L6W2cGOj3Qo

To claim this, I am signing this object:

@penalosa
penalosa / cloudSettings
Created February 2, 2020 22:06
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-02T22:06:41.571Z","extensionVersion":"v3.4.3"}