This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// drop simulation function | |
async function runDropSimulation(sources, path, options) { | |
const { wait = 1000, shouldRelease = true } = options || {}; | |
// create the data transfer | |
const dataTransfer = new DataTransfer(); | |
for (const src of sources) { | |
const blob = await fetch(src).then((res) => res.blob()); | |
const file = new File([blob], src.split('/').pop(), { type: blob.type }); | |
dataTransfer.items.add(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// drag simulation function | |
async function runDragSimulation(path, options) { | |
const { wait = 1000, shouldRelease = true } = options; | |
// helper to wait for x milliseconds | |
const sleep = (time) => | |
new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(); | |
}, time); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![cfg_attr( | |
all(not(debug_assertions), target_os = "windows"), | |
windows_subsystem = "windows" | |
)] | |
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command | |
#[tauri::command] | |
fn sync(name: &str) -> String { | |
format!("Hello, {}! You've been greeted from Rust!", name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://gist.github.com/vdbelt/20f116236d2ebffa92f131e679c0551a | |
addEventListener('fetch', event => { | |
event.respondWith(purgeCache(event.request)) | |
}) | |
async function purgeCache(request) { | |
// get zone querystring value | |
const zone = new URL(request.url).searchParams.get('zone'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ( | |
options: { imageData: ImageData; amount: number }, | |
done: (err: string, imageData: ImageData) => void | |
): void => { | |
const { imageData, amount = 1 } = options; | |
const intensity = Math.round(Math.max(1, amount) * 2); | |
const range = Math.round(intensity * 0.5); | |
const inputWidth = imageData.width; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ( | |
options: { imageData: ImageData; matrix: number[] }, | |
done: (err: string, imageData: ImageData) => void | |
): void => { | |
const { imageData, matrix } = options; | |
if (!matrix) return done(null, imageData); | |
// calculate kernel weight | |
let kernelWeight = matrix.reduce((prev, curr) => prev + curr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const DEBUG = false; | |
const style = document.createElement('style'); | |
style.textContent = ` | |
.sim-pointer { | |
margin-top: -1px; | |
position: absolute; | |
z-index: 9999999999999; | |
left: -24px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro codeline(x, y, totalStatements, spaceWidth) %} | |
{% set offset = x %} | |
{% for i in range(0, totalStatements) -%} | |
{% set width = [2, 4, 8, 12, 24] | random %} | |
{% set opacity = [0.5, 0.75, 1] | random %} | |
<path d="M{{ offset }} {{ y }} h{{width}}" opacity="{{ opacity }}"/> | |
{% set offset = offset + width + spaceWidth %} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (element: HTMLElement, options: any = {}) => { | |
// if added as action on non focusable element you should add tabindex=0 attribute | |
const { | |
direction = undefined, | |
shiftMultiplier = 10, | |
bubbles = false, | |
stopKeydownPropagation = true, | |
} = options; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createCloudinary = (cloudName, unsignedUploadPreset) => ({ | |
process: (fieldName, file, metadata, load, error, progress, abort) => { | |
// `fieldName` and `meta` are not used for now | |
const url = `https://api.cloudinary.com/v1_1/${cloudName}/upload`; | |
const xhr = new XMLHttpRequest(); | |
const formData = new FormData(); |
NewerOlder