Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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-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 / Postgres migration.md
Last active May 25, 2020 16:45
Migrating from sqlite to postgres

Postgres migration

I had to migrate what had started as a toy website and has now become a real website from running on sqlite to postgres today. I use a push-to-deploy setup, so the process was a bit tricky. I only needed like 10 minutes of downtime to do it, but had to make sure I had all the steps in order. For future record:

  1. Update requirements.txt to include psycopg2 and push the latest version of production branch so that any migrations get applied on the sqlite DB and psycopg2 is installed in the virtual env.
@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