Skip to content

Instantly share code, notes, and snippets.

@bazub
bazub / gist:3877971
Created October 12, 2012 08:17
Grayscale/Binary images using PIL
View gist:3877971
im=Image.open("1.jpg")
#im=im.rotate(1)
im.save("e.jpg")
im2=im.convert("L")
im2.save("b.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)
im.save("d.jpg")
img="d.jpg"
result = tesseract.ProcessPagesWrapper(img,api)
@Morley93
Morley93 / openvpn.md
Last active January 12, 2023 16:46
This is how you can take an openvpn .ovpn config file and extract the certificates/key required to import the profile into NetworkManager.
View openvpn.md

OpenVPN .ovpn manipulation.

This is how you can take an OpenVPN .ovpn config file and extract the certificates/keys required to import the profile into NetworkManager.

  • Download the .ovpn file. Save it somewhere you can store it permanently (I use ~/.vpn).
  • Copy from between <ca> tags into ca.crt, remove <ca> tags.
  • Copy from between <cert> tags into client.crt, remove <cert> tags.
  • Copy from between <key> tags into client.key, remove <key> tags.
  • Copy from between <tls-auth> tags into ta.key, remove <tls-auth> tags.
  • Remove the line "key-direction 1"
  • Above "# -----BEGIN RSA SIGNATURE-----" insert the following lines.
@eyeNsky
eyeNsky / mapnik-rotate
Last active November 27, 2018 21:55
rotate mapnik output map
View mapnik-rotate
Mapnik supports the PROJ.4 WKT for projections and buried deep in the doc's is one called
'Two Point Equidistant'. You provide the left and right points and the map is rotated
such that these two points are horizontal in the output.
This allows you to rotate the map to any angle (including south up!!) and the text is
rendered correctly! You don't have to change the projections of your input vectors.
Simply tweak the mapnik generate_image.py script like this:
Change:
@musukvl
musukvl / medusa.html
Created August 2, 2017 19:33
medusa.io RSS feeds
View medusa.html
<link rel="alternate" type="application/rss+xml" title="Meduza — Все" href="https://meduza.io/rss/all">
<link rel="alternate" type="application/rss+xml" title="Meduza — Новости" href="https://meduza.io/rss/news">
<link rel="alternate" type="application/rss+xml" title="Meduza — Шапито" href="https://meduza.io/rss/fun">
@rafaponieman
rafaponieman / rename_app.py
Created December 6, 2017 00:21
Django rename app management command
View rename_app.py
import argparse
from django.core.management.base import BaseCommand
from django.db import connection
class Command(BaseCommand):
help = 'Renames app. Usage rename_app [old_name] [new_name] [classes ...]'
def add_arguments(self, parser):