Skip to content

Instantly share code, notes, and snippets.

View reuf's full-sized avatar

Muhamed Halilovic reuf

View GitHub Profile
# setup vagrant
gem install vagrant
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
mkdir my_vagrant_test
cd my_vagrant_test
vagrant init lucid32
vim Vagrantfile
vagrant up
vagrant ssh
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@reuf
reuf / .vimrc
Last active September 8, 2015 10:28 — forked from nardev/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@reuf
reuf / Pageload.py
Created September 30, 2015 09:32 — forked from ralphking/Pageload.py
Django search
class SearchView(FormMixin, ListView):
template_name = 'search.html'
context_object_name = 'spaces'
form_class = SearchForm
def get_initial(self):
'''get initial values from request params'''
if self.request.GET:
initial = self.request.GET.dict()
return initial
@reuf
reuf / gist:9984a5758d517bcb15a6
Created September 30, 2015 09:35 — forked from kuozo/gist:3046326
django
'''
actions.get(action)(selected)代码写的不错,干净。
源文件:https://github.com/marconi/django-quickstart/blob/master/src/todo/views.py
'''
def home(request):
todos=Todo.objects.order_by('-created')
if request.method == 'POST':
action = request.POST['action'].lower()
todo_list_form = TodoListForm(data=request.POST, todos=todos)
if todo_list_form.is_valid():
@reuf
reuf / Snipplr-25237.py
Created September 30, 2015 09:36 — forked from lambdamusic/Snipplr-25237.py
Django: Django and JSON
def json_response(something):
from django.utils import simplejson
return HttpResponse(simplejson.dumps(something),
content_type='application/json; charset=UTF-8')
@reuf
reuf / Django + Ajax dynamic forms
Created September 30, 2015 09:37 — forked from goldhand/Django + Ajax dynamic forms .py
#Django form with Ajax A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin. There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdate…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
#views.py
@reuf
reuf / django ajax csfr token
Created September 30, 2015 09:37 — forked from elin3t/django ajax csfr token
django ajax csft token
//query
$.ajax({
data: 'csrfmiddlewaretoken={{ csrf_token }}&...,
type: 'post',
});
//json
$.ajax({
data: {'csrfmiddlewaretoken': '{{ csrf_token }}', ...},
@reuf
reuf / django-ajax.html
Created September 30, 2015 09:37 — forked from Djiit/django-ajax.html
django-ajax
<polymer-element name="django-ajax" extends="core-ajax">
<script>
Polymer({
getCSRFCookie: function() {
b = document.cookie.match('(^|;)\\s*csrftoken\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
},
ready: function() {
this.super();
this.headers = {
@reuf
reuf / RBTree
Created September 30, 2015 10:09 — forked from adderllyer/RBTree
red-black tree implementation
package com.ds.tree.rbtree;
import java.util.LinkedList;
import java.util.Queue;
import com.ds.tree.adt.BinarySearchTree;
import com.ds.tree.adt.TreeTraversal;
/**