Skip to content

Instantly share code, notes, and snippets.

View btbytes's full-sized avatar
🐎
🏈

Pradeep Gowda btbytes

🐎
🏈
View GitHub Profile
@btbytes
btbytes / reference-markdown-metadata-from-jinja-template.py
Created August 29, 2019 22:10 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@btbytes
btbytes / rich-already-answered-that.md
Created October 7, 2018 23:42 — forked from reborg/rich-already-answered-that.md
Clojure Design Decisions

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link below in the summary jumps at the answer on this page.
  • The link on the question itself points back at the original post.

Summary

@btbytes
btbytes / wclwn.md
Created October 2, 2018 10:50 — forked from zacharycarter/wclwn.md
Binding to C Libraries with Nim

Pony Considerations

If you're thinking of checking out the Pony programming language, here's a list of things that I think are important to know. This list is based on a Tweet that I wrote.

Editor/IDE support

There are Pony packages for several popular editors.

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@btbytes
btbytes / pandoc.css
Created February 7, 2018 16:13 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@btbytes
btbytes / example.md
Created January 30, 2018 18:52 — forked from adityam/example.md
Run a preprocessor in Hakyll
title
Example file

This is an example file to show how preprocessing works. If you want to show source code in a document, you can directly typing it in. However, that means that we cannot compile the code to check if it is working. To test the code, we must include it in a separate file, and then include the file in the main text.

@btbytes
btbytes / letsencrypt_2017.md
Last active January 27, 2018 14:17 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@btbytes
btbytes / BasicServer.re
Created January 2, 2018 15:53 — forked from jaredly/BasicServer.re
Simple Static File Server in Reason/OCaml
let recv = (client, maxlen) => {
let bytes = Bytes.create(maxlen);
let len = Unix.recv(client, bytes, 0, maxlen, []);
Bytes.sub_string(bytes, 0, len)
};
let parse_top = top => {
let parts = Str.split(Str.regexp("[ \t]+"), top);
switch (parts) {
@btbytes
btbytes / deft-in-dir.el
Created November 14, 2017 15:32 — forked from doitian/deft-in-dir.el
multiple deft #emacs
(defun deft-in-dir (directory &optional buffer)
(interactive "Ddir: ")
(setq buffer (or buffer "*deft-in-dir*"))
(switch-to-buffer (or buffer "*deft-in-dir*"))
;; load deft if not loaded yet
(unless (and
(boundp 'deft-directory)
(boundp 'deft-buffer))