From 74c21347f7efcbc8f4d96441e2ddc2edf55f70c2 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 14 Apr 2021 02:59:16 -0700 Subject: [PATCH] bring in a new blog post, and get embedding the posts on the front page working... This is more documented in NOTES.md, which will be committed shortly.. Slight modifications to Tufte to have some space on the right, and add a custom.css to style the tags a bit better... We can drop article.j2 as it was a test and isn't needed anymore, and macros.j2 is empty now, and may be used for other things in the future... --- .../03/python-ctypes-wrapper-for-flac.html | 36 +++++++++++++++++++ content/2014/{10 => }/meta.yaml | 0 content/media/css/custom.css | 9 +++++ content/media/css/tufte.css | 5 +-- layout/article.j2 | 28 --------------- layout/base.j2 | 3 +- layout/blog.j2 | 8 ++--- layout/frontpage.j2 | 14 +++----- layout/macros.j2 | 31 ---------------- 9 files changed, 56 insertions(+), 78 deletions(-) create mode 100644 content/2014/03/python-ctypes-wrapper-for-flac.html rename content/2014/{10 => }/meta.yaml (100%) create mode 100644 content/media/css/custom.css delete mode 100644 layout/article.j2 diff --git a/content/2014/03/python-ctypes-wrapper-for-flac.html b/content/2014/03/python-ctypes-wrapper-for-flac.html new file mode 100644 index 0000000..f745edd --- /dev/null +++ b/content/2014/03/python-ctypes-wrapper-for-flac.html @@ -0,0 +1,36 @@ +--- +title: Python ctypes wrapper for FLAC +description: > + Python ctypes wrapper for FLAC +created: !!timestamp '2014-03-15' +tags: + - Python + - FLAC + - audio +--- + +As many people know, I've a fan of Python and I have been using it for +over 15 years now. + +One of the recent improvements that Python has made is the inclusion of +ctypes, which allows you to write a wrapper around shared libraries in +Python making it much easier to integrate libraries. Previously you'd +have to know the C Python API to get a module. There was SWIG, but if +the library was complicated, it'd often not produce working code and even +if it did, you'd have to hand tweak the output to get it to work the way +you think it should. + +One of the projects I've worked on is a UPnP media server. One of the +features it has is the ability to decode a flac file and support seeking +with in the file. + +I have now released a package of the code: +[ctflac-1.0.tar.gz](https://www.funkthat.com/~jmg/releases/ctflac-1.0.tar.gz). + +The one issue w/ ctypes is that some code can be very slow in Python. +The FLAC library presents the sample data as arrays for each channel, +though most libraries interleave the channel data. I have written a very +small library (that is optional) interleave.c that does this interleaving +in faster C code. In my tests, using the C code results in about a third of the CPU usage. + +Hope this is useful for others! diff --git a/content/2014/10/meta.yaml b/content/2014/meta.yaml similarity index 100% rename from content/2014/10/meta.yaml rename to content/2014/meta.yaml diff --git a/content/media/css/custom.css b/content/media/css/custom.css new file mode 100644 index 0000000..f26ed17 --- /dev/null +++ b/content/media/css/custom.css @@ -0,0 +1,9 @@ +ul.tags { + list-style-type: none; +} + +ul.tags li { + padding-left: .5em; + padding-right: .5em; + display: inline-block; +} diff --git a/content/media/css/tufte.css b/content/media/css/tufte.css index 976bbd9..1594981 100644 --- a/content/media/css/tufte.css +++ b/content/media/css/tufte.css @@ -45,7 +45,7 @@ html { } body { - width: 87.5%; + width: 83.5%; margin-left: auto; margin-right: auto; padding-left: 12.5%; @@ -114,6 +114,7 @@ article { } section { + padding-right: 5%; padding-top: 1rem; padding-bottom: 1rem; } @@ -343,7 +344,7 @@ h3 > code { pre > code { font-size: 0.9rem; - width: 52.5%; + width: 77.5%; margin-left: 2.5%; overflow-x: auto; display: block; diff --git a/layout/article.j2 b/layout/article.j2 deleted file mode 100644 index 8f114a5..0000000 --- a/layout/article.j2 +++ /dev/null @@ -1,28 +0,0 @@ -
- -

{{ res.meta.title }}

- -

Posted: {{ res.meta.created.strftime('%B %e, %Y') }}

- -{% if res.meta.tags %} - -{% endif %} -
-{% refer to res.relative_path as post %} -{{ post.post|markdown|typogrify }} -{# -{% filter markdown|typogrify -%} -{% mark post -%} -{% block post -%}{%- endblock %} -{%- endmark %} -{%- endfilter %} -#} -
diff --git a/layout/base.j2 b/layout/base.j2 index a42b29c..cf1f2e2 100644 --- a/layout/base.j2 +++ b/layout/base.j2 @@ -47,6 +47,7 @@ {% block css %} + {% endblock css %} {% block endhead %}{% endblock endhead %} @@ -67,7 +68,7 @@