Skip to content

Instantly share code, notes, and snippets.

import proj4 from 'proj4'
proj4.defs([
[
'CCCAMP2019',
'+proj=tmerc +ellps=GRS80 +lat_0=0 +lon_0=15 +k=0.9996 +x_0=114350 +y_0=-5877600 +units=m +no_defs',
],
])
type CoordsLike = [number, number] | maplibregl.LngLat
@russss
russss / deskew.py
Created September 10, 2018 12:05
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
# coding=utf-8
from __future__ import division, absolute_import, print_function, unicode_literals
import csv
import boto3
from zipfile import ZipFile
import io
import tempfile
from decimal import Decimal
import datetime
from collections import defaultdict
@russss
russss / ukpolitics-code-of-conduct.md
Last active May 5, 2016 22:16
##ukpolitics Code of Conduct
  • Sexist, homophobic, racist, transphobic, ableist, sexist or otherwise offensive remarks are not allowed. (Swearing is allowed, but never targeting another user, and never in a hateful or sexually explicit manner.)
  • Remarks that make any of the ops go “Hm, that’s inappropriate”, whether on the above list or not: also not allowed.
  • You get a warning.
  • If the warning is not taken seriously, you might get a second sterner warning in PM, if you’re lucky, and the op is feeling generous, and this is the first time. But don’t count on that.
  • If the warning is unheeded, you get kicked.
  • If you come back and continue to make trouble, you get banned.
  • If you contact the offended party, and are truly apologetic, and it was the first offense, and the op who banned you feels it’s appropriate, then you may get un-banned.
  • If an op bans you, I’m definitely not going to unban you unless they agree it’s a good idea.
  • If an op bans someone, and you think it was unjustified, take it up with that op, or with a differe
@russss
russss / commands.cfg
Created May 17, 2015 09:22
Icinga plugin for IRCCat
define command {
command_name notify-host-by-irccat
command_line /usr/local/share/nagios-plugins/icinga-irccat.py $HOSTNAME$ $HOSTSTATE$ | /bin/nc -q0 irccat-host 12345
}
define command {
command_name notify-service-by-irccat
command_line /usr/local/share/nagios-plugins/icinga-irccat.py -s "$SERVICEDESC$" -o "$SERVICEOUTPUT$" $HOSTNAME$ $SERVICESTATE$ | /bin/nc -q0 irccat-host 12345
}
@russss
russss / gist:8aa174669b2b8345eaed
Last active August 29, 2015 14:09
keybase.md
### Keybase proof
I hereby claim:
* I am russss on github.
* I am russss (https://keybase.io/russss) on keybase.
* I have a public key whose fingerprint is BE75 264B 665E D97E A5DB EFD5 F52F C56D D906 FEB1
To claim this, I am signing this object:
set nonumber
syntax on
filetype plugin indent on
augroup myfiletypes
autocmd!
autocmd BufNewFile,BufRead *.jinja set filetype=jinja
autocmd BufNewFile,BufRead *.sql set filetype=psql
autocmd BufNewFile,BufRead *.migration set filetype=psql
autocmd BufNewFile,BufRead *.vcl set filetype=vcl
# Listen to a CurrentCost monitor on the serial port and forward data to Graphite
import serial
import socket
import time
from lxml import etree
ser = serial.Serial('/dev/ttyUSB0', 57600)
def send_metric(value):
sock = socket.socket()
@russss
russss / graphite-jenkins.py
Created June 7, 2012 10:46
Quick script to send Jenkins successful build durations to Graphite
#!/usr/bin/env python
""" Sends Jenkins build duration statistics to Graphite. """
import requests
import json
from graphite import Graphite # This is our closed-source library but you get the idea.
JENKINS_URL='http://jenkins'
GRAPHITE_HOST='10.x.x.x'
GRAPHITE_PREFIX='jenkins.main.build_time.'
@russss
russss / check_rabbitmq_messages
Created September 1, 2011 15:21
Nagios/Icinga plugin to get the number of un-acked messages in a number of RabbitMQ queues
#!/usr/bin/env python
# https://gist.github.com/gists/1186406
import httplib2, json, re, sys
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-w", "--warning", dest="warning", type="int",
default="50", help="warning threshold")
parser.add_option("-c", "--critical", dest="critical", type="int",
default="100", help="critical threshold")