Skip to content

Instantly share code, notes, and snippets.

View coagulant's full-sized avatar

Ilya Baryshev coagulant

View GitHub Profile
@mtayseer
mtayseer / print_pkg_deps.py
Last active August 29, 2015 14:01
Print a list of all installed Python packages & their dependencies
import pkg_resources, pprint
requires = {p.key: [r.key for r in p.requires()] for p in pkg_resources.working_set}
def graph(pkg):
if not requires[pkg]:
return {pkg: {}}
return {pkg: {k: v for p in requires[pkg] for k, v in graph(p).items() }}
@piumosso
piumosso / path.css
Created October 15, 2012 14:43
Path for gitlab wiki style
.file_holder .file_content.wiki {
max-width: 800px;
font-size: 15px;
font-family: Helvetica, Arial, sans-serif;
line-height: 20px;
}
.file_content.wiki ul li {
list-style: none;
}
.file_content.wiki li {
@dzaporozhets
dzaporozhets / gitlab_gitolite.sh
Created October 24, 2012 13:58
Fix gitolite for gitlab 3
# GITOLITE 3
sudo -u git -H sed -i "s/\(GIT_CONFIG_KEYS\s*=>*\s*\).\{2\}/\1'\.\*'/g" /home/git/.gitolite.rc
# GITOLITE 2
sudo -u git -H sed -i 's/\(GL_GITCONFIG_KEYS\s*=>*\s*\).\{2\}/\1"\.\*"/g' /home/git/.gitolite.rc
@rbarrois
rbarrois / settings.py
Created September 29, 2013 20:58
Helper to get pretty (?) exceptions in Django templates for invalid variable names.
class InvalidStringHandler(object):
"""Custom handler for invalid string in templates."""
def __call__(self):
"""Force crashes in {{ foo|sth }}, without breaking __str__."""
import ipdb; ipdb.set_trace()
raise ValueError()
def __nonzero__(self):
"""So that '{% if foo %}' doesn't break."""
@AndrewIngram
AndrewIngram / storages.py
Created June 18, 2013 09:22
Hybrid Storage Backend for Django
from django.conf import settings
from django.core.files.storage import Storage
from django.utils import importlib
def load_class(class_string):
class_module, class_name = class_string.rsplit('.', 1)
class_module = importlib.import_module(class_module)
return getattr(class_module, class_name)
@ftao
ftao / install_pytho27.sh
Created July 7, 2011 10:00
install python 2.7 on debian 6
#!/bin/sh
mkdir ~/down/
cd ~/down/
sudo apt-get install build-essential
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xzf Python-2.7.2.tgz
cd Python-2.7.2
sudo apt-get install libsqlite3-dev zlib1g-dev libncurses5-dev
sudo apt-get install libgdbm-dev libbz2-dev libreadline5-dev
sudo apt-get install libssl-dev libdb-dev
import datetime
import ssl
import sys
import warnings
from requests.adapters import HTTPAdapter
from requests.packages import urllib3
from requests.packages.urllib3.util import ssl_
from requests.packages.urllib3.exceptions import (
@mitsuhiko
mitsuhiko / .gitconfig
Last active January 30, 2021 20:22
Adds the ultimate of all pull request commands to git
# Alternatively don't use slog but something else. I just like that more.
[aliases]
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \
git fetch origin pull/$1/head:pr/$1 && \
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \
git branch -D PR_MERGE_HEAD && \
git checkout $b && echo && \
git diff --stat $b..pr/$1 && echo && \
@EtsuNDmA
EtsuNDmA / test_respx_cheetsheet.py
Last active November 24, 2021 10:17
Небольшая шпаргалка по библиотечке respx
"""
Небольшая шпаргалка по библиотечке respx. Все это есть в документации https://lundberg.github.io/respx/guide/,
но местами написано очень коротко и не очевидно.
Зависимости: python > 3.10, httpx, respx, pytest-asyncio
"""
from typing import Any
import httpx
import pytest
@svartalf
svartalf / elasticsearch_ru_stemming_and_morphology.py
Last active January 13, 2022 12:21
Example of the ElasticSearch configuration for russian stemming and morphology
requests.put('http://localhost:9200/site/', data=json.dumps({
'settings': {
'analysis': {
'analyzer': {
'ru': {
'type': 'custom',
'tokenizer': 'standard',
"filter": ['lowercase', 'russian_morphology', 'english_morphology', 'ru_stopwords'],
},
},