Skip to content

Instantly share code, notes, and snippets.

View masnick's full-sized avatar

Max Masnick masnick

View GitHub Profile
@masnick
masnick / How I Do PlantUML.md
Created November 25, 2020 13:35 — forked from jerieljan/How I Do PlantUML.md
PlantUML with Style -- How I do PlantUML

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist explains how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • I use a stylesheet.iuml file that keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
  • You can choose to either run the PlantUML jar over your file/s, or use an IDE like VSCode with the PlantUML extension. Here's a preview of example-sequence.puml for example: https://imgur.com/Klk3w2F
@masnick
masnick / gist:1291199
Created October 16, 2011 17:57
jQuery inject one-liner
var a=document.createElement("script");a.type="text/javascript";a.async=true;a.src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);
@masnick
masnick / emails.md
Last active June 3, 2020 09:54
A strategy for writing clearer emails

From this HBR article:

  • Start email with single sentence summary:

    Bottom line: This is a better way to write emails informed by US Military practices.

  • Then have a Background section that succinctly provides the necessary context for the "bottom line."

  • Keep the whole thing as short as possible, ideally to avoid the reader having to scoll.

# Based off of https://github.com/jupyter/notebook/blob/master/docs/source/extending/savehooks.rst
import io
import os
from notebook.utils import to_api_path
_script_exporter = None
_html_exporter = None
def script_post_save(model, os_path, contents_manager, **kwargs):
@masnick
masnick / output.txt
Created December 28, 2019 19:32
Output of tweet to Markdown shortcut
[Max Masnick on Twitter](https://twitter.com/masnick/status/1209899493048639488):
> It’s surprisingly hard to find a tweet with multiple URLs in it for API response testing purposes.
>
> So here are my two favorite non-Google search engines:
>
> 1. <https://t.co/jFqkR0eo8x>
> 2. <https://t.co/UZD9mmtzEH>
>
> 👍
@masnick
masnick / safari_to_chrome.applescript
Created December 27, 2019 21:18
Open Safari tabs in Google Chrome
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set url_list to {}
tell application "Safari"
set w to window 1
try
repeat with t in (tabs of w)
@masnick
masnick / batch_convert_docx_to_pdf.applescript
Last active December 17, 2019 15:34
Batch convert Word files (.docx) to PDF
-- Based on https://discussions.apple.com/thread/250068127 (thanks, VikingOSX!)
property word_docs : {"org.openxmlformats.wordprocessingml.document", "com.microsoft.word.doc"}
property default_path : (path to desktop) as alias
property Delim : {".docx", ".doc"}
property PDF : ".pdf"
set outPDF to {}
set selected_files to (choose file of type word_docs default location default_path with multiple selections allowed without invisibles and showing package contents)
@masnick
masnick / README.md
Created November 18, 2019 14:40
CiteAs bookmarklet

This is the code for a bookmarklet to open the current page in CiteAs.

@masnick
masnick / phone_format.rb
Created January 27, 2015 14:40
Phone number format script for TextExpander snippet
#! /usr/bin/env ruby
# Source: tadman on StackOverflow - http://stackoverflow.com/a/5913838
def formatted_number(number)
digits = number.gsub(/\D/, '').split(//)
if (digits.length == 11 and digits[0] == '1')
# Strip leading 1
digits.shift
tell application "iTunes" to activate
tell application "System Events"
tell window "iTunes" of process "iTunes"
click (first UI element whose help is "Choose which speakers to use.")
end tell
end tell