Skip to content

Instantly share code, notes, and snippets.

View nphilipp's full-sized avatar

Nils Philippsen nphilipp

  • Red Hat
  • Leonberg, Germany
View GitHub Profile
@nphilipp
nphilipp / gist:53511d7946c2adf231aec609056c8581
Created February 9, 2024 01:15
Renovate rangeStrategy=widen poetry lockfile issue log
DEBUG: Using RE2 regex engine
DEBUG: Parsing configs
DEBUG: Checking for config file in /runner/renovate/job_config.json
DEBUG: Detected config in env RENOVATE_CONFIG
{
"config": {
"extends": [
"mergeConfidence:all-badges"
],
"prFooter": "This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/{{platform}}/{{repository}}).",
@nphilipp
nphilipp / try_except_vs_cond2.py
Last active March 3, 2023 11:17
Benchmark try/except vs. conditionals for caching (short-lived objects)
#!/usr/bin/env python
import timeit
class Foo:
base_url = "http://boo"
def __str__(self):
try:
@nphilipp
nphilipp / try_except_vs_cond.py
Last active March 3, 2023 11:17
Benchmark try/except vs. conditionals for caching (long-lived objects)
#!/usr/bin/env python
import timeit
class Foo:
base_url = "http://boo"
def __str__(self):
try:
@nphilipp
nphilipp / gist:dd14f54a28ab00ac709b40c7d7fa2b52
Last active November 8, 2021 10:41
Auto-activate Python virtualenvwrapper environment if shell is started within a project directory
# ...
# Copyright © 2021 Nils Philippsen <[email protected]>
# Licensed under the MIT license as published by the Open Source Initiative
# Auto-activate Python virtualenvwrapper environment if shell is started within a project directory
_old_nullglob=$(shopt -p nullglob)
shopt -s nullglob
unset _projdirs_venvs
declare -A _projdirs_venvs
" This must be first, because it changes other options as side effect
set nocompatible
" Vundle
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" This must be first, because it changes other options as side effect
set nocompatible
" Vundle
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
@nphilipp
nphilipp / testcase.py
Created May 19, 2019 14:55
SQLAlchemy: Association proxy of a hybrid property test case
from sqlalchemy import create_engine, Column, ForeignKey, Integer, String, Unicode
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.sql import case
maker = sessionmaker(autoflush=True, autocommit=False)
@nphilipp
nphilipp / recover_source_code.md
Created March 11, 2017 19:11 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
...
@dbus.service.method("org.atomic", in_signature='ssbbbasb',out_signature='s'
sender_keyword='dbus_sender')
def Diff(self, dbus_sender, src, dest, rpms, no_files, names_only, diff_keywords, metadata):
# check polkit authorization here
...
@nphilipp
nphilipp / role.py
Last active January 25, 2016 16:22
Memcached role exhibiting the anticipated new settings API
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015, 2016 Red Hat, Inc.
#
# Authors:
# Stephen Gallagher <[email protected]>
# Nils Philippsen <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by