Skip to content

Instantly share code, notes, and snippets.

View davidwallacejackson's full-sized avatar

David Jackson davidwallacejackson

View GitHub Profile
import ResizeSensor from require('css-element-queries/src/ResizeSensor')
export default {
// this will run in addition to any mounted() hook on the component
// using the mixin
mounted () {
this.$resizeSensor = new ResizeSensor(this.$el, () => {
// per the docs (https://vuejs.org/v2/api/#Vue-set),
// this lets you add a reactive data property that wasn't specified in the component's
// data() { } hook
watch: {
number: {
handler: function (newValue, oldValue) {
// do your update here
},
immediate: true
}
let blacklists = ["https://mail.google.com/*","https://www.duolingo.com/*","https://trello.com/*","http://null-null-null.github.io/*","file:///*"]
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, y, lambda)
%NNCOSTFUNCTION Implements the neural network cost function for a two layer
%neural network which performs classification
% [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ...
% X, y, lambda) computes the cost and gradient of the neural network. The
% parameters for the neural network are "unrolled" into the vector
import { useState, useEffect } from 'react';
type State<T> = {
data?: T;
error?: T;
};
export default function useAsync<T>(
getData: () => Promise<T>,
deps: readonly any[],
interface Serialized {
a: string,
b: string,
c: string | string[],
}
interface Deserialized {
field: number, //parsed from a
otherField: string, // parsed from b
yetAnotherField: string[] // parsed from c
import { useState, useEffect, useRef } from 'react';
type State<T> = {
data?: T;
error?: any;
};
export default function useAsync<T>(
getData: () => Promise<T>,
deps: readonly any[],
import {Plugin} from 'vite';
import fs from 'fs';
const index = fs.readFileSync(__dirname + '/index.html', 'utf-8');
const fileUrls: Plugin = {
name: 'pass-through-file-urls',
configureServer: server => {
server.middlewares.use(async (req, res, next) => {
if (req.url?.match(/.*\/files\/.*$/)) {
// ...and the encoder is turned counter-clockwise, send Shift+Tab
const key_override_t encoder_prev_app = ko_make_basic(MOD_MASK_GUI, KC_VOLD, G(S(KC_TAB)));
// ...and the encoder is turned clockwise, send Tab
const key_override_t encoder_next_app = ko_make_basic(MOD_MASK_GUI, KC_VOLU, G(KC_TAB));
// when the Opt key is held...
// ...and the encoder is turned counter-clockwise, send Shift+Cmd+`