Skip to content

Instantly share code, notes, and snippets.

View bendytree's full-sized avatar

Josh Wright bendytree

View GitHub Profile
-- In Better Touch Tool, set this Apple Script to run when Zed.app launches
delay 0.5
tell application "System Events"
tell process "Zed"
if exists menu item "Exit Full Screen" of menu "View" of menu bar 1 then
click menu item "Exit Full Screen" of menu "View" of menu bar 1
end if
end tell
end tell

Migrating from Vue2 to Vue3

Instructions

I'm migrating an old codebase from Vue 2.6 with @vue/composition-api to Vue 3.5.12. I will provide my typescript file below. Please respond with the updated code. DO NOT remove comments! Your response will be saved to replace the old typescript file (so DO NOT include comments or markdown formatting). If you don't make any changes, that's fine - but just repeat back the typescript as-is... don't add comments!

Instructions

The following file was just migrated from Vue 2 to Vue 3, but there is one task remaining. Vue 3 does not allow exports within a "setup" script. So you must create a new typescript script tag (above the setup script). We will call this new script tag the "standard" script and it will contain all imports, exports, etc.

Please respond with the updated code. Do not include comments like "Here is the code". Your response will be saved in place of the old file (so DO NOT include comments or markdown formatting).

Migrating from Vue2 to Vue3

Instructions

I'm migrating an old codebase from Vue 2.6 with @vue/composition-api to Vue 3.5.12. I will provide my Vue 2 single file component below. Please respond with the updated code. Your response will be saved to replace the old file (so do not include comments or markdown formatting).

Concerns

const log = (...args) => {}; //console.log(...args);
const isIOS = (function () {
return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
|| (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
})();
class ScrollLocker {
orig = {};
isLocked = false;
@bendytree
bendytree / noyito-relay.js
Created August 26, 2022 02:52
NOYITO USB Control Relay in NodeJS
const HID = require('node-hid');
class Relay {
constructor() {
const devices = HID.devices();
const deviceInfo = devices.find(d => d.product === 'USBRelay8');
this.device = new HID.HID(deviceInfo.path);
}
set(n, on) {
const send = Array(9).fill(0x0);
@bendytree
bendytree / s3hostfix.js
Created May 10, 2022 14:08
CloudFlare worker to rewrite Host header for S3
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
const lookup = {
"mybucket.example.com": "https://my-s3-bucket.s3.us-east-1.amazonaws.com",
};
async function handleRequest(origRequest) {
const origUrl = new URL(origRequest.url);
const fs = require('fs');
const _ = require('lodash');
const PNG = require('pngjs').PNG;
const { promisify } = require('util');
const md5File = require('md5-file');
const images = [
{ filename: 'graphic-gif.gif' },
{ filename: 'graphic-jpg-0.jpg' },
{ filename: 'graphic-jpg-76.jpg' },
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
import app from 'src/api';
import * as qs from 'query-string';
import axios from 'axios';
const settings = {
appId: '**************',
appSecret: '**************************',
redirectUrl: 'https://myapp.com/facebook/callback',
};