This file contains 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
# 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 |
This file contains 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
<?php | |
class BlogController extends Controller | |
{ | |
/** | |
* Posts | |
* | |
* @return void | |
*/ | |
public function showPosts() |
This file contains 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 " 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 |
This file contains 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
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 |
This file contains 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
''' | |
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(): |
This file contains 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 json_response(something): | |
from django.utils import simplejson | |
return HttpResponse(simplejson.dumps(something), | |
content_type='application/json; charset=UTF-8') |
This file contains 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
#models.py | |
class Task(models.Model): | |
title = models.CharField(max_length=255) | |
description = models.TextField() | |
def __unicode__(self): | |
return self.title | |
#views.py |
This file contains 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
//query | |
$.ajax({ | |
data: 'csrfmiddlewaretoken={{ csrf_token }}&..., | |
type: 'post', | |
}); | |
//json | |
$.ajax({ | |
data: {'csrfmiddlewaretoken': '{{ csrf_token }}', ...}, |
This file contains 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
<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 = { |
This file contains 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
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; | |
/** |
OlderNewer