Skip to content

Instantly share code, notes, and snippets.

View bluven's full-sized avatar

Jianbo Yan bluven

  • BoCloud
  • Beijing
  • 01:28 (UTC +08:00)
View GitHub Profile
@bluven
bluven / master.vim
Created May 5, 2017 13:31 — forked from gmccreight/master.vim
A script that gives you a playground for mastering vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
attrdict==2.0.0
backports.shutil-get-terminal-size==1.0.0
cffi==1.7.0
cryptography==1.4
decorator==4.0.10
Django==1.9.7
djangorestframework==3.3.3
enum34==1.1.6
idna==2.1
ipaddress==1.0.16
@bluven
bluven / bobp-python.md
Created September 3, 2016 01:16 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@bluven
bluven / const.py
Created January 25, 2016 00:48
A base class which make choices class.
import six
class ChoiceMeta(type):
def __new__(mcs, name, bases, attrs):
choices = []
values = []
labels = []
@bluven
bluven / how-to-config-ldap-auth.md
Last active September 16, 2019 07:04
how to configure ldap auth

#配置LDAP登录

配置文件:

LDAP配置文件在eoncloud_web/local/ladp_settings.py:

Example:

	#-*- coding=utf-8 -*-
    import ldap

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

#!/usr/bin/env python
# encoding: utf-8
class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
@bluven
bluven / find_middle.py
Created September 1, 2014 15:12
find middle node in singly linked list
#!/usr/bin/env python
# encoding: utf-8
class Node(object):
def __init__(self, value, next=None):
self.value = value
self.next = next
@bluven
bluven / reverse_sentence.py
Last active August 29, 2015 14:05
reverse sentence
#!/usr/bin/env python
# encoding: utf-8
import array
def reverse_array(letters, start, end):
while start < end: