This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# pnginator.rb: pack a .js file into a PNG image with an HTML payload; | |
# when saved with an .html extension and opened in a browser, the HTML extracts and executes | |
# the javascript. | |
# Usage: ruby pnginator.rb input.js output.png.html | |
# By Gasman <http://matt.west.co.tt/> | |
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encode inputfile.tar.gz as a series of video frames | |
# Frames are written to frames/frameNNNN.png | |
from PIL import Image | |
with open('inputfile.tar.gz', 'rb') as f: | |
data = f.read() | |
WIDTH = 120 | |
HEIGHT = 90 | |
CHUNK_SIZE = int((WIDTH * HEIGHT) / 8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import wave | |
from io import BytesIO | |
from PIL import Image | |
wave_buffer = BytesIO() | |
data_len = 0 | |
with wave.open('nevergonna-1920.wav', 'rb') as wav: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On a real-world site with 3058 HTML fragments | |
with richtext-benchmark/original: | |
1. 13.098440 | |
2. 14.320241 | |
3. 13.525923 | |
with richtext-benchmark/loic: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from collections.abc import Mapping | |
import html | |
import re | |
import warnings | |
from django.utils.html import conditional_escape, format_html | |
from django.utils.safestring import mark_safe | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, unicode_literals | |
from bs4 import BeautifulSoup, Tag | |
from django.db import models | |
from wagtail.wagtailadmin.edit_handlers import StreamFieldPanel | |
from wagtail.wagtailcore import blocks | |
from wagtail.wagtailcore.fields import StreamField | |
from wagtail.wagtailcore.models import Page | |
from wagtail.wagtailcore.rich_text import RichText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from django.utils.encoding import python_2_unicode_compatible | |
from modelcluster.models import ClusterableModel | |
from modelcluster.fields import ParentalKey | |
from wagtail.wagtailcore.models import Orderable | |
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel | |
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from hashlib import md5 | |
def gfm(text): | |
# Extract pre blocks. | |
extractions = {} | |
def pre_extraction_callback(matchobj): | |
digest = md5(matchobj.group(0).encode('utf-8')).hexdigest() | |
extractions[digest] = matchobj.group(0) | |
return "{gfm-extraction-%s}" % digest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Command line util for acquiring a one-off Twitter OAuth access token | |
# Based on http://blog.beefyapps.com/2010/01/simple-ruby-oauth-with-twitter/ | |
require 'rubygems' | |
require 'oauth' | |
puts <<EOS | |
Set up your application at https://twitter.com/apps/ (as a 'Client' app), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
from django.db import models | |
from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, StreamBlock | |
from wagtail.wagtailcore.models import Page | |
from wagtail.wagtailcore.fields import StreamField, RichTextField | |
from wagtail.wagtailimages.blocks import ImageChooserBlock | |
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel | |
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, \ |
NewerOlder