Skip to content

Instantly share code, notes, and snippets.

// Footnote previews for markdown by David Yates
// See an example here:
// https://davidyat.es/2020/12/31/footnote-previews/
//
// License: MIT
// set previewSide to specify an additional class for footnote previews
refs = document.querySelectorAll("[id^=fnref]");
activeBox = null;
@dmyates
dmyates / gist:f98b839bdeafdb2e29a457f654e405fd
Last active April 11, 2018 10:27 — forked from larsch/gist:140038
Treetop parser for Lua objects (limited)
LUAOBJECT_GRAMMAR = %q{
grammar LuaObject
rule luaobj
space value space { def to_ruby; value.to_ruby; end }
end
rule value
nil / float / number / string / table / boolean
end
@dmyates
dmyates / description-list.html
Last active September 4, 2023 09:43
Simple description list shortcode for use with the Hugo static site generator.
{{ .Get 0 | replaceRE "<ul>" "<dl>" .Inner | replaceRE "</ul>" "</dl>" | replaceRE "<li>" "<dt>" | replaceRE "(<dt>.*?): " "$1</dt><dd>" | replaceRE "</li>" "</dd>" | markdownify }}

Keybase proof

I hereby claim:

  • I am dmyates on github.
  • I am dyates (https://keybase.io/dyates) on keybase.
  • I have a public key ASCvbnbKTOgPiB7lR4L_PkHDt6nNSB2G5LFITXgCCLYEdAo

To claim this, I am signing this object:

@dmyates
dmyates / SimpleHTTPServerWithUpload.py
Last active July 9, 2017 10:27 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
# Convert all files in dir from Ghost-compatible markdown to Hugo-compatible markdown
# (changes footnotes and headings)
#
# Usage: ruby md2md.rb /path/to/posts
# #Heading --> # Heading
def headings(str)
str.gsub(/(#+)(?=[^ #])/i,'\1 ')
end
#!/usr/bin/python
#
# Count and compare the syllables for each set of two lines in the provided file. Bombs out with numbers and mispelt words.
# Uses Python 2.7 and nltk (pip install nltk)
import sys
from nltk.corpus import cmudict
d = cmudict.dict()
def syllable_count(word):
@dmyates
dmyates / diraware-webshell.rb
Last active March 2, 2016 14:30
Directory persistence hack for command-execution webshells
# Simple directory-aware webshell hack
# Todo: get open-uri to co-operate with shell args for URLs
# For now, put the whole command-injection-vulnerable URL in the place indicated
# pls don't use for evil
require 'open-uri'
prefix = ""
command = "whoami"
while true
@dmyates
dmyates / hidemessage.py
Created March 2, 2014 12:27
Hide messages in images and get them back.
# Hiding Messages in Images
#
#
# Just do this to encode messages:
#
# python hidemessage.py -e <filewithmessage> <imagetohidein>
#
#
# ...and do this to decode messages:
#