Skip to content

Instantly share code, notes, and snippets.

View rominf's full-sized avatar

Roman Inflianskas rominf

  • Helsinki, Finland
  • 19:38 (UTC +03:00)
  • X @_rominf
View GitHub Profile
@rominf
rominf / test_crash.py
Created November 17, 2013 18:03
UnicodeDecodeError on python3 with pygments and unicode source file https://github.com/inducer/pudb/issues/56
print('Hello,')
print('Привет,!')
@rominf
rominf / gist:c966eb91a29fe0217dcc
Created July 3, 2014 19:49
salt #13878 output
localhost:~ # salt-call state.sls cmd_fail -l debug
[DEBUG ] Reading configuration from /etc/salt/minion
[INFO ] Using cached minion ID from /etc/salt/minion_id: svk_server-vm
[DEBUG ] Configuration file path: /etc/salt/minion
[DEBUG ] Reading configuration from /etc/salt/minion
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Decrypting the current master AES key
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Loaded localemod as virtual locale
@rominf
rominf / tabcloseduplicates.penta
Last active August 29, 2015 14:12 — forked from gwash/tabcloseduplicates.penta
pentadactyl command to close duplicate tabs + anchors
com -d "Delete duplicate tabs" tabcloseduplicates,tabclosed -js let seen={},vtabs=tabs.visibleTabs,i=vtabs.length;while(i--){let loc=vtabs[i].linkedBrowser.contentDocument.location.href||"";if(Object.prototype.hasOwnProperty.call(seen, loc)){config.tabbrowser.removeTab(vtabs[i]);}else{seen[loc]=true;}}
com -d "Delete duplicate tabs (including tabs with different view of the same page, i.e. pages with anchors)" tabcloseduplicatesanchors,tabcloseda -js let seen={},vtabs=tabs.visibleTabs,i=vtabs.length;while(i--){let loc=vtabs[i].linkedBrowser.contentDocument.location.href.replace(/#[^#]*$/, '')||"";if(Object.prototype.hasOwnProperty.call(seen, loc)){config.tabbrowser.removeTab(vtabs[i]);}else{seen[loc]=true;}}
@rominf
rominf / postgresql_crop_image.sql
Last active August 8, 2020 14:30
PostgreSQL function to crop images (uses plpythonu and python PIL)
CREATE OR REPLACE FUNCTION crop(image bytea, rect box)
RETURNS bytea
LANGUAGE plpythonu
AS $function$
if ('io' in SD) and ('StringIO' in SD) and ('Image' in SD):
io = SD['io']
StringIO = SD['StringIO']
Image = SD['Image']
else:
import io, StringIO
@rominf
rominf / postgresql_resize_image.sql
Last active April 3, 2024 08:04
PostgreSQL function to resize images (uses plpythonu and python PIL)
CREATE OR REPLACE FUNCTION resize(image bytea, h integer, w integer)
RETURNS bytea
LANGUAGE plpythonu
AS $function$
if ('io' in SD) and ('StringIO' in SD) and ('Image' in SD):
io = SD['io']
StringIO = SD['StringIO']
Image = SD['Image']
else:
import io, StringIO
import java.util.regex.Matcher;
import java.util.regex.Pattern;
String normalizePostcode(String postcode, String country) {
Map<String, List<String>> rules = new TreeMap<String, List<String>>() {{
put("Netherlands", Arrays.asList("(NL-)?(\\d{4})\\W*([A-Z]{2})", , "\$2\$3"));
put("United Kingdom", Arrays.asList("(?i)([A-Z]{1,2}[0-9]{1,2}[A-Z]?)\\s*([0-9][A-Z]{2})", "\$1\$2"));
}}
Pattern pattern = Pattern.compile(rules.get(country).get(0));
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Window 2.2
Window {
id: window
visible: true
width: 640
height: 480
title: qsTr("Hello World")
import asyncio
from aiogram import Bot, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import Dispatcher
from aiogram.types import ParseMode, InlineKeyboardButton, InlineKeyboardMarkup
from aiogram.utils import executor
from aiogram.utils.markdown import text, bold
API_TOKEN = ''
@rominf
rominf / pyproject.toml
Last active September 19, 2018 10:51
pyproject.toml of profanity-filter
[tool.poetry]
name = "profanity-filter"
version = "1.0.0"
description = "A Python library for detecting and filtering profanity"
authors = ["Roman Inflianskas <infroma@gmail.com>"]
license = "GPL-3.0+"
readme = "README.md"
repository = "https://github.com/rominf/profanity-filter"
keywords = ["library", "profanity", "filter", "censor"]
classifiers = [
@rominf
rominf / pyproject.toml
Created October 2, 2018 10:48
Poetry remove causes package update
[tool.poetry]
name = "kgbot"
version = "1.0.0"
description = "Library for creating telegram bots using aiogram library"
authors = ["Roman Inflianskas <r.inflyanskas@zmeke.com>"]
license = "Apache-2.0"
[tool.poetry.dependencies]
python = "^3.6"
aiogram = "^1.4"