Skip to content

Instantly share code, notes, and snippets.

View MilovanTomasevic's full-sized avatar
🎯
Focusing

Milovan Tomašević MilovanTomasevic

🎯
Focusing
View GitHub Profile
@sloria
sloria / bobp-python.md
Last active July 24, 2024 02:53
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@bsphere
bsphere / py_exceptions.py
Last active November 17, 2022 15:01
How to catch exceptions raised by Python worker threads
import Queue
import threading
class WorkerThread(threading.Thread):
def __init__(self, q):
super(WorkerThread, self).__init__()
self q = q
self.exception = None
@mareksuscak
mareksuscak / bump-version.sh
Created March 15, 2015 12:56
Bump version shell script.
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"
@doobeh
doobeh / home.html
Created January 19, 2016 14:04
More complete example of FieldList with FormField
<form method="post" action="">
{{ form.name}}
{{ form.hidden_tag() }}
<br/>
{% for entry in form.hours %}
{{ loop.index0|dow }}
{{ entry() }}
{% endfor %}
<input type="submit"/>
</form>
@jriguera
jriguera / email_notify.py
Last active February 20, 2023 09:09
Email from Python with Jinja2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python 3 and compatibility with Python 2
from __future__ import unicode_literals, print_function
import os
import sys
import re
import logging
@oculushut
oculushut / downloadEnron.py
Last active April 10, 2023 23:43
Example for using Python to download file
##Python 2
#import urllib
#url = "https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tgz"
#urllib.urlretrieve(url, filename="../enron_mail_20150507.tgz")
#print "download complete!"
##Python 3
import urllib.request
url = "https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tgz"
print ("download start!")
@ivanleoncz
ivanleoncz / flask_job_scheduler.py
Last active June 27, 2024 07:23
Demonstrating APScheduler on a Flask App.
#!/usr/bin/python3
""" Demonstrating APScheduler feature for small Flask App. """
from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask
def sensor():
""" Function for test purposes. """
print("Scheduler is alive!")
@huklee
huklee / MyLogger.py
Last active January 6, 2024 18:06
python Logger using example with Singleton Pattern
# -*- coding: utf-8 -*-
import logging
import os
import datetime
import time
class SingletonType(type):
_instances = {}
@niazangels
niazangels / celery-flask-progressbar.py
Created January 22, 2018 19:11
Simple progressbar with Flask + Celery
'''
testing celery progress reporting/polling
* start server
python tempserver.py
* start worker
celery -A tempserver.celery worker -c 1 --loglevel=DEBUG
* browse to localhost:5000/
'''
from flask import Flask, request, render_template_string
@Nomane
Nomane / bump-version.sh
Last active January 15, 2024 02:49
Bump version shell script.
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"