Skip to content

Instantly share code, notes, and snippets.

View matths's full-sized avatar
💻
In a former live I was a flash developer.

Matthias Dittgen matths

💻
In a former live I was a flash developer.
View GitHub Profile
@antony
antony / index.html
Last active October 24, 2020 22:33
Svelte App on Older Browsers (IE11+)
<!-- generated via npm run build && npx create-polyfill-service-url analyse --file public/bundle.js -->
<script crossorigin="anonymous" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.map,ArrayBuffer,console,DataView,Date.prototype.toISOString,document,fetch,Function.prototype.bind,globalThis,Map,Object.create,Object.defineProperties,Object.defineProperty,Object.entries,Object.getOwnPropertyDescriptor,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.getPrototypeOf,Object.keys,Object.setPrototypeOf,Promise,Reflect,Reflect.construct,Set,Symbol,Symbol.iterator,WeakMap,WeakSet"></script>
@williamngan
williamngan / PtsCanvas.svelte
Last active March 20, 2022 07:52
This is a quick test of Pts (https://ptsjs.org) with Svelte (https://svelte.dev)
<script>
/* This is a quick test of Pts (https://ptsjs.org) with Svelte (https://svelte.dev) */
import { onMount } from "svelte";
import { CanvasSpace, Rectangle } from "pts";
let container, space, form;
onMount(() => {
space = new CanvasSpace(container).setup({bgcolor: "#52f"});
form = space.getForm();
space.add( time => {
@bohnacker
bohnacker / points_to_curve.js
Last active August 20, 2021 15:31
A javascript function that takes a list of points and calculates a curvy path that passes all these points. See https://hartmut-bohnacker.de/projects/points-to-curve for more information.
// Calculates a curve that goes through a number of points.
// There are lots of mathematical approaches to do so
// (see: https://en.wikipedia.org/wiki/Cubic_Hermite_spline).
// The most commonly used seems to be the Catmull–Rom spline.
// My approch here is not intended to be a new general
// solution to this problem, but it should fit some geometrical
// and graphical needs. See
// https://hartmut-bohnacker.de/projects/points-to-curve
// for more explanation.
@matths
matths / as-object.js
Last active February 9, 2019 18:53
"You can also use the approach below, which will result in a very nice data table at the top of your markdown when viewing the file GitHub:"
{
Title: 'My awesome markdown file',
Author: 'Me',
Scripts: [
'js/doStuff.js',
'js/doMoreStuff.js'
]
}
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 27, 2024 06:09
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active July 22, 2024 09:05
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@don
don / hexStringToArrayBuffer.js
Created May 3, 2018 17:54
Convert hex string to ArrayBuffer
/**
* Convert a hex string to an ArrayBuffer.
*
* @param {string} hexString - hex representation of bytes
* @return {ArrayBuffer} - The bytes in an ArrayBuffer.
*/
function hexStringToArrayBuffer(hexString) {
// remove the leading 0x
hexString = hexString.replace(/^0x/, '');
@rewida17
rewida17 / termux
Last active April 10, 2024 06:24
Run termux env via eg adb shell
#!/system/xbin/bash
#Based on https://github.com/termux/termux-app/issues/77
export PREFIX='/data/data/com.termux/files/usr'
export HOME='/data/data/com.termux/files/home'
export LD_LIBRARY_PATH='/data/data/com.termux/files/usr/lib'
export PATH="/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:$PATH"
export LANG='en_US.UTF-8'
export SHELL='/data/data/com.termux/files/usr/bin/bash'
export BIN='/data/data/com.termux/files/usr/bin'
export TERM=vt220
@p120ph37
p120ph37 / csd-wrapper.sh
Last active December 12, 2023 23:52
A simple implementation of a CSD-Wrapper as required for OpenConnect to comply with Cisco AnyConnect "hostscan" policies.
#!/bin/bash
unset URL TICKET STUB GROUP CERTHASH LANGSELEN
shift
while [ "$1" ]; do
if [ "$1" == "-ticket" ]; then shift; TICKET=$1; fi
if [ "$1" == "-stub" ]; then shift; STUB=$1; fi
if [ "$1" == "-group" ]; then shift; GROUP=$1; fi
if [ "$1" == "-certhash" ]; then shift; CERTHASH=$1; fi
if [ "$1" == "-url" ]; then shift; URL=$1; fi
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")