Skip to content

Instantly share code, notes, and snippets.

View antonagestam's full-sized avatar
🍉

Anton Agestam antonagestam

🍉
View GitHub Profile
function __shcmd_complete(){
echo "COMPLETING WOHO!"
tput rc
tput ed
echo "COMPLETING WOHO!"
export READLINE_LINE="uh-huh"
}
function read_completion(){
set -o emacs
@antonagestam
antonagestam / gist:095ddb4e4f4cb6029d28
Last active August 29, 2015 14:06
Working with Zanox

Getting started with Zanox

Confused!? Yeah, me too ... Zanox' developer center is super-confusing and even finding the documentation for the correct API was tough. I had to realize that our app should access the Publisher API, which kind of makes sense but I didn't look at it first because I was thinking it's for publishing items to Zanox.

@antonagestam
antonagestam / forms.py
Last active August 29, 2015 14:11
Configurable Model Form
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)
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
@antonagestam
antonagestam / cycle_example.html
Last active August 29, 2015 14:17
Cycle example
<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>
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})
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()
<h3>Gadget users</h3>
<ul>
{% for user in gadget_users %}
<li>{{ user }}</li>
{% endfor %}
</ul>
$ 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'
@antonagestam
antonagestam / comp.py
Last active August 29, 2015 14:26
compare two strings word by word
"""
>>> 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.