Skip to content

Instantly share code, notes, and snippets.

View epogrebnyak's full-sized avatar

Evgeny Pogrebnyak epogrebnyak

View GitHub Profile
@ljvmiranda921
ljvmiranda921 / Makefile
Last active September 10, 2018 10:58
Contains a minimal workflow for compiling LaTeX documents
# A Simple Makefile for LaTeX
# Author: Lester James V. Miranda
# E-mail: ljvmiranda@gmail.com
# Default variables which can be edited via the terminal
BUILDDIR = _build
COMPILER = pdflatex
PROJECT = main
BIBLIOGRAPHY = bibliography
@jkoppel
jkoppel / jnettool.py
Created September 16, 2017 19:17
Example from Raymond Hettinger's talk, "Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015"
# From "Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015"
# Bad code
import jnettools.toolselements.NetworkElement, \
jnettools.tools.Routing, \
jnettools.tools.RouteInspector
ne=jnettools.tools.elements.NetworkElement( '171.0.2.45' )
try:
@mrtns
mrtns / README.md
Last active January 14, 2023 05:07
Markdown-based Literate Programming

R Ecosystem

  • R Markdown

    Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL.

Python Ecosystem

  • Pweave

    Pweave is a scientific report generator and a literate programming tool for Python. It can capture the results and plots from data analysis and works well with numpy, scipy and matplotlib.

  • podoc
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
@MichalZalecki
MichalZalecki / docx2pdf.py
Created July 8, 2017 08:09
Converting DOCX to PDF using Python
import sys
import subprocess
import re
def convert_to(folder, source, timeout=None):
args = [libreoffice_exec(), '--headless', '--convert-to', 'pdf', '--outdir', folder, source]
process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
filename = re.search('-> (.*?) using filter', process.stdout.decode())
@tammoippen
tammoippen / crappyhist.py
Last active March 20, 2024 17:54
Draw a crappy text-mode histogram of an array (python 3)
import numpy as np
def crappyhist(a, bins=50, width=140):
h, b = np.histogram(a, bins)
for i in range (0, bins):
print('{:12.5f} | {:{width}s} {}'.format(
b[i],
'#'*int(width*h[i]/np.amax(h)),
h[i],
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@leoloobeek
leoloobeek / get_gists.py
Created April 26, 2017 21:34
Download all gists for a specific user
# first: mkdir user && cd user && cp /path/to/get_gists.py .
# python3 get_gists.py user
import requests
import sys
from subprocess import call
user = sys.argv[1]
r = requests.get('https://api.github.com/users/{0}/gists'.format(user))
@erikbern
erikbern / get_n_results.py
Created March 13, 2017 02:34
Get number of search results from Google
def get_n_results_dumb(q):
r = requests.get('http://www.google.com/search',
params={'q': q,
"tbs": "li:1"})
r.raise_for_status()
soup = bs4.BeautifulSoup(r.text)
s = soup.find('div', {'id': 'resultStats'}).text
if not s:
return 0
m = re.search(r'([0-9,]+)', s)