Skip to content

Instantly share code, notes, and snippets.

@uhop
uhop / rich.html
Created May 14, 2018 19:11
Rich text editor sketch
<!doctype html>
<html>
<head>
<title>Rich text editor demo</title>
<script src="./rich.js" defer></script>
<style>
#editor[contentEditable=true] {
padding: 0.5em;
margin: 1em;
}
@uhop
uhop / Component.js
Created June 12, 2017 22:14
React to Web Components bridge
class Component extends HTMLElement {
constructor () {
super();
this.addEventListener('click', this.changeBackground.bind(this));
this.addEventListener('transitionend', this.revertBackground.bind(this));
}
static get observedAttributes () {
return ['text'];
}
@uhop
uhop / dnd.js
Last active March 14, 2017 20:07
The minimalistic DnD code.
(function () {
'use strict';
window.dnd = window.dnd || {};
function Move (container, options, node, e) {
this.container = container;
this.options = options;
this.node = node;
@uhop
uhop / .bash_aliases
Created July 3, 2016 20:19
My bash setup
# commands from http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html
#alias chmod='command chmod -c'
alias cpr='command cp -rpv'
alias df='command df -kh'
alias df1='command df -ia'
alias diff='diff -up'
alias dsiz='du -sk * | sort -n --'
alias du='command du -kh'
alias du1='echo *|tr " " "n" |xargs -iFF command du -hs FF|sort'
background: linear-gradient(45deg, #222 12%, transparent 0, transparent 88%, #222 0),
linear-gradient(135deg, transparent 37%, #111 0, #444 32%, #111 63%, transparent 0),
linear-gradient(45deg, transparent 37%, #222 0, #222 63%, transparent 0) #000;
background-size: 15px 15px;
@uhop
uhop / geom.js
Last active November 11, 2020 23:18
All necessary Pie chart calculations based on dojox.charting.
var TWO_PI = 2 * Math.PI;
function tmpl (template, dict) {
return template.replace(/\$\{([^\}]*)\}/g, function (_, name) {
return dict[name];
});
}
function makeSegment (args, options) {
// args is {startAngle, angle, index, className}
@uhop
uhop / print.html
Last active November 29, 2022 23:35
The way to print slides as PDF.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Multi-page print test</title>
<!--
Print to PDF, landscape, letter size, no margins, enable background graphics.
Tested on Chrome.
-->
<style>
Verifying that +elazutkin is my blockchain ID. https://onename.com/elazutkin
@uhop
uhop / nginx-webp-sample.conf
Last active May 25, 2024 17:02
Serving WEBP with nginx conditionally.
user www-data;
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
* + table {
border-style:solid;
border-width:1px;
border-color:#e7e3e7;
}
* + table th, * + table td {
border-style:dashed;
border-width:1px;
border-color:#e7e3e7;