Skip to content

Instantly share code, notes, and snippets.

View kuozo's full-sized avatar
:shipit:
Focusing

Kollin kuozo

:shipit:
Focusing
View GitHub Profile
@kuozo
kuozo / docker_client.go
Created October 9, 2018 01:54
Docker Client
package main
import (
"context"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
)
#!/usr/bin python
# coding: utf-8
'''
Simple Script for iPhone Price.
'''
__author__ = 'Kollin'
class PhoneCost(object):
package main
import (
"fmt"
"strings"
"strconv"
"regexp"
"io/ioutil"
"net/http"
)
@kuozo
kuozo / gist:3606439
Created September 3, 2012 02:53
Get Model by Django
# coding: utf-8
from django.db.loading import get_model
@kuozo
kuozo / gist:3400649
Created August 20, 2012 04:05
re collect
import re
re.search('[0-9]','2') #-->True
re.search('[0-9]','2a') #-->True
re.search('^[0-9]$', '2') #-->True
re.search('^[0-9]$', '22') #-->False
re.search('^[0-9]{1,2}$', '22') #-->True
re.search('^[0-9]{1,}$', '22') #-->True
'''
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():
@kuozo
kuozo / gist:1116755
Created July 31, 2011 12:34
Decorator
#一个简单的装饰器
def require_int(foo):
def re(arg):
if type(arg)==int:
return foo(arg)
else :
raise 'The arg must int'
return re
@require_int