Skip to content

Instantly share code, notes, and snippets.

@felipeochoa
felipeochoa / quill-blots.org
Created January 13, 2018 17:13
Notes to self on blots in quill

Quill Blots

There are four options for creating a custom blot:

——-——–+——-+

InlineBlock

——-——–+——-+

Embed

——-——–+——-+

Text
@felipeochoa
felipeochoa / pp-debug.el
Last active November 19, 2021 19:59
Pretty print emacs debug frames
;;; pp-debug.el --- Pretty-printing debugger -*- lexical-binding: t -*-
;; Copyright (C) 2018 Felipe Ochoa
;; Author: Felipe Ochoa
;; Created: 5 Dec 2017
;; License: GPLv3
;;; Commentary:
;;; Pretty-print debugger frames.
@felipeochoa
felipeochoa / mu4e-ical.el
Created October 2, 2017 08:08
Display iCal details inline with mu4e
(defun fov-ical-mark-body-text (oldfun msg)
"Wrap (OLDFUN MSG) with (propertize * 'fov-ical-message-body-text t)."
(propertize (funcall oldfun msg) 'fov-ical-message-body-text t))
(advice-add 'mu4e-message-body-text :around 'fov-ical-mark-body-text)
(defvar mu4e~view-msg)
(defun fov-ical-insert-info ()
"Submit async requests to insert ical info the current mu4e-view buffer."
(dolist (part (mu4e-message-field mu4e~view-msg :parts))
@felipeochoa
felipeochoa / debug-js2-ast.el
Last active September 4, 2018 14:12
Helper for debugging js2 ast
(defsubst js2-node-very-short-name (n)
"Return the very short name of node N as a string, e.g. `if'."
(replace-regexp-in-string "-node$" ""
(replace-regexp-in-string "^js2-" ""
(js2-node-short-name n))))
(defun debug-js2-ast ()
(interactive)
(if-let ((buf (current-buffer))
(top js2-mode-ast))
import React from 'react';
import autosize from 'autosize';
class AutoTextarea extends React.Component {
constructor(props) {
super(props);
this.refHandler = this.refHandler.bind(this);
this.textarea = null;
}

Just built my app as a single bundle using Webpack, babel, and UglifyJS. It came out to 1,283,741 characters.

Here are the most space-consuming words in the resulting in the resulting bundle, how often they occur, and the total number of characters they take up:

word occurences chracters
function 8764 70,112
@felipeochoa
felipeochoa / comment-form.js
Created April 7, 2017 16:35
@-mentions for Quill
const quillModules = {
toolbar: ["bold", "italic", "underline", "strike"],
// mentions is added in constructor
keyboard: {
bindings: {
tab: {
key: 9,
handler: function(range, context) {
return this.quill.mentionHandler(range.context);
}
@felipeochoa
felipeochoa / el-reportero.js
Created April 5, 2017 23:08
JSON reporter for jest
const fs = require("fs");
const path = require("path");
const mkdirp = require("mkdirp");
// when use use fit, jasmine never calls suiteStarted / suiteDone, so make a fake one to use
const fakeFocusedSuite = {
id: 'focused',
description: 'focused specs',
fullName: 'focused specs'
};
@felipeochoa
felipeochoa / mu4e-thread-folding.el
Created March 16, 2017 18:05
Thread folding in mu4e
;; Refactored from https://github.com/djcb/mu/pull/783
(defun mu4e~headers-msg-unread-p (msg)
"Check if MSG is unread."
(let ((flags (mu4e-message-field msg :flags)))
(and (member 'unread flags) (not (member 'trashed flags)))))
(defvar mu4e-headers-folding-slug-function
(lambda (headers) (format " (%d)" (length headers)))
@felipeochoa
felipeochoa / DOCX spec.md
Created March 8, 2017 19:37
Quick overview of how the DOCX format works

How the DOCX spec works

The standard can be downloaded from the ISO website at [this direct link][iso direct link]

DOCX documents are a zipped folder containing several interacting components in a word doc. The main ones are:

  • word/document.xml: The main document content
  • word/styles.xml: Name style information (e.g. "Header 1"), similar to CSS