Skip to content

Instantly share code, notes, and snippets.

@bazub
bazub / gist:3877971
Created October 12, 2012 08:17
Grayscale/Binary images using PIL
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)
@glueckpress
glueckpress / woocommerce-delete-customer-ip.php
Created January 9, 2014 15:29
Snippet to clear customer IP address when order is sent. #woocommerce #wordpress
<?php
/**
* Snippet for deleting the customer IP address from WooCommerce orders.
* Important for Trusted Shops® certificates in Germany.
*/
add_action( 'woocommerce_checkout_update_order_meta', 'mp1401091554', 1 );
function mp1401091554( $order_id ) {
update_post_meta(
$order_id,
'_customer_ip_address',
@Morley93
Morley93 / openvpn.md
Last active July 1, 2023 03:26
This is how you can take an openvpn .ovpn config file and extract the certificates/key required to import the profile into NetworkManager.

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
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:
@ipmb
ipmb / ratelimit.nginxconf
Last active April 5, 2024 00:46
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;
@musukvl
musukvl / medusa.html
Created August 2, 2017 19:33
medusa.io RSS feeds
<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
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):