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
| from django import forms | |
| class ConfigurableModelForm(forms.ModelForm): | |
| def __init__(self, *args, **kwargs): | |
| super(ConfigurableModelForm, self).__init__(*args, **kwargs) | |
| opts = self.Meta | |
| if hasattr(opts, 'field_conf'): | |
| self.update_fields(opts.field_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
| workon test-project | |
| cdvirtualenv | |
| pip install -e git+git://github.com/antonagestam/django-text.git | |
| cd src | |
| sudo rm -r django-text | |
| ln -s ~/path/to/local/django-text/ django-text |
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
| <div class="posts"> | |
| <div class="row"> | |
| {% for post in posts %} | |
| <div class="post">{{ post }}</div> | |
| {% if not forloop.last %} | |
| {% cycle '' '' '</div><div class="row">' %} | |
| {% endif %} | |
| {% endfor %} | |
| </div> | |
| </div> |
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
| from django.shortcuts import render | |
| from models import User, ItemDetail | |
| def my_view(request): | |
| gadget_users = User.objects.filter(item_detail__category=ItemDetail.GADGET) | |
| return render(request, 'yourtemplate.html', {'gadget_users': gadget_users}) |
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
| def get_category_users(category): | |
| return User.objects.filter(item_detail__category=category) | |
| def item_upload(request): | |
| if request.method == 'POST': | |
| item = ItemUpload(user=request.user) | |
| form = ItemUploadForm(request.POST,request.FILES, instance=item) | |
| if form.is_valid(): | |
| form.save() |
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
| <h3>Gadget users</h3> | |
| <ul> | |
| {% for user in gadget_users %} | |
| <li>{{ user }}</li> | |
| {% endfor %} | |
| </ul> |
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
| $ brew update | |
| Already up-to-date. | |
| $ brew doctor | |
| Error: No such file or directory - ~/.homebrew_temp/doctor20150625-10964-1gbo4wh | |
| $ brew doctor --debug | |
| Error: No such file or directory - ~/.homebrew_temp/doctor20150625-10987-122pw1l | |
| /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:85:in `mkdir' | |
| /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:85:in `block in mktmpdir' | |
| /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:142:in `create' | |
| /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:85:in `mktmpdir' |
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
| """ | |
| >>> comp("""Hi folks | |
| ... What is the best way to clear a Riak bucket of all key, values after | |
| ... running a test? | |
| ... I am currently using the Java HTTP API. | |
| ... """, """Hi folks | |
| ... | |
| ... What is the best way to clear a Riak bucket of all key, values after | |
| ... running a test? | |
| ... I am currently using the Java HTTP API. |
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
| osascript -e 'tell application "Spotify" to activate'; | |
| sleep 5; | |
| osascript -e 'tell application "Spotify" to set shuffling to true'; | |
| osascript -e 'tell application "Spotify" to play track "spotify:user:bananatrapp:playlist:4a6RQIxSGXZVvXy6ckDeL5"' |
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
| set nocompatible " be iMproved, required | |
| filetype off " required | |
| " set the runtime path to include Vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " alternatively, pass a path where Vundle should install plugins | |
| "call vundle#begin('~/some/path/here') | |
| " let Vundle manage Vundle, required |