Skip to content

Instantly share code, notes, and snippets.

View teshanshanuka's full-sized avatar

Teshan Liyanage teshanshanuka

View GitHub Profile
@zed
zed / cydot.pyx
Created March 16, 2012 18:25
Naive O(N**3) 2D np.dot() multithreaded implementation (CPython extension in Cython)
#cython: boundscheck=False, wraparound=False
import numpy as np
cimport numpy as np
from cython.parallel cimport prange
def dot(np.ndarray[np.float32_t, ndim=2] a not None,
np.ndarray[np.float32_t, ndim=2] b not None,
np.ndarray[np.float32_t, ndim=2] out=None):
"""Naive O(N**3) 2D np.dot() implementation."""
@tetrillard
tetrillard / smsbackuprestore-extractor.py
Created November 24, 2014 22:57
SMS Backup & Restore : Extract images and videos from a backup file
#!/usr/bin/env python
# -*- coding: utf8 -*-
# SMSBackupRestore extractor
#
# smsbackuprestore-extractor.py
# 24/11/2014
#
# This script will extract all images and videos retrieved
# from a xml backup of the Android application "SMS Backup & Restore".
@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text
┌─────────────┐     ╭─────────╮     ┏━━━━━━┓
│ I'm a box!  ├─────┤ Rounded ┝━━━━━┫ Bold ┃
└──────┬──────┘     ╰─────────╯     ┗━━━━━━┛
       │
 ┌─────┴────┐      ┌──────────┐
 │ Me too!  ├──────┤ Me Three │
 └──────────┘      └──────────┘