Skip to content

Instantly share code, notes, and snippets.

@jakerella
jakerella / jkq.js
Last active May 2, 2022 21:46
An ultra-light, jQuery-like micro-library for selecting DOM elements and manipulating them.
(function() {
'use strict';
/**
* Core method, similar to jQuery (only simpler)
*
* @param {String|HTMLElement} s The CSS selector to search for or HTML element to wrap with functionality
* @param {HTMLElement} root OPTIONAL An HTML element to start the element query from
* @return {Array} The collection of elements, wrapped with functionality (see API methods)
*/
@misterunknown
misterunknown / alpine-virtual-desktop.sh
Created March 29, 2019 13:47
Alpine Linux: Virtual Desktop installation
#!/bin/sh
#
# This script installs a virtual desktop using Xvfb, x11vnc, mate-desktop,
# mate-session-manager and Apache Guacamole. It runs on Alpine Linux Edge.
#
# See also:
# https://www.reddit.com/r/selfhosted/comments/b6k8go/poc_a_desktop_in_a_container_on_a_server/
# This is the user, under which the MATE desktop will run
# Notice: For several reasons this shouldn't be root

Minio on GlusterFS Volume Guide

This document provides instructions on how to serve a GlusterFS volume across multiple Minio instances. There are no special configuration changes required to enable this feature. Access to files stored on GlusterFS volume are locked and synchronized by default.

Download Minio

Visit here to download binary for your operating system.

Mount GlusterFS

@drodsou
drodsou / custom-element-minimal.js
Last active October 21, 2022 18:20
minimal custom element - web component, webcomponent
/* non-shadow dom minimal custom element */
customElements.define("counter-ce", class extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<button>
${this.innerHTML} <span></span>
</button>
`;
this.update = ()=>{
@ebidel
ebidel / dom-property-watcher.js
Created September 12, 2015 17:01
DOM property watcher using ES6 proxies.
// Watch accesses/sets on a DOM element property.
function watchPropsOn(el) {
return new Proxy(el, {
get(target, propKey, receiver) {
//return Reflect.get(target, propKey, receiver);
console.log('get', propKey);
return el[propKey];
},
set(target, propKey, value, receiver) {
console.log('set', propKey, value);
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>capture microphone audio into buffer</title>
</head>
<body>
<audio id="player" controls></audio>
<input
type="text"
id="username"
@davidmaxwaterman
davidmaxwaterman / gun-panic-notes.md
Last active January 25, 2023 21:27
Notes on writing end-to-end tests with gun's panic server/client.

The docs on Gun's Panic are written from the point of view of someone testing Gun itself, rather than an app that uses Gun. As such it isn't very helpful in how to get started, and the tests aren't all that applicable. So, I figured I'd share my findings after building Panic tests for my app.

refs:

NB, in my case, I was using Gun in an extension, so my 'app' is quite well separated from the panic server. Most people will be testing Gun in a regular web page, so it might be simpler.

  1. in the project you want to test, install dev dependency gun-server: npm install --save-dev panic-server
@felquis
felquis / sw.js
Created December 9, 2015 19:41
sw.js
/*
Copyright 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
// WARNING: There's much more to know/do around hooks, and
// this is just a simplification of how these work.
// shared references, updated
// per each hook invoke
let execution = null;
let current = null;
let context = null;
let args = null;
@sivagao
sivagao / minimal_pubsub.js
Created April 2, 2013 10:02
minimal pubsub js
var pubsub = function(l, u, r, i) { // cool! 闭包并且初始化vars
return function(n, f) {
r = l[n] = l[n] || [], i = -1;
if (f && f.call) r.push(f);
else while (r[++i]) r[i].apply(u, arguments);
}
}({});
// subscribe to event
pubsub("eat_cookie", function() {