Skip to content

Instantly share code, notes, and snippets.

@ReallyLiri
ReallyLiri / Jira-Disable-Inline.js
Last active February 15, 2024 11:35
Tampermonkey scripts
// ==UserScript==
// @name Jira-Disable-Inline
// @namespace http://tampermonkey.net/
// @version 0.1
// @description disable jira issue click-to-edit (only applies few moments after page load, so you can have some grace time if you actually wanna edit)
// @author You
// @match https://*.atlassian.net/browse/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@ReallyLiri
ReallyLiri / ModuleFilter.py
Last active July 13, 2023 11:39
ModuleFilter.py
class ModuleFilter(logging.Filter):
"""
Filters any logger from outside `root_path` to levels ERROR and above
"""
def __init__(self, root_path: str, *args, **kwargs):
self.root_path = root_path
super.__init__(*args, **kwargs)
def filter(self, record: logging.LogRecord) -> bool:
@ReallyLiri
ReallyLiri / gist:82082e430569a013c5d3cdac6aec48e4
Last active February 22, 2021 08:15
MetricsLoggingInterceptor.cs
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Castle.DynamicProxy;
using Microsoft.Extensions.Logging;
using Scrutor;
@ReallyLiri
ReallyLiri / ServiceCollectionExtensions.cs
Last active September 28, 2022 06:37
ASP.NET dependency injection extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace ServiceCollectionExtensions
{
public static class ServiceCollectionExtensions
@ReallyLiri
ReallyLiri / krsync.sh
Created July 11, 2019 08:57
KubernetesRsync
#!/bin/bash
# USAGE: ./krsync.sh <src> <dst> , with either src/dst dir pointing to a pod (of the format 'pod:/<path>')
# Check if we are running within --rsh already (remote shell)
if [ -z "$KRSYNC_STARTED" ]; then
# not using --rsh
export KRSYNC_STARTED=true
exec rsync --blocking-io --rsh "$0" -a --progress --stats $@ # re-activate the script as remote shell
fi
@ReallyLiri
ReallyLiri / gcr-cleanup.sh
Last active February 16, 2021 11:34
Google Container Registry cleanup
#!/bin/bash
# USAGE: gcr-cleanup.sh [tag-to-clean]
# if you want to cleanup a specific tag, pass its name, otherwise all non-tagged images will be cleaned
images=$(gcloud container images list --repository=gcr.io/xxx --format='get(name)')
for image_name in $images; do
if [ -n "$1" ]
then
gcloud container images untag --quiet $image_name:$1
@ReallyLiri
ReallyLiri / remote_debug.py
Created July 11, 2019 08:55
Attach remote debugger to python code point
import sys
import os
import pydevd
import logging
def stop_on():
sys.path.append('/Applications/PyCharm.app/Contents/helpers/pydev/')
sys.path.append('/Applications/PyCharm.app/Contents/debug-eggs/')
@ReallyLiri
ReallyLiri / run_process.py
Created July 11, 2019 08:53
Run external processes from python
import gzip
import shutil
import logging
import os
from subprocess import Popen, PIPE, TimeoutExpired
SUCCESS_CODE = 0
TIMEOUT_SECONDS = 600
@ReallyLiri
ReallyLiri / map_reduce.py
Created July 11, 2019 08:52
Simply map-reduce with multiprocessing
import logging
import pandas as pd
import queue
from multiprocessing import Process, Queue
from time import sleep
DEFAULT_TIMEOUT_SEC = 60*10
def _chunks(l, n):
@ReallyLiri
ReallyLiri / injectable_resource.py
Created July 11, 2019 08:47
Flask resource with http method logic injection capability
from functools import wraps
from flask_restplus import Resource
HTTP_METHODS = ["get", "post", "delete", "put", "patch"]
class InjectableResource(Resource):
def hook_all_http_methods(self, pre_execution=None, post_execution=None, exception_handler=None):
for method in HTTP_METHODS: