Skip to content

Instantly share code, notes, and snippets.

View davidwallacejackson's full-sized avatar

David Jackson davidwallacejackson

View GitHub Profile
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\/.*$/)) {
import { useState, useEffect, useRef } from 'react';
type State<T> = {
data?: T;
error?: any;
};
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 } from 'react';
type State<T> = {
data?: T;
error?: T;
};
export default function useAsync<T>(
getData: () => Promise<T>,
deps: readonly any[],
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
let blacklists = ["https://mail.google.com/*","https://www.duolingo.com/*","https://trello.com/*","http://null-null-null.github.io/*","file:///*"]
watch: {
number: {
handler: function (newValue, oldValue) {
// do your update here
},
immediate: true
}
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
@davidwallacejackson
davidwallacejackson / controllers.application.js
Created August 11, 2016 16:34
Query Param replace:true bug repro
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: [{
testParam: {
replace: true
}
}],
var playerToEntrance = PortalEntrance.position - PlayerCamera.transform.position;
Debug.Log(playerToEntrance);
var renderCenter = originalPosition - playerToEntrance;
var leftEyeOffset = InputTracking.GetLocalPosition((VRNode)0);
var leftEyeRotation = InputTracking.GetLocalRotation((VRNode)0);
var rightEyeOffset = InputTracking.GetLocalPosition((VRNode)1);
var rightEyeRotation = InputTracking.GetLocalRotation((VRNode)1);