Skip to content

Instantly share code, notes, and snippets.

@rmeekers
rmeekers / Send Gmail email to Omnifocus.bookmarklet.js
Last active November 23, 2016 16:04
Bookmarklet to send Gmail email to Omnifocus. Email subject will become the action title. A link to the email will be added to the action notes. If you've selected some text, it will be added to the notes as well.
javascript: (function() {
var enc = encodeURIComponent,
w = window,
frames = w.frames,
d = document,
ms = w.getSelection ? w.getSelection() : (d.getSelection) ? d.getSelection() : (d.selection ? d.selection.createRange().text : 0),
mu = w.location.href,
mt = d.title,
subjSpans = d.getElementsByClassName('hP'),
i, url;
@rmeekers
rmeekers / Send Gmail email to Omnifocus.applescript
Created November 23, 2016 16:05
Applescript to send Gmail email to Omnifocus. Email subject will become the action title. A link to the email will be added to the action notes. If you've selected some text, it will be added to the notes as well.
tell application "Google Chrome" to tell active tab of front window to set the URL to "
javascript: (function() {
var enc = encodeURIComponent,
w = window,
frames = w.frames,
d = document,
ms = w.getSelection ? w.getSelection() : (d.getSelection) ? d.getSelection() : (d.selection ? d.selection.createRange().text : 0),
mu = w.location.href,
mt = d.title,
subjSpans = d.getElementsByClassName('hP'),
@rmeekers
rmeekers / composeNewGmail.js
Created March 28, 2017 06:53
Compose new Gmail Bookmarklet
javascript:
(function() {
var url = 'https://mail.google.com/mail/?view=cm&fs=1';
var emailInput = prompt('E-mail address','');
var subjectInput = prompt('Subject','');
if (emailInput) {
url += '&to=' + escape(emailInput);
}
if (subjectInput) {
url += '&su=' + escape(subjectInput);
@rmeekers
rmeekers / importNumberOfInternetUsersPerCountry.gs
Created June 6, 2018 09:28
Formula to import the number of internet users for a given country
/*
* Datasource: public Google Spreadsheet with internet user data:
* https://docs.google.com/spreadsheets/d/1uxPf0einHJxZqkTvXnFto0O8Q4Lxw9RBPKoBCV2idTE/edit
*
* In the example below, we expect one or more country codes (ISO 3166-1 alpha-2), separated by a pipe (|), in cell A2
*/
=
SUM(
QUERY(
IMPORTRANGE("1uxPf0einHJxZqkTvXnFto0O8Q4Lxw9RBPKoBCV2idTE";"Data!B:C");
=TRIM(RIGHT(SUBSTITUTE(A2;"/";REPT(" ";100));99))
<tag>[\s\S]*?</tag>
/**
* Set of functions to import CSV files into a Google Sheet
* Imports CSV as text, freezes the first row, sets it bold and removes empty rows and columns.
*/
var settings = {
CSVFolderID: '',
singleFileID: '',
CSVSeparator: ';'
}

This describes how you can convert an XML file to a simple HTML table. The table can then be copy/pasted into a Google Sheet for example for further manipulation.

Install Saxon

brew install saxon

Convert XML file to HTML

saxon -s:input.xml -xsl:stylesheet.xsl -o:result.html

Sample XSL

@rmeekers
rmeekers / difference between straight and curly quotes.md
Created March 13, 2020 11:13
What's the difference between straight and curly quotes?

Straight quotes are the generic vertical quotation marks which are inserted via the quotes button on a keyboard. There are two variants:

  1. the straight single quote (') and 2 .the straight double quote (").

Curly quotes are the quotation marks used in good typography. There are two sets of curly quote characters:

  1. Single quotes: the opening single quote (‘) and the closing single quote (’)
  2. Double quotes: the opening double quote (“) and the closing double quote (”).

How to use these quotes in a text editor?

@rmeekers
rmeekers / vlookup_in_multiple_columns.md
Last active April 24, 2020 07:13
Google Sheet formula to do a vlookup in multiple columns

Assumptions:

  • value to look for is in cell C2
  • array to search in: 'email domains'!A:Y
  • value to retrieve is in column no 26 (Z)
=ArrayFormula(if(countif('email domains'!A:Y;C2)=0;"";index('email domains'!A:Z;sum(if('email domains'!A:Y=C2;row('email domains'!A:Y))); sum(if('email domains'!A:Y=C2;26)))))