Skip to content

Instantly share code, notes, and snippets.

@hazelweakly
hazelweakly / cry-more.html
Last active January 8, 2023 07:46
Enron Mullet Is A Giant CryBaby
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Redirecting to the Fediverse</title>
<head>
<script>
// let's say this is hosted at example.com. Given a url of one of the forms:
// - example.com/@user@instance.com/post_id
// - example.com/@user@instance.com
// - example.com/@instance.com
// redirect accordingly
@matthewp
matthewp / decorate-element.js
Last active April 23, 2020 07:57
decorate-element
function decorate(tag, template) {
customElements.define(tag, class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
let root = this.shadowRoot;
if(!root.firstChild) {
@bmeck
bmeck / proposal-no-path-searching.md
Last active February 6, 2018 17:20
Removal of path searching / defining a hook for migration.

Problem

There has been no progress in working towards a single cohesive story for path resolution between Servers and Web. Notable discussion points relevant to this are:

  1. Node has a path searching algorithm.
  2. Web has not been able to gather support for any of the following:
    1. Build tooling as part of UX expectations (lack of interest)
    2. Smarter static web servers (lack of interest). PoC example at https://github.com/bmeck/esm-http-server
  3. A resolve based hook. (interest shown with desire for ~6 months of userland experimentation)
@alekseykulikov
alekseykulikov / index.md
Last active April 14, 2024 00:32
Principles we use to write CSS for modern browsers

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@domenic
domenic / 0-usage.js
Last active August 21, 2023 09:02
Import module function (assuming <script type="module"> is implemented)
// Dynamic module loading using runtime-composed strings, decisions, etc.
for (const m of ["cool", "awesome", "fun", "whee"]) {
if (Math.random() > 0.5) {
importModule(`/js/${m}.js`).then(
module => console.log("Module instance object for " + m, module),
e => console.error(e)
);
}
}
@jonathantneal
jonathantneal / eventListener.js
Created June 4, 2012 16:27
Event Listener polyfill
// addEventListener polyfill IE6+
!window.addEventListener && (function (window, document) {
function Event(e, element) {
var instance = this;
for (property in e) {
instance[property] = e[property];
}
instance.currentTarget = element;
@matthewp
matthewp / gist:2036428
Created March 14, 2012 13:23
Object.is polyfill
// Blatantly stolen from ES6 specs. Kept here for reference.
// http://wiki.ecmascript.org/doku.php?id=harmony:egal
if(!Object.is) {
Object.defineProperty(Object, 'is', {
value: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
return x !== 0 || 1 / x === 1 / y;
@tfausak
tfausak / wp7-tile.html
Created February 3, 2012 04:39
Generate a tile-able page for Windows Phone 7.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="maximum-scale=1,minimum-scale=1,width=device-width" name="viewport">
<style>
body {
margin: 0;
@LeverOne
LeverOne / LICENSE.txt
Created October 24, 2011 04:17 — forked from jed/LICENSE.txt
generate random v4 UUIDs (107 bytes)
DO WTF YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Alexey Silin <pinkoblomingo@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WTF YOU WANT TO PUBLIC LICENSE
@nzjrs
nzjrs / skype-notify.py
Created June 3, 2011 13:14
Python script to make Skype co-operate with GNOME3 notifications
#!/usr/bin/env python
# Python script to make Skype co-operate with GNOME3 notifications.
#
#
# Copyright (c) 2011, John Stowers
#
# Adapted from skype-notify.py
# Copyright (c) 2009, Lightbreeze
#
#