Skip to content

Instantly share code, notes, and snippets.

View cben's full-sized avatar

Beni Cherniavsky-Paskin cben

View GitHub Profile
@cben
cben / README.md
Last active April 11, 2018 13:50
testing mathml->image fallback in email

Test mail1.html

Tested 2 fallback ways inside semantics tag:

  1. <annotation-xml encoding="MathML-Presentation"><mtext><img ... (the math was display="block")
  2. <annotation-xml encoding="text/html"><img ... (the math was inline)

Didn't try altimg fallbacks, nor <annotation encoding="image/png" src=...> as I figure it's unlikely any clients that don't understand MathML would honor them. img can be honored simply by skipping all the unfamiliar tags.

I tried to use xmlns in a way that (hopefully) would work both in HTML5 and older parsers...

@cben
cben / README.md
Last active April 11, 2018 13:57
svg>switch>foreignObject>img fallback in email

From what I read known SVG->PNG fallbacks don't work well in email:
http://stylecampaign.com/blog/2014/01/basics-of-svg-in-email/
http://emailcodegeek.com/svg-images/
http://mikevoermans.com/css/svg-png-fallback-html-email

But then I stumbled upon this 2009 technique: http://www.kaizou.org/2009/03/inline-svg-fallback/ and it works surprisingly well!

Caveat: apparently it only works when the svg contains no text; any text content might be visible (in addition to the fallback) in clients that don't understand svg.

[since the source blog doesn't support comments and the margins of a tweet are too narrow]

Hmm, interesting distinction. But I don't see why your way is better than having the CI build the image.

  • It is more flexible in allowing me to build the image any ad-hoc way I want, e.g. modify files inside the container and take a snapshot.
    But my primary Dev instinct is that I don't want this. The last thing I want in prod is an image I don't have sources for. I'm not thinking in terms "test this image before deploying" but in terms of "test this source code". Which means build an image from Dockerfile in a clean env, test this "clean" image (and yes, push this same image to prod).
@cben
cben / numeric_entities_to_utf8.py
Last active August 29, 2015 14:23
Convert numeric entities (`&#123;`) to unicode
#!/usr/bin/python3
# Caution: this will convert everywhere, including inside <script>...</script> or CDATA sections.
import re, os
def numeric_entities_to_utf8(fname):
s = open(fname, encoding='utf8', newline='').read()
s = re.sub(r'&#([0-9]+);', lambda m: chr(int(m.group(1))), s)
with open(fname, 'w', encoding='utf8', newline='') as f:
@cben
cben / foo.py
Last active August 29, 2015 14:26 — forked from anonymous/foo.py
print("Hello, world!")
@cben
cben / CF-CNAME-flattened-TTL.md
Created September 10, 2015 20:46
The problem with CloudFlare's DNS "CNAME flattening" TTL

[attaching this to a CloudFlare survey why I left them (for DNSimple)]

I was a free user using CloudFlare only for DNS, chiefly because it can simulate CNAME at an apex domain. The apex domains mathdown.net,mathdown.com point to mathdown-cben.rhcloud.com. Cloudflare "CNAME-flattening" nicely returns an A record; unfortunately it's served with a huge TTL of 7 days(!), which causes a long outage when the underlying IP changes.

I asked support how I can lower the TTL (BTW it's great that you provide free support at all) and was told [https://support.cloudflare.com/hc/en-us/requests/522551, emphasis mine]:

This is based on the TTL of your authoritative provider for mathdown-cben.rhcloud.com:

@cben
cben / jasmine-before-it-value.rst
Last active October 2, 2015 06:13
Jasmine: Using in a test a value set in beforeAll/Each

Using Jasmine 2, I want to:

  1. compute a value in a beforeAll/beforeEach block
  2. access it in the it / nested describe block

so far easy: set a var and use it [OUT below]. It will have right values by the time it runs.

  1. extract test cases / nested suite into a function.

That's harder, especially with nested suites - nested describe body is executed immediately,

@cben
cben / LICENSE.md
Last active October 13, 2015 14:35
Dumping ground: Latin Modern subsetted to just 0-9 digits, see https://github.com/cben/mathdown/issues/95

Caveat

I've spent about a day writing this README and LICENSE files trying to make sure I've complied with all legalese; but there are a few concerns (documented below).

This directory contains a tiny font derived from Latin Modern Ver. 2.004, 30.10.2009 (lmroman10-*.otf under https://www.ctan.org/tex-archive/fonts/lm/fonts/opentype/public/lm/) subsetted and converted via http://www.fontsquirrel.com/tools/webfont-generator. See README.md for the exact procedure.

Everything under this directory is provided under GUST Font License 1.0 (text below),

@cben
cben / downvotes.fish
Last active December 21, 2015 11:28
Find all downvoted posts from my StackOverflow
#!/usr/bin/fish
# TODO: this is only SO — how to fetch from all StackExchange sites?
set MY_USER_ID 239657
# Don't remember exact content of filter but it includes .has_more and more info about votes.
# See: curl --compressed "https://api.stackexchange.com/2.2/filters/$FILTER"
set FILTER '!b0OfN6h15EULDG'
rm downvotes-*
set page 1

Errors in console upon loading a website — any website, not just on docs.google.com!:

chrome-extension://iilhmomfbagepbbfmpdpogkohiidffnm/js/particles/stats.js:4 Uncaught SyntaxError: Unexpected token <
chrome-extension://iilhmomfbagepbbfmpdpogkohiidffnm/js/particles/particles.js:654 Uncaught TypeError: Cannot read property 'appendChild' of null
  window.particlesJS @ chrome-extension://iilhmomfbagepbbfmpdpogkohiidffnm/js/particles/particles.js:654
  (anonymous function) @ chrome-extension://iilhmomfbagepbbfmpdpogkohiidffnm/js/particles/nodes.js:1

(first bug is simple: chrome-extension://iilhmomfbagepbbfmpdpogkohiidffnm/js/particles/stats.js shows an HTML source - apparently a github page - instead of JS)