for file in *.fb2; do ebook-convert "$file" "$file.mobi"; done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=1; for file in *.jpg; do mv "$file" "${a}.jpg"; let a=a+1; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find ./ -name '*~' -exec rm '{}' \; -print -or -name ".*~" -exec rm {} \; -print |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 .*$" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = %some string% | |
size = %chunk size% | |
[s[n:n+size] for n in xrange(0, len(s), size)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:source-file ~/.tmux.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model._meta.get_all_field_names() |