Skip to content

Instantly share code, notes, and snippets.

View sventschui's full-sized avatar

Sven sventschui

  • Winterthur, Switzerland
View GitHub Profile
@sventschui
sventschui / machine.js
Last active November 4, 2020 14:55
Generated by XState Viz: https://xstate.js.org/viz
const fetchInitialData = () => {
return Promise.resolve({
countries: [],
allowedCurrencies: []
});
};
const submitPayment = () => {
return Promise.resolve({});
@sventschui
sventschui / machine.js
Created November 2, 2020 16:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sventschui
sventschui / ViewControler.swift
Last active April 4, 2023 11:08
JS based download in WKWebView
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if (openInDocumentPreview(navigationAction.request.url!)) {
decisionHandler(.cancel)
// TODO: Add more supported mime-types for missing content-disposition headers
webView.evaluateJavaScript("""
(async function download() {
const url = '\(navigationAction.request.url!.absoluteString)';
try {
@sventschui
sventschui / JPA detached delete
Created May 24, 2012 08:32
Ist dies der korrekte Ansatz um eine "detached" Entity zu löschen?
public void delete(Entity e) {
this.em.remove(em.find(Entity.class, e.getId()));
}