Skip to content

Instantly share code, notes, and snippets.

@slava-vishnyakov
slava-vishnyakov / readme.md
Last active April 12, 2024 06:24
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@berkus
berkus / xbox-one-wireless-protocol.md
Created April 4, 2019 13:21 — forked from alfredkrohmer/xbox-one-wireless-protocol.md
XBox One Wireless Controller Protocol

Physical layer

The dongle itself is sending out data using 802.11a (5 GHz WiFi) with OFDM and 6 Mbit/s data rate:

Radiotap Header v0, Length 38
    Header revision: 0
    Header pad: 0
    Header length: 38
    Present flags
@argyleink
argyleink / easings.css
Created February 26, 2018 22:34
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@timtyrrell
timtyrrell / .gitlab-ci.yml
Last active May 8, 2018 07:21
Gitlab config to run electron on our Gitlab CoreOS install
image: node:latest
stages:
- build
cache:
paths:
- node_modules/
build_and_test_job:
@LukeL99
LukeL99 / compress-web-video.sh
Created December 29, 2015 21:22
Compress video output for HTML5 background video
#!/bin/bash
# Make sure ffmpeg is installed with the following flags
# brew install ffmpeg --with-libvpx
#
# Take source video, convert to raw grayscale (-pix_fmt gray),
# remove audio track (-an), darken it by 50% (-vf "lutyuv=y=val*.5"),
# and output to an avi container for maximum compatibility.
# Pipe all that to stdout
# (ffmpeg -i - \) take input rawvideo track, and...
@bendc
bendc / nodelist-iteration.js
Created January 13, 2015 14:39
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@yuval-a
yuval-a / js-micro.js
Last active January 7, 2024 18:38
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@pstaender
pstaender / remove_pdf_password.sh
Created November 11, 2013 12:07
Remove password from protected PDF file with GhostScript
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf
@nsisodiya
nsisodiya / iframe.js
Last active December 16, 2020 14:45
Dynamic IFRAME Using Dynamic Document Fragment when html & css are provided as Strings
var html = '<h1 class="nar">Narendra</div>';
var css = '.nar { color: red; background: url("http://google.com/images/google_favicon_128.png") repeat scroll 0 0 transparent;}';
var nodeWhereToAppend = document.body;
//var nodeWhereToAppend = document.getElementById("container");
function CreateIframe(html, css, nodeWhereToAppend){
var fragment = document.createDocumentFragment();
var iframe = document.createElement('iframe');
iframe.onload = function(){
var doc = this.contentWindow.document;