Skip to content

Instantly share code, notes, and snippets.

Damien Seguin dmnsgn

Block or report user

Report or block dmnsgn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View es-modules-in-the-browser-almost-now-sw.js
// Disclaimer: this is not stable nor properly tested
// Not sure about the security implications of hijacking the fetch request either
// https://gist.github.com/pilwon/ff55634a29bb4456e0dd
const ES_MODULE_IMPORT_REGEX = /\bimport\s+(?:.+\s+from\s+)?[\'"]([^"\']+)["\']/g;
const packages = new Map().set(
"lodash/clamp",
"https://cdn.jsdelivr.net/npm/lodash-es@4.17.8/clamp.js"
);
View es-modules-in-the-browser-app.js
import clamp from "lodash/clamp";
const num = Infinity;
const answer = clamp(num, 0, 42);
console.log(answer);
export default answer;
View package-name-maps.html
<!DOCTYPE html>
<html>
<head>
<title>ES modules in the browser - almost - now | Package name maps</title>
</head>
<body>
<!-- Declare the package map -->
<script type="packagemap">
View es-modules-service-worker.html
<!DOCTYPE html>
<html>
<head>
<title>ES modules in the browser - almost - now | Service worker</title>
</head>
<body>
<script>
// Register
View unpkg-getlibs.html
<!DOCTYPE html>
<html>
<head>
<title>ES modules in the browser - almost - now | unpkg getLibs</title>
<!-- Include the getlibs endpoint -->
<script src="https://unpkg.com/getlibs"></script>
</head>
<body>
View basics-script-type-module.html
<!DOCTYPE html>
<html>
<head>
<title>ES modules in the browser - almost - now | Basics: script type module</title>
</head>
<body>
<!-- Use a type set to "module" with a fallback -->
<script type="module" src="app.js"></script>
@dmnsgn
dmnsgn / listAllEventListeners.js
Created Apr 5, 2017
List all event listeners in a document
View listAllEventListeners.js
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@dmnsgn
dmnsgn / listen_say_voices.sh
Created Mar 28, 2017
Listen to all voices available by the `say` command on macOS
View listen_say_voices.sh
for voice in `say -v '?' | awk '{print $1}'`; do say -v "$voice" "Hi `whoami` my name is ${voice}"; done
@dmnsgn
dmnsgn / WebGL-frameworks-libraries.md
Last active Nov 13, 2019
A collection of WebGL frameworks and libraries
View WebGL-frameworks-libraries.md

A non-exhaustive list of WebGL frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are outdated/not maintained anymore.

Engines and libraries

  • three.js: JavaScript 3D library
  • stack.gl: an open software ecosystem for WebGL, built on top of browserify and npm.
  • PixiJS: Super fast HTML 5 2D rendering engine that uses webGL with canvas fallback
  • Pex: Pex is a javascript 3d library / engine allowing for seamless development between Plask and WebGL in the browser.
  • Babylon.js: a complete JavaScript framework for building 3D games with HTML 5 and WebGL
  • Filament: Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS and WASM/WebGL
  • ClayGL: A WebGL graphic library helping you to
@dmnsgn
dmnsgn / SingletonNoInstance.js
Created Apr 16, 2016
ES6 singleton pattern: prevent the creation of an instance
View SingletonNoInstance.js
// Implementation 4: prevent the creation of an instance
class SingletonNoInstance {
constructor(enforcer) {
throw new Error('Cannot construct singleton');
}
static singletonMethod() {
return 'singletonMethod';
}
You can’t perform that action at this time.