Skip to content

Instantly share code, notes, and snippets.

View timfish's full-sized avatar

Tim Fish timfish

  • Freelance
  • 03:37 (UTC +02:00)
View GitHub Profile
@timfish
timfish / README.md
Last active January 30, 2024 18:43
Sentry Cloudflare Workers Proxy - Makes JavaScript and event submission first-party!
  • Add the worker.js code to a new Cloudflare Worker
  • Set up a worker for your domain than responds to /tunnel/* and point it to your new worker
  • Add the Sentry script to your html but replace https://browser.sentry-cdn.com/ with ./tunnel/
    • Eg. <script src="./tunnel/6.9.0/bundle.min.js"></script>
  • init Sentry with the tunnel option set to /tunnel/
    • Eg. Sentry.init({ dsn: "__DSN__", tunnel: "/tunnel/" })
  • Rejoice at how everything now works with ad blockers

As you start out with your Electron app, you'll start to notice some features which have been carried directly across from the browser realm but make less sense for a desktop app. Here are the ones I can remember:

Ctrl or + Click Opens Links in New Window

In Electron just like in Chrome, if you hold down the Ctrl key (or on Mac) while clicking a link it opens in a new window. For many SPA apps, this is undesired and will load another full copy of your app in another window. You can disable this by calling the following code once you've created a BrowserWindow

win = new BrowserWindow({ ... });
@timfish
timfish / index.html
Last active November 3, 2021 00:29
Protocol JSON stream to renderer
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
@timfish
timfish / index.html
Last active July 20, 2021 20:14
no-unhandledRejection
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
{
__isElectronForgePlugin: true,
async init() {
//
},
getHook(hookName) {
switch (hookName) {
case "resolveForgeConfig":
return this.resolveForgeConfig;
}
use rhai::{plugin::*, Engine, FnPtr};
use std::{
sync::{Arc, Mutex},
thread,
time::Duration,
};
#[derive(Debug, Clone)]
pub struct Service {
func: Arc<Mutex<Option<FnPtr>>>,
@timfish
timfish / index.html
Created November 15, 2020 23:19
ip-address
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
@timfish
timfish / index.html
Created April 29, 2020 15:02
autonumeric
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
@timfish
timfish / app.html
Last active August 1, 2018 12:18
remove svg wrappers
<template>
<require from="./select-component"></require>
<select-component selected.bind="selected"></select-component>
<div>
Selected: ${selected.name}
</div>
</template>
@timfish
timfish / app.html
Created July 31, 2018 17:45
remove svg wrappers
<template>
<require from="./svg-rect"></require>
<svg width="100" height="100" style="background-color:lightblue">
<svg-rect rect.bind="{x: 5, y: 5, width: 30, height: 20}"></svg-rect>
</svg>
</template>