Skip to content

Instantly share code, notes, and snippets.

@turicas
turicas / example_image_utils.py
Created December 10, 2011 19:04
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@theorm
theorm / __init__.py
Last active April 14, 2020 18:45
Pluggable API using Flask MethodView.
# -*- coding: utf-8 -*-
from .bananas import Bananas
from .base import the_api
the_api.add_url_rule('/bananas', view_func=Bananas.as_view('bananas'))
the_api.add_url_rule('/farm/<farm_id>/bananas', view_func=Bananas.as_view('bananas_from_a_farm'))
__all__ = [
@pinceladasdaweb
pinceladasdaweb / imgur.js
Created March 27, 2014 13:14
Upload images to imgur via JavaScript
/*
--------------------------------
imgur Upload
--------------------------------
+ https://github.com/pinceladasdaweb/imgur-upload
+ version 1.1
+ Copyright 2014 Pedro Rogerio
+ Licensed under the MIT license
+ Documentation: https://github.com/pinceladasdaweb/imgur-upload
@th0ma5w
th0ma5w / comparer.py
Created April 8, 2014 23:00
CSV logging script for stock dump1090
#!/usr/bin/python
#
# CSV logging script for stock dump1090
#
# Uses the Requests library to compare the state of planes in view
# and prints changes to standard out
#
# Start dump1090
# modify this script to point to your dump1090 URL if different
# run the script and pipe the output to a file eg:
@svetlyak40wt
svetlyak40wt / cached_mixin.py
Last active January 3, 2022 22:44
Cache mixin for Django class based views.
class CachedMixin(object):
def get(self, *args, **kwargs):
cache_key, cache_ttl = self.get_cache_params(*args, **kwargs)
response = cache.get(cache_key)
if response is None:
response = super(CachedMixin, self).get(*args, **kwargs)
response.render()
cache.set(cache_key, response, cache_ttl)
return response
@rfong
rfong / cprofile.py
Last active November 6, 2021 21:02
Django profiling decorator
import cProfile
import pstats
from django.utils.functional import wraps
def cprofile(sort_by='cumulative', n=20):
"""Decorator to profile a function."""
def decorator(func):
@wraps(func)
@raghothams
raghothams / server.py
Created February 22, 2016 10:10
Flask request header decorator
from functools import wraps
from flask import Flask, request
app = Flask(__name__)
key = "ya29.bwLu0ruxXdXe_RMOSYgfiCPORNMHLkf9rCDmV1rKtWu90TuF1d8B2SmdUlrjeOWNYThkgMM"
def secure(f):
@wraps(f)
def check_authorization(*args, **kwargs):
if request.headers.get("Authorization") == key:
return f()
@Breakthrough
Breakthrough / example_ntfsresize.txt
Last active December 2, 2023 07:39
Bash script to show the progress of ntfsresize while installing Xubuntu (or other Debian-based variants) using the GUi installer and resizing an NTFS partition, only to be frustrated with the lack of zero time estimate or progress indicator.
$> sudo strace -p `pidof "ntfsresize"` -e trace=write 2>&1 | grep 'write(1'
[...]
write(1, " 87.38 percent completed\r", 25) = 25
write(1, " 87.38 percent completed\r", 25) = 25
write(1, " 87.92 percent completed\r", 25) = 25
write(1, " 87.92 percent completed\r", 25) = 25
[...]
@alexcasalboni
alexcasalboni / amazon-rekognition.md
Last active September 6, 2023 15:20
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search