Skip to content

Instantly share code, notes, and snippets.

@andreyshuster
andreyshuster / gist:a6d8013bbe3999b126ae
Created June 17, 2014 07:34
pain and suffer with git-tf case insensitive issues
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ''solution\Schema Objects\Programmability\Stored Procedures\dbo.Product_recommendation_insert.proc.sql''' --prune-empty --tag-name-filter cat -- --all
@andreyshuster
andreyshuster / gist:0b2180abd23b7a7e505c
Created June 25, 2014 11:16
git use default https instead of git
git config url.https://.insteadOf git://
@andreyshuster
andreyshuster / gist:8d4ff5a94f7732c826e2
Created June 25, 2014 11:58
yeoman interesting generators
npm install -g generator-webapp
npm install -g generator-chromeapp
npm install -g generator-chrome-extension
npm install -g generator-angular
@andreyshuster
andreyshuster / gist:1eb5b349443fbd9c9087
Created July 29, 2014 09:05
pre-commit hook to check pep8
#!/bin/sh
FILES=$(git diff --cached --name-status | grep -v ^D | awk '$1 $2 { print $2}' | grep -e .py$)
if [ -n "$FILES" ]; then
pep8 -r $FILES
fi
@andreyshuster
andreyshuster / gist:6a3afe2cb4afa4267482
Created July 29, 2014 10:20
get model fields in django
model._meta.get_all_field_names()
@andreyshuster
andreyshuster / gist:f540f1866aa7b9c7e166
Last active August 29, 2015 14:04
django form handling
@render_to('contact.html')
def contact(request):
form = ContactForm(request.POST or None)
if form.is_valid():
# обрабатываем данные. Например, делаем form.save()
# ...
return redirect('url_name', param1=value)
return {'form': form}
:source-file ~/.tmux.conf
@andreyshuster
andreyshuster / gist:4d6519396f6273c18f98
Created August 10, 2014 05:33
split string in chunks
s = %some string%
size = %chunk size%
[s[n:n+size] for n in xrange(0, len(s), size)]
@andreyshuster
andreyshuster / gist:ecb683d31e11ac53bd70
Created August 21, 2014 06:59
colored tail logs. requires ack-grep
tail -f /var/log/nginx/access.log | ack-grep --flush --passthru --color --color-match=red "^.* 404 .*$" | ack-grep --flush --passthru --color --color-match=green "^.* 200 .*$"
@andreyshuster
andreyshuster / gist:0b99ef2b30779fd01649
Created December 3, 2014 12:04
user_passes_test class based
# http://stackoverflow.com/questions/8082670/django-user-passes-test-decorator
class SuperuserRequiredMixin(object):
@method_decorator(user_passes_test(lambda u: u.is_superuser))
def dispatch(self, *args, **kwargs):
return super(SuperuserRequiredMixin, self).dispatch(*args, **kwargs)
class MyView(SuperuserRequiredMixin, View):
def get(self, request):
...