Skip to content

Instantly share code, notes, and snippets.

View cben's full-sized avatar

Beni Cherniavsky-Paskin cben

View GitHub Profile
#!/usr/bin/env python3
class memoize(dict):
def __init__(self, func):
self.func = func
dict.__init__(self)
def __call__(self, *args):
return self[args]
def __missing__(self, key):
@cben
cben / fix.patch
Last active September 26, 2015 05:37
xml-google-maps wordpress plugin - fix for Warning: sprintf() [function.sprintf]: Too few arguments in .../xmlgooglemaps_googleMapsAPI.php on line 421
diff --git a/xmlgooglemaps_googleMapsAPI.php b/xmlgooglemaps_googleMapsAPI.php
index 5b797d9..fb337f2 100644
--- a/xmlgooglemaps_googleMapsAPI.php
+++ b/xmlgooglemaps_googleMapsAPI.php
@@ -418,7 +418,7 @@ class xmlgooglemaps_googleMapAPI {
$ret .= $this->addLine(sprintf('}'),4);
$ret .= $this->addLine(sprintf('setTimeout(smt_%s, 100);', $this->map_id, $this->map_id),4);
$ret .= $this->addLine('} catch(err) {',3);
- $ret .= $this->addLine(sprintf('document.write("Could not load the file with the GGeoXML Object! Check the file, the Google Maps API says that there is an error! Validate your links or files with the Validators from <a href=\'http://googlegeodevelopers.blogspot.com/2008/06/new-service-released-kml-validator.html\' target=\'_blank\'>http://googlegeodevelopers.blogspot.com/2008/06/new-service-released-kml-validator.html</a> or try enter the URL to your file directly in the search field of <a href
@cben
cben / pandoc_filter_math2doublebackslashmath.py
Created March 18, 2014 04:52
pandoc filter to convert $..$ and $$...$$ math to \\(..\\) and \\[...\\] respectively.
#!/usr/bin/env python2
r"""
Use via ``pandoc --filter pandoc_filter_math2doublebackslashmath.py``
to convert math (in any syntax pandoc will recognize)
to \\(..\\) and \\[...\\] syntaxes (``tex_math_double_backslash`` extension).
"""
from pandocfilters import toJSONFilter, Math, RawInline, RawBlock
import sys, json
>>> import yaml # need to install PyYAML
>>> dict_1 = {'a': 0, '1': {1: {'abc': [1, 2, 3, 4, 5, 6], 'efg': [7, 8, 9, 10, 100]},
2: {'1': {1: 'abc', 2: 'efg'}, '2': {3: 'abc'}}}, '2': [1, 2, 3, 4, 5, 6]}
>>> print(yaml.safe_dump(dict_1, default_flow_style=False))
'1':
1:
abc:
- 1
- 2
@cben
cben / README.md
Last active January 22, 2016 23:02
tests of data URI PNG image in gmail

I did some tests to confirm Gmail doesn't like data URI images (PNG format). (It was a well-documented fact, but I couldn't find conclusive tests after the image proxy change). => Still broken.

The second test was send from https://putsmail.com/tests/fceaea2b-e495-4cfc-a263-bb0883e1135b (where anybody can edit and re-send it).

Results: The image shows fine during compose (I inserted via DOM inspector) and are not stripped on send, but are not shown when reading via gmail. ALT text does show in gmail.

Connecting to gmail via thunderbird shows all data uri images fine.

@cben
cben / README.md
Created February 5, 2015 10:15
Haroopad 0.13.0 issue with inline math

haroopad-v0.13.0-x64.deb on lubuntu 14.10. Same problem both in editor preview and Export -> HTML file.

  • \sqrt{3x-1}+(1+x)^2 at the end is rendered as display math. (Same when I tried single dollars with corresponding Preferences option.)
  • the text that follows it in the paragragh disappeared.
fr = null;
try {
FileReader fr = new FileReader(file);
try {
BufferedReader br = new BufferedReader(fr);
String line = null;
} finally {
// [I'm not sure swallowing errors here is good but that's an unrelated question -- Beni]
try {
fr.close();
@cben
cben / README.md
Last active August 29, 2015 14:17
mathml fallback in email

Tried to test mail.html, as sent to myself via https://putsmail.com/tests/f742cb78-6229-450f-bfa7-494c2349e859. Copy-pasted into Mailchimp (which give interface to Litmus testing for $3/test). Alas, it seems the Mailchimp editor sanitized(?) it into actual-test.html, stripping out the MathML :-( Results below make more sense now...


Full results at https://rawgit.com/cben/51056286578d837cba46/raw/results.html (16MB of images!)

  1. MathML didn't render anywhere. Not thunderbird, not Apple Mail / iOS. I'll have to read www.maths-informatique-jeux.com/blog/frederic/?post/2012/11/14/Writing-mathematics-in-emails again and try to make it work.
@cben
cben / dodgetocat_v2.png
Last active April 1, 2023 13:16 — forked from alienlebarge/dodgetocat_v2.png
Is there an easy way to link image in a GIST ?
dodgetocat_v2.png