Skip to content

Instantly share code, notes, and snippets.

@toudi
toudi / FormatPythonCode.py
Created November 22, 2022 14:26
run black and isort inside sublime project
# I've installed LSP and LSP-pyright but I could not make it to format code and sort imports
# despite the fact that it works perfectly for golang
# out of pure frustration I created this little plugin:
from os.path import exists
from pathlib import Path
from subprocess import call
import sublime
import sublime_plugin
import requests
from requests.auth import HTTPBasicAuth
import re
from StringIO import StringIO
JIRA_URL = 'https://your-jira-url.tld/'
JIRA_ACCOUNT = ('jira-username', 'jira-password')
# the JIRA project ID (short)
JIRA_PROJECT = 'PRO'
GITLAB_URL = 'http://your-gitlab-url.tld/'
@toudi
toudi / utils.py
Created November 14, 2014 14:37
recursive model_to_dict
from django.forms.models import model_to_dict as fmodel_to_dict
from django.db.models.related import RelatedObject
def remove_baseattr_name(prefix):
def inner(value):
return value[len(prefix)+1:]
return inner
@toudi
toudi / gist:7527501
Created November 18, 2013 13:11
ConfigParser that emulates ZendConfigParser (multiple sections inheritance)
from ConfigParser import SafeConfigParser, NoOptionError, NoSectionError
class ZendConfigParser(SafeConfigParser):
def read(self, filenames):
self._parents = {}
self._s = {}
SafeConfigParser.read(self, filenames)
for section in self.sections():
if ':' in section:
s = section.split(':')
@toudi
toudi / finders.py
Created March 27, 2013 09:54
staticfiles finder which allows you to use STATIC_ROOT for hosting static files on development server
from django.contrib.staticfiles.finders import DefaultStorageFinder
from django.conf import settings
from django.core.files.storage import FileSystemStorage
class StaticRootFinder(DefaultStorageFinder):
def __init__(self, *args, **kwargs):
self.storage = FileSystemStorage(location=settings.STATIC_ROOT, base_url=settings.STATIC_URL)
super(StaticRootFinder, self).__init__(*args, **kwargs)
@toudi
toudi / gist:973626
Created May 15, 2011 22:41
countWalkerPatch
diff --git a/library/DoctrineExtensions/Paginate/CountWalker.php b/library/DoctrineExtensions/Paginate/CountWalker.php
index 6512435..44456d8 100644
--- a/library/DoctrineExtensions/Paginate/CountWalker.php
+++ b/library/DoctrineExtensions/Paginate/CountWalker.php
@@ -31,9 +31,14 @@ class CountWalker extends TreeWalkerAdapter
{
$parent = null;
$parentName = null;
-
+ $removeAllGroupBy = false;
diff --git a/src/DiffDirPane.cpp b/src/DiffDirPane.cpp
index 5060137..9b39681 100644
--- a/src/DiffDirPane.cpp
+++ b/src/DiffDirPane.cpp
@@ -32,18 +32,18 @@ enum {
WX_DECLARE_STRING_HASH_MAP( wxTreeItemId, NameToTreeIdHash );
BEGIN_EVENT_TABLE(DiffDirPane, wxPanel)
- EVT_TREE_ITEM_GETTOOLTIP(ID_DIFFTREE, OnTreeGetToolTip)
- EVT_TREE_ITEM_MENU(ID_DIFFTREE, OnTreeMenu)