Skip to content

Instantly share code, notes, and snippets.

Kacper Sokol So-Cool

View GitHub Profile
@So-Cool
So-Cool / 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…
View reference-markdown-metadata-from-jinja-template.py
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() }}
@So-Cool
So-Cool / high.ipynb
Created Jun 30, 2017
HighCharts in Jupyter
View high.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View jupyter_python_interact.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@So-Cool
So-Cool / Readme.md
Last active May 27, 2017
AISB hackathon -- story comprehension
View Readme.md

Automated story comprehension

This notebook shows how to extract background knowledge and relations from a story text. To this end, we use Stanford's NLP parser available to download here.

We parsed the following story (story.txt file):

Mary was sleeping.
Her phone rang.
She was annoyed.
Mary answered the phone.
Ann told the good news to Mary.
@So-Cool
So-Cool / find10.md
Last active Dec 29, 2016
How to find a 'perfect 10'
View find10.md

Perfect10

How it works?

How to find a 'perfect 10'?

This simple algorithm applies Optional Stopping Time Theorem used for calculating optimal exercising time for American Options. Simply, it tells you whether your current partner is optimal.
Optimality is calculated in a sens of score represented by integer: 1--10, that you assign to your current partner. You also need to specify a few more parameters like:

  • score(1--10) of you current partner,
@So-Cool
So-Cool / cuckooml.md
Last active Aug 31, 2016
CuckooML datasets
View cuckooml.md
@So-Cool
So-Cool / slider_ex.ipynb
Created Apr 5, 2016
Jupyter notebook with sliders
View slider_ex.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@So-Cool
So-Cool / xkcd.ipynb
Created Mar 24, 2016
XKCD in Python
View xkcd.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View cuckooml.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@So-Cool
So-Cool / extractor.py
Last active Oct 20, 2017
Prettify ugly MS Word HTML
View extractor.py
import os
import sys
from bs4 import BeautifulSoup
if len(sys.argv) != 3:
sys.exit("First argument is HTML second is an output directory.")
with open(sys.argv[1], "r") as html:
soup = BeautifulSoup(html.read(), "html.parser")
You can’t perform that action at this time.