This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
'''Crop an image to just the portions containing text. | |
Usage: | |
./crop_morphology.py path/to/image.jpg | |
This will place the cropped image in path/to/image.crop.png. | |
For details on the methodology, see | |
http://www.danvk.org/2015/01/07/finding-blocks-of-text-in-an-image-using-python-opencv-and-numpy.html | |
UPDATE 2017-05-07 by hmmbug: | |
- Removed dependency on PIL and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A python port of http://stackoverflow.com/a/23565051/2416742 | |
import cv2 | |
def detect_letters(img, struct_elem_x=17, struct_elem_y=3, contour_size=100): | |
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
img_sobel = cv2.Sobel(img_gray, cv2.CV_8U, 1, 0, ksize=3, scale=1, | |
delta=0, borderType=cv2.BORDER_DEFAULT) | |
ret, img_threshold = cv2.threshold(img_sobel, 0, 255, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# A mini hipchat client. Sends a message to a predetermined room. | |
# Requires HypChat (pip install hypchat) | |
# | |
# Mark Hollow. April 2015 | |
# | |
# Config file (hipchat.json), in JSON format: | |
# { | |
# "hipchat": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set disk scheduler | |
sed -i "/^echo .*queue\/scheduler$/d" /etc/rc.local | |
for d in /dev/sd? | |
do | |
device=${d/\/dev\//} | |
rotational=$(cat /sys/block/${device}/queue/rotational) | |
if [ "$rotational" = "0" ] ; then | |
echo noop > /sys/block/${device}/queue/scheduler | |
echo "echo noop > /sys/block/${device}/queue/scheduler" >> /etc/rc.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP_ADDR=$(hostname -i) | |
IFS=. read -r io1 io2 io3 io4 <<< "$IP_ADDR" | |
IFS=. read -r mo1 mo2 mo3 mo4 < <(ifconfig -a | sed -n "/inet addr:$IP_ADDR /{ s/.*Mask://;p; }") | |
NET_ADDR="$((io1 & mo1)).$(($io2 & mo2)).$((io3 & mo3)).$((io4 & mo4))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# goes in /etc/nginx/sites-available & link in ../sites-enabled | |
upstream graphite { | |
server unix:///tmp/uwsgi.sock; | |
} | |
server { | |
listen 9002; | |
server_name localhost; |