···11+#!/usr/bin/env python3
22+33+from markdown2 import markdown_path
44+import os
55+import fileinput
66+import sys
77+88+# change our cwd
99+os.chdir('bin')
1010+1111+blog = '../pages/blog/'
1212+1313+# bunch of file hacks to get to the most recent file
1414+def getrecent(path):
1515+ files = [path + f for f in os.listdir(blog)
1616+ if f not in ['_index.md', 'feed.xml']]
1717+ files.sort(key=os.path.getmtime, reverse=True)
1818+ return files[0]
1919+2020+2121+def update_index(s):
2222+ path = '../pages/_index.md'
2323+ with open(path, 'r') as f:
2424+ md = f.readlines()
2525+ latest = md.index('# latest post\n')
2626+ md[latest + 2] = s + '\n'
2727+2828+ with open(path, 'w') as f:
2929+ f.writelines(md)
3030+3131+3232+def update_blog(s):
3333+ path = '../pages/blog/_index.md'
3434+ s = s + '\n'
3535+ for l in fileinput.FileInput(path, inplace=1):
3636+ if "marker" in l:
3737+ l=l.replace(l, l + s)
3838+ print(l, end=''),
3939+4040+# fetch title and date
4141+meta = markdown_path(getrecent(blog), extras=['metadata']).metadata
4242+fname = os.path.basename(os.path.splitext(getrecent(blog))[0])
4343+url = '/blog/' + fname
4444+line = f"`{meta['date']}` [{meta['title']}]({url})"
4545+4646+update_index(line)
4747+update_blog(line)
4848+4949+
+8-7
build/blog/index.html
···3636 <div align="left">
3737 <h1 id="all-posts-rssblogfeedxml">all posts (<a href="/blog/feed.xml">rss</a>)</h1>
38383939-<p><code>2019-09-17</code> – <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p>
3939+<p><!–marker–!>
4040+<code>2019-09-17</code> <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p>
40414141-<p><code>2019-09-10</code> – <a href="/blog/disinfo">Disinformation demystified</a></p>
4242+<p><code>2019-09-10</code> <a href="/blog/disinfo">Disinformation demystified</a></p>
42434343-<p><code>2019-08-15</code> – <a href="/blog/mailserver">Setting up my personal mailserver</a></p>
4444+<p><code>2019-08-15</code> <a href="/blog/mailserver">Setting up my personal mailserver</a></p>
44454545-<p><code>2019-08-06</code> – <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p>
4646+<p><code>2019-08-06</code> <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p>
46474747-<p><code>2019-06-06</code> – <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p>
4848+<p><code>2019-06-06</code> <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p>
48494949-<p><code>2019-13-05</code> – <a href="/blog/my-setup">My Setup</a></p>
5050+<p><code>2019-13-05</code> <a href="/blog/my-setup">My Setup</a></p>
50515151-<p><code>2019-02-08</code> – <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p>
5252+<p><code>2019-02-08</code> <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p>
52535354 </div>
5455 <hr />
···1919Want to contact me? The best way is via email (plain-text please), at [x@icyphox.sh](mailto:x@icyphox.sh)
2020or via [Twitter](https://twitter.com/icyphox) DMs.
21212222-# latest post
2222+# latest post
23232424-`2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17)
2424+`2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17)
25252626([see all](/blog))
2727···3131*still reading* | by **Vikram Sood** | started **8th August, 2019**
32323333([see all](/reading))
3434+
+8-7
pages/blog/_index.md
···6677# all posts ([rss](/blog/feed.xml))
8899-`2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17)
99+<!--marker--!>
1010+`2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17)
10111111-`2019-09-10` -- [Disinformation demystified](/blog/disinfo)
1212+`2019-09-10` [Disinformation demystified](/blog/disinfo)
12131313-`2019-08-15` -- [Setting up my personal mailserver](/blog/mailserver)
1414+`2019-08-15` [Setting up my personal mailserver](/blog/mailserver)
14151515-`2019-08-06` -- [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50)
1616+`2019-08-06` [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50)
16171717-`2019-06-06` -- [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm)
1818+`2019-06-06` [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm)
18191919-`2019-13-05` -- [My Setup](/blog/my-setup)
2020+`2019-13-05` [My Setup](/blog/my-setup)
20212121-`2019-02-08` -- [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/)
2222+`2019-02-08` [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/)
2223